vllm.models.muse_spark.nvidia.specialized_decode.runtime.cute_ops
¶
The Muse Spark kernels the specialized decode and the DSpark draft call (the CuTe DSL kernels of cutedsl/attention/ and cutedsl/moe/routing.py), with the checks that decide where each one runs.
attn2 (cutedsl/attention/attn2.py)
Paged decode attention of the 8-token verify step (one request, 1 + 7 draft
tokens) fused with the attention output's weightless RMS norm and sigmoid
gate: the o_proj input of a decoder layer. Contract: head_dim 64, 8 query
heads per KV head, bf16 [pages, num_kv_heads, 16, 128] cache (K | V per
slot), 8 query rows per request, any context length L >= 8, and the
layer's sliding window if it has one. One launch covers the KV heads of
the rank. With max_model_len past 2048 (or a window) a split kernel
spreads a request's pages over attn2_splits z slices, merged through a
workspace. The launch shape depends on max_model_len only, not on the
step, so it is graph-capturable once prepare_attn2 has compiled it.
attn2 has no fallback of its own: the executor's plan() leaves every step
it does not cover (prefill, other query lengths) to the stock forward.
MuseRouting (cutedsl/moe/routing.py)
Muse Spark routing for decode batches of at most 8 tokens. It writes, bit
for bit, the expert ids and weights fused_musespark1x_routing writes
for Muse Spark's router: sigmoid scores, the correction bias for the
selection only, top-8 of 256 experts, weights
score * route_scale / (sum + 1e-15). The router's output multiplier
must already be folded into its weight, as fold_router_output_multiplier
does after loading. Optionally the same launch writes the TRT-LLM-gen
routing metadata of this rank's experts for one GEMM tile
(RoutingMetadata): the CTA map, the permutation and the padded size the
routed experts' GEMMs read, as the routed MoE op's own routing kernel
would write them for these ids.
qkv_front (cutedsl/attention/qkv_front.py)
For 1 to 16 tokens on the SM100 family the QKV front CuTe kernel replaces
the QKV + o-gate projection GEMM and
fused_muse_spark_qknorm_rope_kv_insert. A served call is checked once
(supports_call) and then launched (launch_qkv_front). Called
eagerly (Muse Spark runs uncompiled), so the data_ptr() checks are not
traced.
Classes:
-
MuseRouting–The routing of one Muse Spark MoE layer for 1 to 8 tokens, bound to its
-
RoutingMetadata–Where the routing writes the routing metadata of the local experts
Functions:
-
attn2_splits–The z slices of an attn2 launch (ROW_GROUPS clusters each per request
-
attn2_window–The window attn2 applies for a layer: 0 (none) when the layer has none
-
attn2_workspace_bytes–Bytes of the workspace the split kernel needs for
num_reqs -
sm100_family–Whether this is an SM100-family GPU, which each of the kernels needs
-
split_qkv–The q and gate column views of the attention front's output rows
-
supports_call–Whether the QKV front takes this call of a layer with
num_kv_heads -
unavailable–The reason a deployment whose GPUs cannot run
kernelis refused. -
unsupported_attn2–Why the kernel cannot compute this MuseSpark1xAttention layer, or None.
-
unsupported_projection–Why the QKV front cannot read this Muse Spark attention layer's loaded
-
unsupported_router–Why the kernel cannot reproduce
router's routing, or None if it
MuseRouting
¶
The routing of one Muse Spark MoE layer for 1 to 8 tokens, bound to its router's bias and route scale at build time, when the kernel compiles. A call allocates nothing, so it can be captured in a CUDA graph.
Methods:
-
__call__–Route fp32 router logits [b, 256] (1 <= b <= 8, 16-byte aligned
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
__call__(logits, ids, weights, metadata=None)
¶
Route fp32 router logits [b, 256] (1 <= b <= 8, 16-byte aligned
rows) into ids (int32 [b, 8], global expert ids) and weights
(fp32 [b, 8]), and with metadata the routing metadata of its local
experts; returns (ids, weights). Raises ValueError on arguments outside
routing.route's contract.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
RoutingMetadata
¶
Bases: NamedTuple
Where the routing writes the routing metadata of the local experts
[local_expert_offset, local_expert_offset + num_local_experts) for GEMM
tile tile_n: buffer, int32 of at least metadata_size(tile_n)
elements, not aliasing the ids or weights.
Methods:
-
fields–The fields of
num_tokenstokens, as 1-D int32 views of
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
fields(num_tokens)
¶
The fields of num_tokens tokens, as 1-D int32 views of
buffer at the extents the routed MoE op allocates for them (with
8 num_tokens <= 256 routes, at most one CTA per route):
total_num_padded_tokens [1], num_non_exiting_ctas [1],
expanded_idx_to_permuted_idx [8 num_tokens] (-1 for another rank's
expert), cta_idx_xy_to_batch_idx and cta_idx_xy_to_mn_limit
[8 num_tokens], and permuted_idx_to_token_idx [8 num_tokens tile_n + 1]
(-1 for a padding row; the last element is the guard the GEMMs may
read, never written).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
attn2_splits(max_model_len, window, num_kv_heads)
¶
The z slices of an attn2 launch (ROW_GROUPS clusters each per request and KV head) for a deployment: 1 for the one-cluster kernel and for a window (it spans at most window + 7 keys), else about SPLIT_TARGET_CLUSTERS clusters per request over the rank's KV heads.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
attn2_window(sliding_window, max_model_len)
¶
The window attn2 applies for a layer: 0 (none) when the layer has none or the window covers max_model_len (no key is then outside a row's window).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
attn2_workspace_bytes(num_reqs, num_kv_heads, num_splits)
¶
Bytes of the workspace the split kernel needs for num_reqs
requests: the counters (16-byte padded) and a partial per row and
cluster.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
sm100_family()
¶
Whether this is an SM100-family GPU, which each of the kernels needs (clusters of up to 16 CTAs, TMA, st.async, PDL).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
split_qkv(qkv, num_kv_heads)
¶
The q and gate column views of the attention front's output rows
[q | k | v | gate] (q and gate: 8 heads of 64 per KV head).
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
supports_call(x, weight, positions, cos_sin_cache, slot_mapping, kv_cache, num_kv_heads, out=None)
¶
Whether the QKV front takes this call of a layer with num_kv_heads
(with out, the full check before launch_qkv_front); otherwise the
caller keeps the unfused path.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
unavailable(kernel)
¶
The reason a deployment whose GPUs cannot run kernel is refused.
unsupported_attn2(layer)
¶
Why the kernel cannot compute this MuseSpark1xAttention layer, or None.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
unsupported_projection(attn)
¶
Why the QKV front cannot read this Muse Spark attention layer's loaded QKV projection and rotary table, or None.
Source code in vllm/models/muse_spark/nvidia/specialized_decode/runtime/cute_ops.py
unsupported_router(router)
¶
Why the kernel cannot reproduce router's routing, or None if it
can.