Skip to content

EXL3 Flash Next: CUDA graphs and the device planner (7/8) - #1445

Open
BlivionIaG wants to merge 80 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s5-graphs
Open

BlivionIaG wants to merge 80 commits into
ashhart:mainfrom
BlivionIaG:pr/exl3-s5-graphs

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

EXL3 decode graphs over shared attention and a device planner. TF_FLASHNEXT_EXL3_GRAPH=eager|1 is opt-in; the default remains the host planner. Excess experts are staged in budgeted device memory. TF_FLASHNEXT_EXL3_UNIFORM_LINES=0 means off.

The last two commits initialize the experimental two-chunk prefill buffer with its owning runtime and bound the deep-prefill MTP head's scratch-row calculation for Zig 0.17 ReleaseSafe.

Current-head evidence

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

  • Restore: TP1 and TP2 graph-off plain and drafted cold/warm/branch/rewind outputs matched cache-disabled references at 10,240-token fixtures. Warm/branch/rewind restored 10,305–10,315 tokens. The original concurrent inputs shared a prefix; their cold phase does not establish independently cold lanes or simultaneous throughput.
  • Graph alternation: TP1 off/eager/graph/graph/eager/off, greedy chat/code at one/four streams: full hashes and alone/serial checks matched. Eager/off aggregate decode ratios were 1.020–1.032 and graph/off 1.019–1.042, one observation per arm/cell. Receipt.
  • Graph execution: a separate TP1 CUDA node trace recorded 1,476 four-row graph-node launches each for shared-attention preparation, chunk and merge. Profiling perturbs timing; this is execution coverage, not a benchmark. Trace.
  • Active TP2 peer loss: without profiling, killing rank 1 after at least eight nonempty streamed chunks produced RankDisconnected and [DONE] within 20 seconds; rank 0 remained alive and refused a follow-up completion with HTTP 503 engine_unavailable. /v1/models still returned 200. This run did not independently prove graph replay. Receipt.
  • Profiled peer loss: one node trace was stopped before injection; graph activity preceded peer loss, but the active client timed out after 20 seconds. A separate run left tracing active: 4,104 graph-node kernel records preceded injection, and the active stream failed explicitly within 20 seconds; the follow-up completion returned 503. The unprofiled run also returned an error. One observation each does not establish causation. Stopped trace, live trace.
  • Darwin arm64 zig build test-flashnext-exl3-host -Doptimize=ReleaseSafe exited 0. The original ReleaseSafe overflow also reproduced in a standalone Linux x86-64 program; guarded boundary cases passed. Investigation.

Earlier evidence

On d4df21978f, TP2 experimental two-chunk 16,384-input/1,024-output prose and code completed with output hashes matching the default single-chunk baseline, one stream, graph off. Earlier device-plan/graph and EXL3 kernel contracts passed, but are not current-head server or kernel coverage. Two-chunk receipt.

Open

Repeat seeded and drafted TP1/TP2 graph alternation, cacheless-reference restore and active-request peer-loss checks on the integrated head, with independent graph-execution evidence. Investigate the profiled timeout without assuming causation. No server throughput test isolates staged overflow. The maintainer owns routine coordination, CI and integration.

Earlier model-fidelity testing found 70/72 top-token matches against an independent reference; no tie waiver or perfect-equivalence claim. Main refuses this checkpoint and is not a runnable performance baseline on this box. No checkpoint weights are distributed; the checkpoint uses Qwen Community License 1.0.

@ashhart

ashhart commented Oct 27, 2026

Copy link
Copy Markdown
Owner

CUDA graphs for Flash Next are welcome. Acceptance staying in the core lane engine, with the device code only proposing
and planning, is the right split. Before this can land:

  1. Please add the eager-vs-graph receipt: same binary, graphs on and off, alternating runs. That was the condition on
    [Draft] EXL3 Flash Next on CUDA: TP=2, BF16 paging, cache reuse, graphs #1113.
  2. Please fix capture-failure handling. One failed capture sets gcache.broken
    (exl3/graph/cuda_exl3_graph_cache.zig:71, set at cuda_exl3_graph_hooks.zig:94 and :141), and every later
    round then fails with GraphCaptureFailed (:64, :111) for the life of the process. The round should run
    eagerly instead. On two ranks, the failure aborts the communicator.
  3. Please cut the 20 new graph and planner switches down to the few a user needs.
  4. Please move the engine facts out of process globals (offloaded_layers, dplan.active, tiles_on, state.deep)
    into the engine.
  5. Please give the six planner kernels runner entries.

This PR depends on #1441 to #1444, so it inherits their blockers.

@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s5-graphs branch 4 times, most recently from f13fa73 to 556eb09 Compare October 27, 2026 17:56
@BlivionIaG BlivionIaG changed the title EXL3 Flash Next: CUDA graphs and the device planner (5/7) EXL3 Flash Next: CUDA graphs and the device planner (7/8) Oct 27, 2026
@BlivionIaG
BlivionIaG force-pushed the pr/exl3-s5-graphs branch 19 times, most recently from 3a3714f to 5ca7783 Compare October 29, 2026 19:22
@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Hardware update for #1445, #1522 and #1446: I no longer have the two RTX 5060 Ti system. I now have access to only one RTX PRO GPU, so I can run TP1 checks there but cannot reproduce the requested TP2 or peer-rank-loss cells locally. The previous 5060 Ti receipts remain available and are not exact-head results for the latest integrated stack. Would TP1 results on the RTX PRO be useful for the updated heads, and can the TP2/peer-loss cells be covered on your side or by another contributor? I will not label TP1 or older results as TP2 qualification.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Hardware detail: the remaining card is an NVIDIA RTX PRO 2000 Blackwell, 16 GiB (driver 580.178.04). It is reachable, but the prior benchmark checkpoint and Zig/CUDA build toolchain are not installed in the standard locations on that host. I will keep any new TP1 results distinct from the earlier 5060 Ti receipts.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Correction to my host-readiness note: CUDA 13.2 is installed at /usr/local/cuda-13.2; nvcc was simply not on the noninteractive PATH. Zig was not on that PATH. The prior exact checkpoint revision 69e33439ae950f17bcbe95c98f117d80f759ab6d is approximately 79.3 GiB according to Hugging Face metadata, while this host currently has approximately 60 GiB free on its disk, so it cannot be downloaded there as-is without additional storage or cleanup. I have not deleted other workloads or substituted a different checkpoint.

@AIFlowML

Copy link
Copy Markdown
Contributor

On M5 Max with Zig 0.17.0, I ran zig build test-flashnext-exl3-host test-flashnext-exl3-trace-writer-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j5 --summary all at public head 60206ea3. The trace writer passed 7/7, but the EXL3 suite hit two compile errors.

  • zig/src/families/flashnext/cuda_kv_lifetime_test.zig:153 declares a local t that shadows the existing file-level std.testing alias. Removing the local declaration reuses the existing alias.
  • zig/src/families/flashnext/cuda_kv_lanes.zig:465 calls nextPages(&p.pool, …). Since p.pool is already a pool pointer, passing p.pool matches the expected type.

With those two changes in a scratch copy, the same command passed 290/290. A trial merge against 6a8faeed also reported four conflicts. The TP2 rank-loss receipt above is from e633d2d9. I saw the hardware update. A TP1 check on the integrated head would cover the single-rank path, and the TP2 peer-loss cell still needs a contributor with the appropriate setup.

Igor Lessio - AIFLOW LABS

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Correction to my storage update: an existing EXL3 checkpoint was already present under a different local user’s private home. Its seven model shard SHA-256s, n-gram and MTP files match Hugging Face revision 69e33439ae950f17bcbe95c98f117d80f759ab6d; the unmodified .native config and index also match that revision. I created a separate symlink view using those native metadata files, without modifying the existing checkpoint. Zig 0.17.0 is installed and its published checksum verified. The host can therefore be prepared for TP1 work without downloading another 79 GiB; TP2 and active peer loss remain unavailable on this single GPU.

The pool lane test's TF_FLASHNEXT_KV_PAGES case declared a local `t`, shadowing the file-level `std.testing` alias; it now reuses the alias. `Pool.mapAhead` passed `&p.pool`, whose field is already a pool pointer, so the call now passes `p.pool`.
@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Both compile errors @AIFlowML reported are fixed on 235d94f38249c38667025dbc4a53ec4001e585e8 (fast-forward on pr/exl3-s5-graphs, no rebase, no force-push).

  • zig/src/families/flashnext/cuda_kv_lifetime_test.zig: the local const t = std.testing in the TF_FLASHNEXT_KV_PAGES case is gone; the file-level alias is reused.
  • zig/src/families/flashnext/cuda_kv_lanes.zig:465: nextPages(&p.pool, ...) now passes p.pool, which is already a pool pointer.

Verified on Darwin arm64 with official Zig 0.17.0, in a fresh worktree at this commit:

  • zig build test-flashnext-exl3-host test-flashnext-exl3-trace-writer-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j4 --summary all: Build Summary: 9/9 steps succeeded; 297/297 tests passed — test-flashnext-exl3-host 290/290, test-flashnext-exl3-trace-writer-host 7/7. The step prints the known failed command: label with three EXL3 placement-profile cold start warnings while the run succeeds.
  • zig fmt --check on both files: clean.
  • python3 tools/pr_check.py --base f0b9cb8555 --pr 1445: 0 errors, 1 advisory warning (no Unreleased bullet naming this PR; merge base 3661a42814, 357 changed files, lean 168 vs 168, 0 new).

This is a host compile/test result only. Device graph, performance and TP2 peer-loss cells have not been run on this head; the earlier device receipts are from e633d2d9 and older commits, and I no longer have the two-card system.

# Conflicts:
#	docs/kernel-contract.md
#	zig/src/native/cuda_refusal.zig
#	zig/src/platform/environment_test.zig
#	zig/tests/cuda/contract_limits.zig
#	zig/tests/cuda/main.zig
#	zig/tests/fixtures/gradient-serving.tsv
@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Merged current main 36e17ec297; head is now decfebcf26. Conflicts resolved: zig/tests/cuda/main.zig takes main's readout dispatch (info(gpu), flashnext-readout-fused), cuda_refusal.zig takes main's rank refusal, contract_limits.zig keeps both image lists, environment_test.zig keeps main's new rank/env rows beside ours, docs/kernel-contract.md keeps main's gate-4 stress-fill text then our EXL3 paragraphs. The gradient-serving.tsv fixture was regenerated from the merged sources (36 hashes; our stacked content differs from main's pins). Verification on this head: zig build test-gradient-serving test-flashnext-exl3-host test-flashnext-exl3-trace-writer-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j4 --summary all → 15/15 steps, 290/290 tests; cuda_prompt_wt.zig compacted to 600 lines; pr_check against 36e17ec297 → 0 errors, lean 167 vs 167, 0 new. Host-only evidence.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Refreshed onto upstream main d3d9a66117; head is now 013f2508e7. Conflicts: 3 files, 5 blocks — zig/tests/cuda/contract_family_sets.zig (kept main's idol_decoder set beside our flashnext_exl3, with init, errdefer and deinit in main's order), zig/tests/cuda/contract_limits.zig (kept main's image list and re-attached our five flashnext_exl3* names), zig/tests/fixtures/gradient-serving.tsv (took main's pins, then regenerated 36 hashes from the merged sources, including the cuda_prompt_wt.zig pin the head commit had left stale).

Verification on this head: zig build test-gradient-serving test-flashnext-exl3-host test-flashnext-exl3-trace-writer-host -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j4 --summary all → 15/15 steps succeeded, 299/299 tests passed (291 + 7 + 1); zig fmt --check build.zig zig clean; tools/pr_check.py --base upstream/main --pr 1445 → 0 errors, 1 advisory warning (no Unreleased bullet naming this PR; pre-existing), 356 changed files, lean 167 vs 167, 0 new.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

CI note: release-paths (ubuntu-24.04) failed the step zig build check-release-paths. I reproduced that exact command locally on this head (zig build -Dfixed-cpu check-release-paths) and it exits 0; the hosted log is unavailable while the run is still queued. I am not claiming a pass yet — if it fails again on a fresh run I will treat it as real and dig into the cache/restore path.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Follow-up on the red release-paths job: not a flake. On Linux that job builds the dist server, which compiles the CUDA planner; cuda_exl3_pass.zig:303 passed serverReserve(total) (an error union) straight into std.math.add. macOS hosts never compile that path, which is why my local run passed. Fixed on 66ae33bf12 with try serverReserve(total); zig build -Dfixed-cpu compile-dsv41-server now exits 0, fmt clean, pr_check 0 errors.

@AIFlowML

Copy link
Copy Markdown
Contributor

I reproduced the release-paths difference on Zig 0.17.0. zig build -Dfixed-cpu compile-dsv41-server passes on both 013f2508e7 and 66ae33bf12. To exercise the hosted job's artifact on the Mac, I added a local build step that selects the repository's Linux x86-64/glibc 2.28 dist target and runs the same release-path checker over it.

  • 013f2508e7 fails with the serverReserve(total) error union at cuda_exl3_pass.zig:303.
  • 66ae33bf12 clears that error and reaches a second one at zig/src/families/flashnext/cuda_kv_lanes.zig:302. In Pool.waits, nextPages(&p.pool, k, ids[0..n]) takes the address of an existing pool pointer.
  • Changing that call to nextPages(p.pool, k, ids[0..n]) on 66ae33bf12 passes all 11 release build and path-check steps locally.

The published head also passed 299 EXL3 host, trace-writer and serving-pin tests. The one-line repair above was tested in the Linux release build and needs to be applied to the branch before that check can pass there.

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.

3 participants