Repository navigation
[None][feat] Muse Spark Open modeling_v2 TEP target: Vera Rubin decode megakernel, 2..4-request TEP4 decode paths and sm107 context-step paths - #21646
Closed
xwang233 wants to merge 15 commits into
Conversation
… each MNNVL all-reduce workspace before the first capture MUSESPARK_OPEN_PREFILL_SP_MIN_TOKENS (default 4096, floor 1024) sets the smallest step the built-in prefill sequence parallelism shards. With the split on, every MNNVL all-reduce workspace the layers use is sized for a full replicated step at the first forward that is not captured, keyed by the reducer's own mapping and dtype, so no CUDA graph keeps the address of a workspace a later replicated message would grow. Both exist only under MUSESPARK_OPEN_PREFILL_SEQUENCE_PARALLEL=1. With it unset the constructor reads no new variable and sets no reservation; the forward runs as before. Signed-off-by: Xiao Wang <[email protected]>
RuntimeHooks gains overlap_offsets_applier (None by default). When a model declares one, the decoder runner may issue the overlap scheduler's position-id and KV-length corrections of a generation-only speculative step as one launch. Without it, or when it declines the step, the two original adds run unchanged. Signed-off-by: Xiao Wang <[email protected]>
…e its CUDA context With TLLM_WORKER_AFFINITY_BEFORE_CUDA_CONTEXT=1, BaseWorker applies the CPU affinity of its GPU before torch.cuda.set_device creates the CUDA context. The context is then created from a CPU of the GPU's NUMA node, so the driver's host-side memory for it, such as the words the GPU writes and polls for event completion, is on the GPU's own socket. Unset (the default), the affinity is applied after the context is created, as before. Signed-off-by: Xiao Wang <[email protected]>
…CUDA sources Package data for the CUDA sources that the musespark_open TEP target compiles at run time: the .cu files of its kernel packages dr_draft_tail, drafter_attn_pdl/_qk_norm_rope_pdl, pf_pre, pv_logits, s2_sampler and megakernel, and the megakernel's stages/*.cuh headers. The packages are added by the following commits. The codespell ignore list gains the kernels' identifiers. Signed-off-by: Xiao Wang <[email protected]>
…ed context FMHA for mixed steps A CuTe DSL paged context FMHA for sm107 that runs several attention instances per CTA over a planned list of work units, and the installer that serves the context rows of mixed steps with it. - ops/attention/context_fmha_fmk_kernel.py: the kernel. Double-buffered S, diagonal causal mask, Q prefetch, direct O stores and an optional diagnostic timestamp build. - ops/attention/context_fmha_fmk.py: the host planner. It splits each context request into units and merges short ones, from fitted per-unit costs, and builds the plan tensors. - kernels/fmk_context_fmha: the installer over the mixed-step context library. It reserves its workspace and warms up outside meta init, checks for a stream capture before reading the call's parameters, and refuses head splits other than the planned one. The path is installed by the fmk_context_fmha lever (a later commit). Signed-off-by: Xiao Wang <[email protected]>
… for aggregated TEP4 servers Paths for context and mixed steps, each installed by its own lever (a later commit): - ops/attention/preattn_prep.py: a vectorized context prep rows kernel with one 16-byte load and store per norm lane and the reference summation order. - kernels/replicated_embedding: the replicated table also serves context-step ids up to a per-architecture row limit. - kernels/context_sequence_parallel: on sm107 the sequence-parallel context step also joins the router input. - ops/attention/multi_request_split_kv.py: a deeper page ring for the E4M3-query split-KV build; the ring depth is part of the compiled-kernel key. - kernels/drafter_window_compact: in-place compaction of the windowed drafter arena on mixed steps. - kernels/context_fp8_dense: refined MXFP8 tactic buckets for the lossy context FP8 projections. Signed-off-by: Xiao Wang <[email protected]>
…gregated TEP4 servers Decode-step paths, each installed by its own lever (a later commit): - ops/allreduce/post_attn_hop_wide.py: a row-gated split of the wide post-attention hop into fewer CTAs per rank on given row ranges. - spec_worker.py: a wider drafter fc inbox gather (more rows and programs). - ops/moe/decode_expert_tactics.py, kernels/replicated_experts: a tile-32 pin of the layer 0 and 61 decode expert calls. - ops/moe/router_gemm_staged.py, ops/moe/router_gemm.py, kernels/router_gemm: a BF16x3 router GEMM whose epilogue stages the partial tile in bulk. - kernels/context_kv_fork: a late join of the context-K/V side chain, deferred until its first reader (the readers follow with the drafter commit). With no join pending the readers keep their previous launch order. Signed-off-by: Xiao Wang <[email protected]>
… published decode steps (lossy) On a decode step that projection_publish serves, the QKV projection runs on the MXFP8 copy of the weight that context_fp8_dense keeps, with the activation quantized per 1x32 block. This lowers precision, so the decode_qkv_mxfp8 lever (a later commit) is never on under auto and needs its knob, MUSESPARK_OPEN_LEVER_DECODE_QKV_MXFP8=on. - kernels/decode_qkv_mxfp8: the installer. - ops/comm/projection_publish.py, kernels/projection_publish, kernels/batch_dense_gemms: the hooks it uses. - weights.py: install after the context FP8 copies. Signed-off-by: Xiao Wang <[email protected]>
…paths for the 2..4-request decode steps of sm107 TEP4 Bitwise paths for decode steps of two to four requests, each installed by its own lever (a later commit): - kernels/swa_block, ops/attention/swa_block.py: the sliding-window split grid gives each program as many 32-key blocks as the step has sequences; one partial per block and the combine are unchanged. - kernels/full_attention_prep_fold, ops/attention/full_attention_prep_fold.py, ops/attention/full_attention_split_kv*.py: the prep fold also takes the steps the wide full-attention path folds, in a multi-sequence build of the fold kernel on the multi-sequence split-KV partition. - kernels/next_qkv_prefetch, kernels/boundary_early_release: on the wide QKV rows whose kernel stages its weight before its wait, the next QKV weight's L2 prefetch is forked after the experts and the unpooler's prefetch of it is dropped. - kernels/capture_fold: a capture layer armed on the wide direct transport stores the DFlash capture from its boundary. Signed-off-by: Xiao Wang <[email protected]>
…el parameter block and a fused overlap-offsets applier The target's runtime hooks gain two parts of the single-request step loop. Each writes the same words as the launches it replaces: - a step commit whose descriptors fit a kernel parameter block carries its table there (ops/runtime/step_commit_inline.py) instead of reading it from pinned host memory; - in captured decode graphs the overlap scheduler's two offset adds run as one launch that releases its programmatic dependent at entry (ops/runtime/overlap_offsets.py, the overlap_offsets_applier hook). Both are installed by the step_loop_inline_commits lever (a later commit). Signed-off-by: Xiao Wang <[email protected]>
…front and last-layer boundary of the single-request decode The decoder's edges around the middle layers, each installed by its own lever (a later commit): - layer0_qkv_table: on a decode step the pre-layer chain is one launch (kernels/pf_pre): the replicated token-embedding gather, the embedding RMSNorm, the exact FP32 widening of its BF16 output as the residual stream, and layer 0's pre-QKV norm. Layer 0's QKV(G) projection depends only on the token id, so it is served from a per-token table built at load (kernels/tt_table/target_l0.py) and returned by layer 0's dense GEMM dispatcher in place of the GEMM. - edge_bf16_moe_front: the two layers the checkpoint leaves with BF16 experts (0 and 61) take the routed decode front of the NVFP4 layers; the MoE prologue runs their router shard and pool on one chain, and the pool and router logits are published into the routed pool kernel's transport (kernels/pool_into_route). - last_layer_boundary: the last layer's unpool gather, post-FFN gated residual and the model's final norm run as one launch (ops/comm/unpool_final_boundary.py), reproducing the bits of the built-in join and RMSNorm it replaces; the glue to the LM head writes the head's BF16 input directly (kernels/pv_glue). The routed pool kernels gain a BF16 norm variant for the BF16 expert layers. When the armed join cannot run, projection_gathers falls back to the built-in chain and logs the reason once. - kernels/ox_entry: the layer-0 input RMSNorm releases its dependent at entry. Signed-off-by: Xiao Wang <[email protected]>
distributed_head_sampler (installed by its lever, a later commit): the target head's verify sampler runs on an interleaved vocabulary shard on every rank and the ranks exchange sampler states instead of logits (kernels/s2_sampler). Logits are gathered in one shot straight into the final row layout (kernels/pv_logits), and calls neither takes are gathered with one MULTIMEM all-gather (split_sampler.target_head). The head sampler's first kernel runs a cooperative fold whose states are the plain fold's bit for bit, its second kernel releases its dependent right after its wait, and the verify fold launches as that programmatic dependent. Signed-off-by: Xiao Wang <[email protected]>
…eamble late join and draft-head tail Drafter paths of the single-request decode, each installed by its own lever (a later commit), computing the same values as the launches they replace unless noted: - drafter_folds: elementwise kernels folded into the epilogue of the split-K GEMV before them (kernels/dr3_folds, ops/gemm/dr3_fold_splitk_gemm.py); the drafter's QK norm + RoPE and window attention as programmatic dependents (kernels/drafter_attn_pdl, ops/spec/dr3_qk_norm_rope.py); the drafter's layer-0 front served from a per-token table built at load (kernels/tt_table/drafter_l0.py). - draft_head_tail: the draft head's tail after the vocab-sharded LM-head GEMV as a short chain of CUDA launches (kernels/dr_draft_tail). It does not apply a drafter logit transform, so it is excluded when the drafter declares one. - drafter_preamble_late_join: the verify fold stages the drafter's layer-0 input, and the main stream's join of the context-K/V side chain moves into the drafter forward, right before layer 0's QK norm and RoPE (drafter.py, kernels/drafter_block_decode, kernels/verify_fold, ops/spec/dflash_*). The drafter's window attention can apply the QK norm and RoPE itself and issues its loads before the dependency wait. With no join pending, the readers of the side chain keep their previous launch order. Signed-off-by: Xiao Wang <[email protected]>
…ernel on sm107 TEP8 The megakernel lever runs target layers 1 to 60 (every NVFP4 routed layer of the 62-layer model) of a decode forward as whole-layer launches: one persistent launch per sliding-window layer and one per full-attention layer. Only the forward it is built for takes it: sm107, TP8 with EP8 over two nodes of four, one sequence with its drafts, no context rows. Every other forward, and a step whose metadata is first seen inside a capture, runs the stock layers. kernels/megakernel holds the CUDA kernel (msoMegakernel.cu and stages/*.cuh, compiled at install), its per-CTA unit schedules, the layer plans, and the serving code: install compiles the library, builds the workspaces and packs each replaced layer's GEMV weights once; begin binds a forward's parameter blocks; run launches every replaced layer and returns what the stock layer 60 would. The served build is not bitwise the stock layers: the MoE boundaries and the router inputs use FP32 composites instead of BF16-rounded intermediates (no stored value loses precision), so near-tied top-8 expert choices can differ. These are the gated numerics levers megakernel_one_exchange_boundaries, megakernel_two_term_pool and megakernel_router_by_linearity, which the megakernel requires (a later commit). The install refuses, with the reason logged, on another device or mapping, or without pinned host memory for the kernel's watchdog record. Signed-off-by: Xiao Wang <[email protected]>
…d sm107 TEP4, 2..4-request and single-request TEP8 paths Registers the paths of the previous commits as levers in the resolver (levers.RULES, dispatch.FAST_PATHS) and composes them in modeling.py, layers.py and the decode target. MUSESPARK_OPEN_LEVER_<NAME> (auto|on|off) is the only switch; the paths' former environment switches are retired and raise at start-up, naming the lever knob. Under MUSESPARK_OPEN_LEVER__DEFAULT=baseline every new lever is off. Aggregated sm107 TEP4 servers of max_batch_size 4 or more, on under auto: - bitwise: context_kv_late_join, hop_cluster_split (CLUSTER, ROWS), router_staged_epilogue, step_window_compact (windowed arena only), split_kv_deep_ring, context_prep_rows_vec, context_embedding_replicated, context_sp_router_input; drafter_fc_inbox_wide (MAX_ROWS, PROGRAMS) also needs a decode step of more than 128 rows; - lossless-numeric, with an accuracy gate on the same servers: fmk_context_fmha, l061_tile32_pin; - lossy, on only by its knob: decode_qkv_mxfp8, excluded when context_fp8_dense__PROJECTIONS leaves out qkv. sm107 TEP4 decode steps of two to four requests (bitwise): on for generation servers of max_batch_size 2..4 and aggregated servers of max_batch_size 2..8, off on TEP8, at max_batch_size 1, on context servers, for an unknown role and on the high-concurrency selection: swa_blocks_per_program, wide_full_attention_fold, wide_qkv_prefetch, wide_capture_fold. Aggregated sm107 TEP8 servers of max_batch_size 1 over a dense drafter arena (dispatch.SM107_TEP8_ONLY), on under auto there and off everywhere else: megakernel with its numerics levers megakernel_one_exchange_boundaries, megakernel_two_term_pool and megakernel_router_by_linearity (gated, switchable; opting out of one runs the stock layers); megakernel_zero_exchange_boundary, declared and structurally excluded; layer0_qkv_table, edge_bf16_moe_front, last_layer_boundary, context_kv_fork_last_layer, distributed_head_sampler, drafter_preamble_late_join, drafter_folds, draft_head_tail (excluded when the drafter declares a logit transform) and step_loop_inline_commits. Param gains a ranges mode for comma-separated lo-hi row ranges. The sm103 compositions serve the same paths as before. The host tests pin the region tables, the new parameters, gates and retired names. Signed-off-by: Xiao Wang <[email protected]>
xwang233
requested review from
a team,
Wanli-Jiang,
WeiHaocheng and
litaotju
as code owners
November 4, 2026 18:16
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR follows #21377. It adds the next round of Vera Rubin (sm107) fast paths to the Muse Spark Open modeling_v2 TEP target and registers each one as a lever in the per-deployment resolver. The changes are 15 commits:
_experimental/modeling_v2/models/musespark_open/...__tep): eight groups of paths (context steps, decode steps, 2..4-request decode steps, the lossy MXFP8 QKV opt-in, and four parts of the single-request decode), the whole-layer decode megakernel, the step-commit hooks, and the lever registration;setup.pychange that ships the target's new JIT CUDA sources.Aggregated TEP4 servers (sm107),
max_batch_size≥ 4, on underauto.fmk_context_fmha);decode_qkv_mxfp8runs the decode QKV projection on the context FP8 copy of the weight. It is never on underauto; it needsMUSESPARK_OPEN_LEVER_DECODE_QKV_MXFP8=on.TEP4 decode steps of 2–4 requests (bitwise).
max_batch_size2–4 and aggregated servers of 2–8. Off on TEP8, atmax_batch_size1, on context servers and on the high-concurrency selection.Single-request TEP8 (aggregated,
max_batch_size1, dense drafter arena).kernels/megakernel) runs target layers 1–60 as whole-layer persistent launches, one per layer.megakernel_one_exchange_boundaries,megakernel_two_term_poolandmegakernel_router_by_linearity. Opting out of any of them runs the stock layers.head_multimem_gatherstays off underautohere; the single-request recipe turns it on with its knob.MUSESPARK_OPEN_LEVER_<NAME>=auto|on|offis the only switch. The paths' former environment switches are retired and raise at start-up, naming the lever knob. UnderMUSESPARK_OPEN_LEVER__DEFAULT=baselineevery new lever is off. The sm103 (GB300) compositions serve the same paths as before.Shared paths: opt-in, off by default. With the variables unset, behaviour is unchanged.
MUSESPARK_OPEN_PREFILL_SP_MIN_TOKENSsets the smallest step the built-in prefill sequence parallelism shards. With the split on, each MNNVL all-reduce workspace is reserved before the first capture. Both exist only underMUSESPARK_OPEN_PREFILL_SEQUENCE_PARALLEL=1.RuntimeHooks.overlap_offsets_applier(None by default): a model can run the overlap scheduler's position-id and KV-length corrections of a generation-only speculative step as one launch.TLLM_WORKER_AFFINITY_BEFORE_CUDA_CONTEXT=1applies the GPU's CPU affinity beforetorch.cuda.set_devicecreates the CUDA context, so the driver's host-side memory for it is on the GPU's socket.Measured gains.
max_batch_size4max_batch_size4max_batch_size6max_batch_size8max_batch_size8max_batch_size4 still has TTFT p90 above the 10-second bound, 22 % lower than before.Accuracy.
max_batch_size4 and 32, two pairs each against the same recipe without it: passes, p ≥ 0.052, acceptance-length ratio within ±1 %.MUSESPARK_OPEN_LEVER__DEFAULT=baseline, one pair: McNemar passes on every probe (GSM8K +0.15 pp, p 0.77; reuse −0.08 pp, p 1.0; GPQA −2.5 pp, p 0.062).Validation.
feat/musespark-open-agentx(b5ca973040, [None][feat] Muse Spark Open modeling_v2 TEP target: a per-deployment lever resolver and the Vera Rubin high-concurrency, mid-concurrency and low-latency fast paths #21377).__sm_103__teptarget, whose routing serves both sm103 and sm107. Splitting them into their own target is left for a follow-up.Test Coverage
tests/unittest/_torch/modeling_v2/models/musespark_open/.../test_modeling_v2_levers.py: the region tables, the new parameters (including the row-range mode), gates, structural exclusions and retired switch names.accuracy/modeling_v2/test_musespark_open.py(on this branch): GSM8K and mean acceptance length undermodeling_v2="require".PR Checklist
🤖 Generated with Claude Code