Skip to content

EXL3 Flash Next: expert-parallel TP=2 (same tokens as TP=1) and MTP drafts (2/8) - #1442

Open
BlivionIaG wants to merge 49 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s2-tp2-drafts
Open

BlivionIaG wants to merge 49 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s2-tp2-drafts

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Expert-parallel TP2 for EXL3 Flash Next and MTP drafts. TP partials use canonical FP64 gather and one rounding step.

Current-head checks

Two RTX 5060 Ti 16 GiB GPUs, CUDA 13.4.92, Zig 0.17.0; turboderp/Qwen3.8-Flash-Next-exl3 revision 69e33439ae950f17bcbe95c98f117d80f759ab6d.

  • Token gate: pass. TP1/TP2, drafts on/off, code/chat, greedy/seeded, one/four streams, three repetitions: full token hashes matched across all eight cells and all 240 measured responses completed. Receipt.
  • Performance gate: open. TP1 four-stream chat with default drafts was 0.883× plain greedy and 0.891× plain sampled on the alternating fresh-server check; code gains do not offset the chat loss. Receipt.
  • Sampled-head batching off did not resolve the loss: sampled chat was 0.879× plain. Diagnostic.
  • Draft depth 3 improved greedy chat to 1.077× plain, but sampled chat remained 0.916×. This diagnostic retained drafts and exact output hashes; it is not a production fix or a final performance/restore gate. Diagnostic.
  • Sampled depth 1 plus greedy depth 3 yielded 1.077× greedy and 0.953× sampled chat; all four diagnostic cells cleared 0.95 with identical hashes. The sampled margin is narrow and still below plain; this is not a robust no-regression result. Diagnostic.
  • tools/pr_check.py --base upstream/main --pr 1442 reported 0 errors and 0 warnings on this head at the time of the check. Its earlier Linux CI run passed eight checks with two nightly skips; current CI and integration remain with the maintainer.

Earlier evidence and open work

  • Earlier-head TP1/TP2 drafted/plain and resume comparisons passed; the filtered EXL3 Flash Next kernel contract passed 63/63 kernels and rejected 22/22 planted controls. Those resume and kernel checks have not been repeated on the current head.
  • Model fidelity on an older head: 70/72 top-token matches against an independent reference. The ids16 and ids17 differences remain open; no tie waiver or perfect-equivalence claim.
  • Final no-regression performance and restore evidence are required after a substantive fix. Main refuses this checkpoint and is not a runnable performance baseline; NVFP4 validation needs the maintainer's hardware.
  • ATC 0.9.6 returned an incomplete [Draft] EXL3 Flash Next on CUDA: TP=2, BF16 paging, cache reuse, graphs #1113 snapshot due to its pull-request limit. The earlier overlap check covered four known peers, not global clearance; maintainer is handling routine coordination.

The changed CUDA kernel was covered by the earlier filtered contract. No checkpoint weights are distributed; the checkpoint uses Qwen Community License 1.0.

@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s2-tp2-drafts branch 3 times, most recently from 0b6880d to 519c235 Compare October 27, 2026 10:51
@ashhart

ashhart commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thanks for this. Three things block it, two of which came up on #1113:

  1. TP=2 has to give the same tokens as TP=1. An FP64 receipt won't settle it. Each rank now sums its own experts
    before the fp32 all-reduce (exl3/tp/cuda_exl3_tp.zig:263-291), which regroups the sum, and you report different
    text on two of three prompts. One way through is to exchange the per-slot fp32 expert outputs, sum them in pick
    order on each rank, and show equal hashes at TP=1 and TP=2. Could you also say what regroups in the head? As far as
    I can see, the logits are gathered whole before the argmax.
  2. Please remove TF_FLASHNEXT_ATTN_SPLIT (exl3/model/cuda_exl3_heads.zig:26-32,181). It's an opt-in mode that
    changes tokens.
  3. Offloaded engines shouldn't serve plain by default. plainByDefault() (exl3/model/cuda_exl3_pass.zig:114-118)
    turns drafts off unless TF_FLASHNEXT_DRAFT_ENABLE=1.

This PR also changes NVFP4 Flash Next. Please take those changes out, or give them their own PR with NVFP4 receipts:

  • tp_draft_snapshots = true (cuda_lanes.zig:32) and --tp in the CUDA serves list (native/cuda.zig:35) admit
    NVFP4 TP=2 with drafts and the prompt cache. docs/multi-rank-receipts.md still says the CUDA build serves neither
    flag, and the refusal test (native/cuda_flashnext_refusal_test.zig:23) no longer checks Flash Next.
  • TF_FLASHNEXT_DRAFTS and _CONFIDENCE are renamed (cuda_lanes_load.zig:75-76), so existing settings are ignored
    without a warning.
  • Every NCCL wait now spins for 3 ms (cuda_collective.zig:14,85).

Two smaller points:

  • The draft vocabulary is decoded to bf16 at load (exl3/tp/cuda_exl3_mtp.zig:164-180). That only affects proposals,
    but please say so in the description.
  • fn_exl3_tp_mask and fn_exl3_tp_place need runner entries.

@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s2-tp2-drafts branch 4 times, most recently from ae96d79 to 0d58795 Compare October 27, 2026 17:56
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s2-tp2-drafts branch from 0d58795 to e8b66c3 Compare October 27, 2026 19:21
@BlivionIaG BlivionIaG changed the title EXL3 Flash Next: expert-parallel TP=2 and MTP drafts (2/7) EXL3 Flash Next: expert-parallel TP=2 (same tokens as TP=1) and MTP drafts (2/8) Oct 27, 2026
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s2-tp2-drafts branch from e8b66c3 to b36b385 Compare October 28, 2026 08:08
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s2-tp2-drafts branch 4 times, most recently from f53ed60 to 66aca3f Compare October 29, 2026 07:33
@BlivionIaG BlivionIaG mentioned this pull request Oct 29, 2026
5 of 8 tasks
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s2-tp2-drafts branch 9 times, most recently from 28c7075 to e8bc4a0 Compare November 2, 2026 17:08
@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Thanks for the review. On the head (e8bc4a049):

  1. TP=2 equals TP=1 by construction rather than by a per-slot exchange: one fixed reduction order at every degree. 64 leaves of 8 expert ids (the shared expert in leaf 63), an fma chain per leaf in pick order, then a fixed balanced fp32 tree. Each rank computes its own subtree, one fixed-size fp32 all-gather follows, and both ranks finish the tree; TP=1 runs the same tree (cuda_exl3_tp.zig, exl3_canon.zig). The old per-rank sum is gone. This changes TP=1 bits against the single 11-slot chain of the previous version, which the body asks you to accept.
  2. Nothing regroups in the head: the lm_head is split by vocabulary column (128-column blocks, each column reduced over the full K), the bf16 logits are gathered whole and the argmax runs on the whole row. A device test checks the joined halves equal the whole head bit for bit at 1 and 5 rows.
  3. TF_FLASHNEXT_ATTN_SPLIT, plainByDefault and TF_FLASHNEXT_DRAFT_ENABLE are gone; drafts are on by default for offloaded engines.
  4. NVFP4: tp_draft_snapshots stays false, --tp is refused for every non-EXL3 pack (packRanks), the 3 ms collective spin is EXL3-only, and the TF_FLASHNEXT_DRAFTS / _CONFIDENCE names are unchanged. fn_exl3_tp_place no longer exists; fn_exl3_tp_mask has a runner test. The draft vocabulary is decoded to bf16 at load and only affects proposals.

Open on our side: runner tests for fn_exl3_leaf_tree and fn_exl3_leaf_finish (the canonical reduction kernels) and removal of a stale per-slot test, in the next push; a few shared-rank changes (rank frame telemetry phase, prompt_last, snapshot warnings) that we are checking are EXL3-only; and a published TP=1 vs TP=2 hash table on this exact head, which is not posted yet.

@AIFlowML

Copy link
Copy Markdown
Contributor

I checked the TP and MTP layer at a7642cc7 in a scratch merge with 37fa51d23. The five overlap paths resolve by keeping main's explicit-rank refusal, the EXL3 test dispatch entries beside main's readout dispatch, and the affected serving pins from the resolved tree. The environment test initially failed with two TF_FLASHNEXT_SHARD_HEAD entries. Keeping main's single Flash Next entry restored the expected refusal text.

zig build test-environment-host test-flashnext-exl3-host test-gradient-serving check-native-cuda-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j3 --summary all
zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dcpu=baseline -Doptimize=ReleaseSafe -j2 --summary all

Both exited 0 on M5 Max with Zig 0.17.0. All 136 tests passed, and both Linux ARM64 CUDA executables compiled. The TP=2 device and final train runs remain open.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. Four runtime/offload fixes are needed. Disk-resumed Flash Next states always allocate in VRAM, bypassing the configured host snapshot placement. With routed host offload plus TF_FLASHNEXT_EXL3_MTP_RESIDENT=1, admission accounting also misses the routed head trellises that the loader keeps on device. Changing MTP residency then discards all saved decoder placement counts instead of only cold-starting MTP. Finally, the pool's two u32 round counters use trapping increments and panic at the 2^32 boundary; please give them the intended wrapping behavior and a boundary regression.

Both serving qualification scripts also exit successfully after wrong output. Include both golden comparisons in the serving gate's status, and make that gate and the long-context needle gate exit nonzero whenever their required checks fail. Please add focused host regressions for these cases. Device A/B remains after the fixes.

  • Synthena

@ashhart

ashhart commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Synthena Initial Review — Needs changes (kind:feature)

Diff exceeds GitHub's 20,000-line diff API limit (+22922/-504 across 100 files); escalated for manual maintainer review or splitting.

  • Branch currently has merge conflicts against base.
  • Failing CI check(s): zig, zig-b, zig-windows.
  • Synthena

…pping

- `now` and `round_no` are u32 stamps that order lines and swaps; a long-running server wrapped them into an overflow trap
- test: from maxInt they step to 0 then 1 (trapped with integer overflow before)
…P_HOST puts kept states

- the disk view allocates through snap.blank, which honors the host placement instead of always taking device memory
- test: with TF_FLASHNEXT_SNAP_HOST=1 a read-back state sits on the host (it sat on the device before)
…loader keeps

- headOptions reads TF_FLASHNEXT_EXL3_MTP_RESIDENT once; headBytes and the loader's mtp. roots both use it
- test: a synthetic pack with the switch set counts the head's routed bytes (they were missing before)
… history

- a profile written with or without MTP counts keeps the decoder counts; only MTP starts cold, and the fingerprint marks the head
- test: prepare/finish across a residency change keep decoder counts (they were discarded before)
- the serve gate's status includes the golden check and exits 1 on failure; the long-context client exits 1 on a missed needle
- tests/test_exl3_gates.py fails on the old scripts (2 failures) and passes now
- drop the duplicate TENSORFOLD_MEMORY_RESERVE_GIB and cuda-scoped TF_FLASHNEXT_SHARD_HEAD rules; main's single entries stay
- the legacy fixture for an untrimmed reserve follows main: it is refused, and the EXL3 consumer applies its own floor
@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Pushed 1129f8c720 (fast-forward from a7642cc734). One commit per item:

  • Pool round counters (24ef124c31): now and round_no now advance through nextRound with wrapping adds. New test "exl3: the pool's round stamp and number wrap at 2^32 instead of trapping"; on the old code it panics with integer overflow. The same two lines are on EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) #1441 at 6b9aa04b17. I left EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) #1441 untouched, so this commit can be taken there at landing.
  • Disk-resumed state placement (2fe6e1a4af): cuda_disk View.blank now allocates through the new snap.blank, which honours TF_FLASHNEXT_SNAP_HOST the same way kept states do. New test "exl3: a state read back from disk sits where TF_FLASHNEXT_SNAP_HOST places kept states" (fake driver). On the old code: expected true, found false.
  • MTP resident admission (c7eff72d31): memory.headOptions reads TF_FLASHNEXT_EXL3_MTP_RESIDENT. headBytes (world 1, rank 0 of world 2, weightBytes) and the loader's mtp. roots now use that same reading. New test on a synthetic index plus safetensors. On the old code: expected 407528484, found 407524388.
  • Placement history across MTP residency (158a9132d8): a residency change no longer throws away the decoder's counts. Only MTP starts cold, and that is logged. The fingerprint marks that the head is present instead of hashing the head's routed bytes. New test "exl3: an MTP residency change keeps the decoder's placement counts and starts MTP alone cold"; on the old code it fails with error.DecoderCountsDiscarded. The two existing tests are adjusted.
  • Gate exit codes (d24ec1698c): exl3_serve_gate.py now puts golden_ok into the status and exits 1 when it fails. exl3_longctx_client.py exits 1 on a missed needle or a continuation error. tools/tests/test_exl3_gates.py gives FAILED (failures=2) on the old scripts and OK now.
  • Environment table (9d5819f4af): test-environment-host failed on a7642cc734 (2 tests). The cause was duplicate TENSORFOLD_MEMORY_RESERVE_GIB and cuda-scoped TF_FLASHNEXT_SHARD_HEAD rows. I kept main's single rows, and the untrimmed-reserve fixture is now refused as on main. This is the same resolution @AIFlowML described on EXL3 Flash Next: KV pages from the core pool (4/8) #1444.
  • Contract set release (1129f8c720): added errdefer flashnext_exl3.deinit() in zig/tests/cuda/contract_family_sets.zig. This was raised on EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522, but the line first appears in EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) #1441 and here. It is only compile-checked.

Commands run on macOS arm64 with Zig 0.17.0:

  • zig build test-flashnext-exl3-host test-environment-host test-cuda-host: 439/439 steps, 7824 passed, 49 skipped
  • zig build check-native-cuda-host -Dtarget=aarch64-linux-gnu -Dcpu=baseline: 8/8 steps
  • zig build compile-cuda-tests -Dtarget=aarch64-linux-gnu -Dcpu=baseline: 10/10 steps
  • python3 -m unittest tools/tests/test_exl3_gates.py: OK
  • python3 tools/pr_check.py --base upstream/main --pr 1442: 0 errors, lean 168 vs 168. One warning: no Unreleased bullet.

Not done: there is no CUDA device here, so no device qualification was run for any of this. I did not add a CHANGELOG bullet.

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

kind:feature Classified by Synthena as feature addition synthena:needs-changes Reviewed by Synthena; changes requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants