Skip to content

EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) - #1441

Open
BlivionIaG wants to merge 25 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s1-one-rank
Open

BlivionIaG wants to merge 25 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s1-one-rank

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Current head: ffe81a4bfb, merged with main baed910096 and moving the EXL3 release notes back to Unreleased. On earlier head d4da1bacab, test-environment-host, test-gradient-serving and test-flashnext-exl3-host exited 0 on Darwin arm64. Device measurements below were not repeated on this head. An earlier Linux Zig CI job was canceled during zig build test-host after about an hour, matching its then-60-minute job limit; it was not a passing result.

Current-head tools/pr_check.py --base upstream/main --pr 1441: 0 errors, 0 warnings, 0 new lean findings.

What this changes

EXL3 single-rank Flash Next loading, offloaded experts and the sm_120 kernel contracts. Expert leaves are float64 with fixed-tree merges, rounded once to float32 at the root.

Checks before the release merge

  • Head d954f1232d. The device results below ran on 7cd3e412c41a; this head differs from it by the merges of main at 0591c4e85d, c34ff562ca, a3aecd8d0f and 484437b6ac (conflicts resolved in cuda_batch_moe.zig, cuda_batch_state.zig, the CUDA runner help, CHANGELOG.md, the fixture and one upstream test that calls passRules) and the pin fixture gradient-serving.tsv. The device cells were not repeated on this head.
  • python3 tools/pr_check.py --base <main> --pr 1441: exit 0, 0 errors, 0 warnings; lean 339 vs 341 on main, 0 new. zig fmt --check zig: clean.
  • Host tests: test-cuda-host, test-exl3-cuda-host, test-flashnext-exl3-host, test-exl3-prompt-host, compile-flashnext-host, test-flashnext-memory-host, test-qwen-serving-host, test-lane-api-host and test-lanes-see passed on an earlier integrated EXL3 Flash Next: draft lane guard for offloaded experts (8/8) #1446 head on Darwin arm64; the full list was not rerun on this head.
  • Linux x86_64 CUDA cross-build exited 0 on an earlier integrated EXL3 Flash Next: draft lane guard for offloaded experts (8/8) #1446 head (build only).
  • CI: see the checks on this PR.

Device results on 7cd3e412c41a

Two 16 GB sm_120 GPUs, Linux x86_64, checkpoint above. One run per cell unless stated.

Cell Result
kernel-contract exl3 flashnext (filtered) 61/61 kernels pass gates 1-4, 22/22 controls red as planted, 137 limit problems; all 137 are also reported by pinned main on the same GPU with identical registers, shared bytes and recorded values
1441-serve-tp1 concurrent equals solo, 12/12 rows
1441-tf, -pack, -layer, -pool pass
1441-tfc, 1441-gen differ from the golden only at the documented near-tie positions (70/72 top tokens; teacher-forced ids 16 and 17)
Chat turn resumed at 3072 and 4096 rows same 48 token ids as a cold server
Decode and first token about 15 tok/s greedy at one stream, 41 tok/s aggregate at four; cold 6144-token first token 73.45 s. No main comparison: main refuses this checkpoint with UnsupportedCheckpoint.

Not run or open

  • The unfiltered kernel contract on this head. The filtered run covers every kernel this chain registers; the unfiltered one is about 630 kernels of other families, unchanged from main. On an older head it gave 632 kernels pass gates 1-4, 421/421 controls red, 564 limit problems (inherited; exit 1). A --jobs 4 unfiltered run on test(cuda): opt-in --jobs and --shard for kernel-contract #3093's head (main plus the runner change) gave 625 kernels pass, 410/410 controls red, 546 limit problems.
  • Main against this head (main refuses this checkpoint) and the NVFP4 comparison (not on my hardware).

Receipt

  • Boxes it reaches: single-rank EXL3 Flash Next loading and decode.
  • New switch: none in this update.
  • Environment: Zig 0.17.0. Host checks on Darwin arm64. Device runs on Linux x86_64 with two 16 GB sm_120 GPUs. Checkpoint turboderp/Qwen3.8-Flash-Next-exl3 at 69e33439ae950f17bcbe95c98f117d80f759ab6d.
  • Kernel contract: Filtered contract above. This PR adds the EXL3 expert and prompt kernels and their controls.
  • Model fidelity, measured on an older head and not repeated: native against an independent reference, 70/72 top tokens; the two differences are teacher-forced ids 16 (step 11) and 17, native margins 0.25 and 0.5 against reference 0.125 and 0.25. No tie waiver and no perfect-equivalence claim.
  • Licence of new weights or drafter: n/a (Qwen Community License 1.0 on the checkpoint; no weights distributed, no new drafter).

Review requests implemented in source

  • Main's test environment: video refusal describes the token budget without advertising a storage maximum is back byte for byte beside the unsigned-budget test.
  • The layer-test helper reads the canonical global moe_f32 branch as production does.

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. The Linux host CI job was canceled; device results and failures are listed above. The new tests were not run against the parent.
  • Comments and docstrings are one line. No measurements or history in the source. Lean check (one-line comments within 120 columns): 0 new problems. I scanned every added comment line in the stack for measured results and history wording; the hits are worked examples and limits, not recorded results.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines. Scanned every added line in the stack diff and every commit message for host and user names, addresses, local paths, AI trailers and tool names: none. No binary files are added. Receipts are not in the repository.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. No direct demonstration. The concurrent and drafted device cells run through the lane rounds.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Drafted: n/a, no drafts before EXL3 Flash Next: expert-parallel TP=2 (same tokens as TP=1) and MTP drafts (2/8) #1442. Resumed equals cold: a chat turn resumed at 3072 and 4096 rows gives the same 48 token ids. Concurrent equals solo: 12/12 rows.
  • No precision traded for speed. If the bits change, the description says which sums change and why. Expert leaves are float64 with fixed-tree merges and one rounding to float32 at the root, so cancellation does not lose low-order terms; this is new arithmetic against the NVFP4 path, not a trade for speed.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it. n/a against main (main refuses this checkpoint). Measured: decode about 15 tok/s greedy at one stream, 41 aggregate at four.

@BlivionIaG BlivionIaG changed the title EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/7) Oct 27, 2026
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s1-one-rank branch 3 times, most recently from 7790cd9 to dc22001 Compare October 27, 2026 10:51
@ashhart

ashhart commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thank you for splitting #1113 into a chain and for the clear write-up. A pilot gated to sm_120 with a named refusal is
a good shape. A few things need to change before this one can land:

  1. Please remove the int8 KV cache entirely. That means flashnext_exl3_kv.cu, exl3/kv/cuda_exl3_kv8.zig, the int8
    parts of exl3/kv/cuda_exl3_kv.zig, its seven contract records, and the hooks in cuda_batch.zig:358,
    cuda_snap.zig and cuda_prompt.zig. We don't take lossy formats, even opt-in. As written it also reaches every
    Flash Next checkpoint: Options.kv8 (cuda_lanes.zig:61) lifts main's --kv-cache fp8 refusal
    (native/cuda_refusal.zig:48), and setup() enables int8 before its if (!exl3) return
    (exl3/kv/cuda_exl3_kv.zig:151-154). The same applies to TF_FLASHNEXT_PLE_EMB=bf16 (cuda_exl3_ple.zig:25).
  2. Please move the shared EXL3 changes into their own PRs, each with a device byte-equality receipt against main and
    re-derived contract records. They are the ldmatrix path in exl3_candidate.cu:127 (it runs on sm_121 too),
    prompt_chunk 256 to 2048 in exl3_candidate.zig:47 (8x the scratch for every user), and the counter reset inside
    tf_exl3_rot_in (exl3_linear.cu:112, exl3.zig:55-69). Nothing in this PR uses the first two.
    tools/zig/exl3_prompt_ldmatrix_fixture.py looks like the right harness for the first.
  3. Please drop the comment-only edits to the 15 files outside the family (DeepSeek V4.1, GLM, H3, Drama3, HIP,
    tree_attention.cu, and others). EXL3 Flash Next: CUDA graphs and the device planner (7/8) #1445 reverts them anyway.
  4. cuda_prompt.zig:183 moves every BF16 embedding table, NVFP4's included, to mapped host memory. Please limit that to
    EXL3, or measure it on NVFP4.
  5. The new kernels need entries in the CUDA contract runner for gates 1 to 4. test-kernel-contract only checks
    their launch records.
  6. Please remove the local paths from the tools and from zig/tests/fixtures/exl3_ref_*.json. Nothing reads the
    fixtures. One row in them needs an explanation: at position 27 the GPU picks 5269, while your f64 oracle and the
    reference both pick 6278 with a 0.95 gap, and the row is labelled a tie.

Once those are done, what remains is the pending repo-client receipts and a concurrent-equals-solo run on this slice.

@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s1-one-rank branch 2 times, most recently from c0b2466 to 286f86d Compare October 27, 2026 14:46
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s1-one-rank branch 2 times, most recently from 68ddf3c to f556fd6 Compare October 27, 2026 17:56
@BlivionIaG BlivionIaG changed the title EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/7) EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) Oct 27, 2026
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s1-one-rank branch 4 times, most recently from c999115 to 725041a Compare October 29, 2026 10:36
@ashhart

ashhart commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG for the update. This slice is much tighter now. As far as we can see, the int8 KV cache, the shared EXL3 changes, the out-of-family comment edits and the local paths are gone, and the mapped-host embedding table is limited to EXL3 packs. A few things remain:

  1. fn_exl3_split_f16 still has only a launch record. Please add it to the CUDA contract runner for gates 1 to 4.
  2. Removing the fixtures takes the position-27 row out of the repo, but we'd still like to understand it: the GPU picked 5269 while the f64 oracle and the reference both picked 6278 with a 0.95 gap.
  3. On EXL3 the prompt arithmetic depends on the chunk cuts (cuda_lanes.zig:87), so the 1024-row chunk and TF_FLASHNEXT_CHUNK change tokens. Prompt rows should match serial decode whatever the chunk. This is the same point as on EXL3 Flash Next: deep prefill (3/8) #1443.
  4. Small cleanups: the bf16 Emb option in cuda_exl3_ple.zig, and the comments that cite an internal lever number and a work-in-progress branch name.

After that, we still need the repo-client receipts and a concurrent-equals-solo run on this slice.

BlivionIaG and others added 13 commits November 20, 2026 07:41
Admit window, MTP head and decode captures only when their pass has no host-planned expert pool; keep resident and rollback graphs available.
Recompute the actual merged-file pins for the 19 intentional ashhart#1441 serving source changes; no source or approved-list change.
…t cases

Main now names a TF_FLASHNEXT_CHUNK the table refuses at startup, so 0, 16385
and 4k end in error.InvalidEnvironment before the reader's BadChunk. The test
moved to cuda_lanes_admission_test.zig keeps that expectation and its comment.
runPiece and runGroup now ask window_graph.admits(p.m.layers), so the fake
Scratch in cuda_mtp_graphs_test.zig gets an m with no layers: no pooled EXL3
experts, so the graphs it checks still run as before.
Main's ashhart#3308 rows (scope flashnext) stay; the series' second .cuda rows for
the same names go, since rule() returns the first row and the SOLO one refused
0 that main accepts and the reader refuses. SOLO's forms and its doc row say an
EXL3 pack refuses it; the duplicate doc rows and the SOLO 0 refusal case go.
The EXL3 serving line and the startup refusal line stay under Unreleased; the
test, register-count, read-ahead, rank-scratch, negative-zero, graph-capture,
reduction-detail and CPU-only server lines describe internals and go.

# Conflicts:
#	CHANGELOG.md
--
2.54.0 (Apple Git-157)
--
2.43.0
Its bytes changed with main's InvalidEnvironment cases for the moved test.
@AIFlowML

Copy link
Copy Markdown
Contributor

I checked the first EXL3 patch ff95da41 in a scratch merge with 37fa51d23. The four conflict paths were the environment fixture, CUDA limits registry, CUDA test runner and serving pins. I kept main's readout dispatch and Inkling registry entries beside the EXL3 entries, and regenerated the affected pins from the resolved tree. The environment resolution is the one described in #1443.

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 with Zig 0.17.0 on M5 Max. The first passed 126/126 tests and built the Linux ARM64 CUDA native runner. The second compiled the Linux ARM64 CUDA test executable. The GPU run and final train CI remain open.

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.

4 participants