vllm.models.muse_spark.amd.mono.kernels.dev
¶
Device-side primitives of the Muse Spark monokernel.
Adapted from ATOM's atom/mono/device (ops.py, sync.py; MIT, AMD). Differences
from ATOM that matter:
- Mailbox tags are epoch based (
tag = epoch * 64 + slot + 1with the epoch a device word bumped once per forward inside the CUDA graph) instead of ATOM's zero-at-step-start discipline: nothing is ever zeroed. - Every spin is bounded by a wall-clock timeout (s_memrealtime, 100 MHz) that writes a diagnostic record and sets a sticky FAILED word, so a bug turns into a report instead of a hang.
Functions:
-
bf16_pair–Two f32 -> one i32 word holding (bf16(a) low, bf16(b) high), RNE.
-
bpermute–Lane
src_lane's i32 v (ds_bpermute: the LDS crossbar, no LDS memory). -
e8m0_f32–E8M0 biased exponent (an i32 holding 1..254) -> the f32 power of two.
-
fp4x8_bf16–One dword of 8 E2M1 (low nibble first) times
scale_f32-> bf16x8 -
fresh–An opaque v_mov: stops LLVM hoisting / CSE of lane math into long-lived
-
ld_vec_if–wordsdwords at dwordi, or zeros without a memory access when notok -
mb_poll–[(base, pair index, npairs in {1, 2})] -> value words, all re-loaded
-
mb_put–Pair i := (v, tag), device scope (CM_SYS: system scope, a peer GPU's buffer).
-
mb_put2–Pairs i, i+1 := (w0, tag), (w1, tag): one 16 B store (i even).
-
mb_put_if–Pair i := (v, tag) when
ok(branch-free, see st_if). -
mfma_bf16–16x16x32 bf16 MFMA: a, b bf16x8 vectors, c f32x4.
-
st_if–buffer_store of v (i32 or i32 vector) at dword i, dropped (out-of-range offset, no
-
traced–FlyDSL AST rewriting for a helper (
if/whileon traced values).
_spin_bounded(load_all, pending, health, region_id, index, tag)
¶
Re-load until pending clears or TIMEOUT_TICKS pass; on a timeout the
CTA's first record goes to health (word 0 = sticky FAILED, words
8 + 8 bid .. = record) and later waits of this launch exit at once.
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
bf16_pair(a, b)
¶
Two f32 -> one i32 word holding (bf16(a) low, bf16(b) high), RNE.
bpermute(v, src_lane)
¶
Lane src_lane's i32 v (ds_bpermute: the LDS crossbar, no LDS memory).
e8m0_f32(code)
¶
fp4x8_bf16(word, scale_f32)
¶
One dword of 8 E2M1 (low nibble first) times scale_f32 -> bf16x8
(exact: v_cvt_scalef32_pk_bf16_fp4, the aiter Muse a16w4 decode).
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
fresh(v)
¶
An opaque v_mov: stops LLVM hoisting / CSE of lane math into long-lived registers (ATOM ops.fresh).
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
ld_vec_if(ok, ptr, i, words, nbytes, cm=0)
¶
words dwords at dword i, or zeros without a memory access when not ok
(out-of-range buffer offset; nbytes must bound the buffer).
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
mb_poll(tag, health, specs, region_id=0, batch=16, oks=None, cm=CM_DEV)
¶
[(base, pair index, npairs in {1, 2})] -> value words, all re-loaded
together until every tag matches (one round trip after the last lands).
oks (optional, one traced bool a spec): a false spec is not loaded (an
out-of-range buffer offset, no memory access), returns zeros, and is not
waited for.
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
mb_put(tag, base, i, v, cm=CM_DEV)
¶
Pair i := (v, tag), device scope (CM_SYS: system scope, a peer GPU's buffer).
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
mb_put2(tag, base, i, w0, w1)
¶
Pairs i, i+1 := (w0, tag), (w1, tag): one 16 B store (i even).
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
mb_put_if(ok, tag, base, i, v, cm=CM_DEV)
¶
Pair i := (v, tag) when ok (branch-free, see st_if).
Source code in vllm/models/muse_spark/amd/mono/kernels/dev.py
mfma_bf16(a, b, c)
¶
st_if(ok, v, base, i, cm=0)
¶
buffer_store of v (i32 or i32 vector) at dword i, dropped (out-of-range offset, no
branch) when not ok: keeps the waitcnt pass from draining at a join.