[Kimi-K3] Add GEMM-RS for sequence parallelism (#52079)

Signed-off-by: Thien Tran <gau.nernst@yahoo.com.sg>
This commit is contained in:
Thien Tran
2026-08-13 09:02:28 -07:00
committed by GitHub
parent 96acd473a7
commit 6014f9e672
11 changed files with 1590 additions and 12 deletions
+12
View File
@@ -40,6 +40,18 @@ def recast_val(x, dtype, *, loc=None, ip=None):
return dtype(llvm.bitcast(dtype.mlir_type, x.ir_value(loc=loc, ip=ip)))
@dsl_user_op
def to_cta0_smem(ptr: cute.Pointer, *, loc=None, ip=None):
return cute.make_ptr(
ptr.dtype,
ptr.toint(loc=loc, ip=ip) & 0xFEFF_FFFF,
cute.AddressSpace.smem,
assumed_align=8,
loc=loc,
ip=ip,
)
def simple_tma_copy(atom, src, dst, mbar=None, cache_policy=None):
"""A simple helper that wraps group_modes() and tma_partition()
NOTE: this should be called WITHOUT cute.elect_one()
+47
View File
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from cutlass import Int32
from cutlass._mlir.dialects import nvvm
from cutlass.cutlass_dsl import dsl_user_op
_SPACE_MAP = {
"cta": nvvm.MBarrierSpaceKind.CTA,
"cluster": nvvm.MBarrierSpaceKind.CLUSTER,
}
_MEMORY_ORDER_MAP = {
"weak": nvvm.MemOrderKind.WEAK,
"relaxed": nvvm.MemOrderKind.RELAXED,
"acquire": nvvm.MemOrderKind.ACQUIRE,
"release": nvvm.MemOrderKind.RELEASE,
"acq_rel": nvvm.MemOrderKind.ACQ_REL,
}
@dsl_user_op
def arrive(mbar, space: str = "cta", order: str = "relaxed", *, loc=None, ip=None):
nvvm.mbarrier_txn(
mbar.to_llvm_ptr(loc=loc, ip=ip),
Int32(1).ir_value(loc=loc, ip=ip),
kind=nvvm.MBarrierTxnKind.ARRIVE,
space=_SPACE_MAP[space],
order=_MEMORY_ORDER_MAP[order],
loc=loc,
ip=ip,
)
@dsl_user_op
def arrive_expect_tx(
mbar, size, space: str = "cta", order: str = "relaxed", *, loc=None, ip=None
):
nvvm.mbarrier_txn(
mbar.to_llvm_ptr(loc=loc, ip=ip),
Int32(size).ir_value(loc=loc, ip=ip),
kind=nvvm.MBarrierTxnKind.ARRIVE_EXPECT_TX,
space=_SPACE_MAP[space],
order=_MEMORY_ORDER_MAP[order],
loc=loc,
ip=ip,
)