Skip to content

SenseNova Loop CUDA: MTP drafting with the checkpoint's own head (--drafter mtp) - #3867

Draft
Maxrio9 wants to merge 10 commits into
ashhart:mainfrom
Maxrio9:sensenova-loop-mtp
Draft

Maxrio9 wants to merge 10 commits into
ashhart:mainfrom
Maxrio9:sensenova-loop-mtp

Conversation

@Maxrio9

@Maxrio9 Maxrio9 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

With --drafter mtp, SenseNova-Loop-9B on CUDA drafts with its own MTP head. Greedy output equals plain decoding token for token on #3723's 11 prompts (alone, at 4 concurrent streams and on a resumed chat). Forced rejections at every draft depth leave the state clean. Decode goes from 25.9 to 59.2 tok/s at one stream on code and from 100.3 to 216.0 tok/s aggregate at 4 streams. Qwen3.6 MTP samples match main; decode results are below.

What this changes

serve <SenseNova-Loop-9B> --backend cuda --drafter mtp loads the checkpoint's mtp.safetensors and drafts with it. Before this, every drafter was refused for sensenova_loop.

Checks on this head

  • Head commit: 497cfed9d, tested as is. It is the previous c81b1f949 rebased onto the new qwen3_5 cuda: SenseNova-Loop-9B (sensenova_loop) in BF16, text only #3723 head; the only conflict was main's engine.tap_rows becoming e.tapRows() next to this PR's tapNorm, and setTaps folds the Loop tap check into the existing loop line so cuda_engine.zig stays at 600 lines.
  • Lean checker: 168 findings on the base and 168 on the tested tree, 0 new.
  • Tests:
    • zig build test-cuda-host: pass, except cuda.stager "every byte lands where the mapping would have put it" on my machine, which coincides with a Btrfs checksum error on its O_DIRECT temp file; it passes in CI and this PR does not touch the stager.
    • test-gradient-serving, test-qwen-serving-host and test-serve-drafter-host: pass.
    • test-qwen35-loop-host: pass.
    • The dense_serving_test.zig launch-sequence hash and the gradient-serving pins are unchanged and pass.
  • CUDA builds: zig build native -Dsm=120 -Dnative-fp-decode=true and compile-cuda-tests pass.
  • Device check: tf-cuda-test qwen-loop-mtp (needs TF_LOOP9B_DIR; TF_LOOP9B_MTP defaults to it) passes on SM120.
  • CI: green on 497cfed9d: all 9 jobs pass.
  • Not run: chips other than SM120; tensor parallel and pipeline stages (refused).

Receipt

  • Main against branch: Qwen3.6-35B-A3B MTP, main 11a0de0cf against this head, alternated main/head/main/head (table below). Loop-9B plain against --drafter mtp is on the same binary, because main cannot serve this model.

  • Boxes it reaches: CUDA qwen3_5 MTP drafting (dense Loop and MoE Qwen3.6), the Loop tap rule, server --drafter selection.

  • New switch: none. --drafter mtp is a new value of an existing flag, for sensenova_loop on CUDA only, and it is off unless given.

  • Environment:

    • TensorFold 497cfed9d, Zig 0.17.0, nvcc 13.4.
    • RTX PRO 4500 Blackwell (SM120, 32 GB), Linux.
    • sensenova/SenseNova-Loop-9B at 329a65f7, plus mtp.safetensors (sha256 3b84d5143ad5c97cbeffb4ffe9d2db9f620e3cbbfa334f987a04a3cb902d08a6), Apache-2.0.
    • TensorFold/Qwen3.6-35B-A3B-MLX-4bit-MTP at f84b054c.
  • Paths run: decode at 1 and 4 streams, greedy and sampled; prompt-cache resume; forced rejection at depths 0–2. Not run: other SMs.

  • Losslessness (Loop-9B):

    • Settings: --context 8192 --prompt-cache-gib 0, 256 tokens or to EOS, raw token IDs through /v1/completions.
    • The 11 prompts are 11/11 identical with --drafter mtp at --parallel 1, and 11/11 identical with the 11 sent 4 at a time at --parallel 4.
    • Plain at 4 streams also equals plain alone, 11/11.
  • Resume: a two-turn chat of 6907 then 6970 prompt tokens, served with --drafter mtp and the prompt cache on. Turn 2 resumes at 4096 cached tokens, and both turns equal plain decoding with --prompt-cache-gib 0.

  • Rollback (tf-cuda-test qwen-loop-mtp): a wrapper replaces draft k of every round with a token the target cannot pick and keeps drafts 0..k−1 as proposed. In every run, all 64 tokens equal plain, and a fresh stream afterwards equals its plain reference.

    forced wrong at accepted / proposed rounds
    k = 0 0 / 66 63
    k = 1 26 / 58 38
    k = 2 29 / 52 35
    none 35 / 84 29
  • Exactness (bench_concurrent.py --alone --serial, levels 1 and 4, greedy and sampled with fixed seeds): equal throughout with and without the drafter: alone 2/2 and 8/8 per prompt; serial against "draft": false 1/1 greedy and 4/4 sampled.

  • Acceptance (11 prompts, depth 3): 863 of 1603 drafts accepted (53.8%), 1.56 accepted drafts and 2.57 tokens per round; at 4 streams, 864 of 1613 accepted (53.6%) and 2.56 tokens per round.

  • Decode, Loop-9B (tok/s, bench_concurrent.py aggregate; separate bench_openai.py 1-stream medians are not identical):

    plain --drafter mtp
    code, 1 stream, greedy 25.9 59.2
    chat, 1 stream, greedy 25.9 43.9
    code, 4 streams, greedy 100.3 216.0
    chat, 4 streams, greedy 100.2 169.1
    code, 1 stream, sampled 25.9 47.6
    chat, 1 stream, sampled 25.9 42.3
    code, 4 streams, sampled 100.2 178.3
    chat, 4 streams, sampled 100.2 143.4
  • Memory and load: not rerun.

  • Qwen3.6-35B-A3B MTP, main against branch (--context 8192 --parallel 4 --prompt-cache-gib 0 --drafter <its folder>; bench_openai.py decode medians at 1 stream, bench_concurrent.py aggregates at 4):

    • Samples (greedy and seeded sampled) are byte-identical across all four runs.
    • --alone --serial is equal on every run.
    tok/s, code / chat main head main head Welch p, code / chat
    1 stream, greedy 410.6 / 307.9 409.1 / 307.8 410.5 / 308.0 410.5 / 308.1 0.912 / 0.307
    1 stream, sampled 353.8 / 281.5 353.8 / 281.4 353.8 / 281.4 353.8 / 281.3 0.998 / 0.894
    4 streams, greedy 1327.0 / 975.9 1328.1 / 977.2 1328.0 / 975.9 1327.5 / 976.8 0.668 / 0.114
    4 streams, sampled 777.1 / 667.6 777.8 / 665.8 778.3 / 664.6 777.6 / 665.8 1.000 / 0.874

    Welch tests compare main and head repetitions pooled across both runs: n=6 per side at 1 stream and n=2 per side at 4 streams.

  • Prompt speed: n/a. Prompt processing is unchanged; drafting starts after the prompt. Cold TTFT is in qwen3_5 cuda: SenseNova-Loop-9B (sensenova_loop) in BF16, text only #3723.

  • Licence: mtp.safetensors is part of sensenova/SenseNova-Loop-9B, Apache-2.0.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. The target's sums are unchanged; the draft's own norms keep FP32 1 + w except the q/k head norms (BF16 RNE pre-shift, draft-only).
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled. Prompt speed was not rerun.

…nsenova_loop

Physical layers keep one weight copy; each execution owns its delta-net or KV slot (42 + 14 for SenseNova-Loop-9B).
Plain Qwen checkpoints get the identity schedule. Drafting, learning, pockets and stages are refused for loop models.

Refs ashhart#3717
… leave) with host reference and contract cases

Refs ashhart#3717
Route, plain norm, mixer, merge around both halves of layers 4..27; streams enter at each pass's first layer and leave at
its last. FP32 dt_bias rounds to BF16 at load, as the reference holds it. Execution counts are cached in the geometry.

Refs ashhart#3717
…the reviewed launch sequence

qwen35_learn and the qwen35 GPU test mains pass null loops. kernels.zig registers the qwen35_mhc image.
The launch sequence's three norm add flags come from the schedule's decision, main's values on the plain schedule.
Other backends decide their own drafting for this model type.
…iterations and pre_scale

Accept loop_settings.use_gate absent or false, ignore unknown loop_settings keys, and no longer require layer_types.
Streams 4 parses but is refused at admission, as are fixed_identity and more than 1000 iterations. The route kernel
takes the Sinkhorn iteration count and pre_scale (defaults 20 and 1.0, the default path unchanged). A shared case
table, zig/tests/fixtures/sensenova_loop_config.json, runs through the CUDA reader and admission.
…al does

The route kernel takes pre_scale as an f32. A positive f64 such as 1e-50
passed the reader and the finite check, then ran as 0. Admission now
refuses it with UnsupportedSenseNovaMhc, matching ashhart#3859's reader. Two
fixture cases: 1e-30 (a normal f32) accepts, 1e-50 is refused at admission.
--drafter mtp serves SenseNova-Loop-9B's own mtp.safetensors (or an mtp/ directory) through the
Qwen MTP drafter: a dense BF16 layer packed in the target's lane format, fed the last layer's
final-normed hidden (the draft's main_norm when it ships one). The Loop engine taps only layers its
schedule runs once; verification and rollback use the per-execution delta-net and KV slots.
DFlash2 and DSpine drafts stay refused for this model type.
@AIFlowML

Copy link
Copy Markdown
Contributor

On exact head 497cfed9d, I ran zig build test-qwen35-loop-host -Dcpu=apple_m1 -j4 --summary all with Zig 0.17.0 on the Mac. It passed 213 tests with 2 skips. This covers the Loop configuration and execution-slot host tests. The CUDA rollback check still uses the pinned SenseNova-Loop-9B revision and matching MTP side file listed in the receipt.

I also checked the stated #3723 dependency against main 210e3b0c5. The trial merges of parent c1ec09679 and this head both conflict in contract_controls_set.cu, cuda_refusal.zig and gradient-serving.tsv. The parent rebase is the first step. After replaying this commit, please recheck the SenseNova block in cuda_refusal.zig, where this patch permits MTP, and rerun TF_LOOP9B_DIR=<checkpoint-dir> tf-cuda-test qwen-loop-mtp on SM 120. The expected rollback result is all 64 tokens matching plain at each forced rejection depth 0, 1 and 2, followed by a fresh stream matching its plain reference. I did the host checks only.

Igor Lessio - AIFLOW LABS

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SenseNova-Loop-9B (sensenova_loop) MTP speculative decoding on CUDA

2 participants