Skip to content

[Draft] EXL3 Flash Next on CUDA: TP=2, BF16 paging, cache reuse, graphs - #1113

Closed
BlivionIaG wants to merge 126 commits into
ashhart:mainfrom
BlivionIaG:exl3-on-upstream-wip
Closed

BlivionIaG wants to merge 126 commits into
ashhart:mainfrom
BlivionIaG:exl3-on-upstream-wip

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Draft for upstream review; not merge-ready. This ex3-on-upstream-wip/branch/exl3-on-upstream-wip integrates the Qwen3.8-Flash-Next EXL3 path with upstream main (base d1018b318). It is a broad working draft intended to be split into focused PRs before merge. The implementation has working paths, but required correctness, capacity, and performance gates remain open; in particular, CUDA graphs have not demonstrated a repeatable speedup.

What it adds

  • EXL3 weight loading and CUDA execution in TensorFold's Flash Next path.
  • Routed-expert offload with per-layer GPU pools, pinned host banks, and asynchronous H2D staging.
  • Opt-in persistent decoder/MTP expert-frequency priors, with private per-model/rank storage, checked reload, adaptive startup decay, pool warming and atomic graceful-stop saves.
  • Expert-parallel TP=2 with split routed experts, shared-expert execution, vocabulary-sharded lm_head, and NCCL collectives.
  • BF16 KV paging to host RAM, snapshots/restores, and prefix/cache reuse, with an opt-in per-rank shared block arena. Ordinary-context private/shared snapshot and served reuse gates pass; the 200k × 2 target remains unqualified.
  • MTP drafting and CUDA graph capture/replay. Decode graphs cover eligible rounds/windows; prefill graphs capture dense sub-blocks, while expert scheduling/copies remain eager.

These are implemented paths in the branch, not claims that every supported shape or failure mode is validated. The evidence and remaining gates below define what has actually been checked.

Memory and execution split

Configuration shown: TP=2 with BF16 KV paging enabled (TF_FLASHNEXT_KVPAGE=1). Each request uses both GPUs. The boxes show placement, not allocation sizes.

flowchart LR
  subgraph HOST["CPU scheduling and host RAM"]
    direction TB
    RAM0["Rank 0 RAM<br/>Expert bank: 0-255<br/>MTP expert bank<br/>Full BF16 KV backing<br/>Prompt snapshots"]
    RAM1["Rank 1 RAM<br/>Expert bank: 256-511<br/>Shared weight source<br/>Full BF16 KV backing<br/>Prompt snapshots"]
  end

  subgraph VRAM["Two GPUs - one TP=2 model"]
    direction TB
    GPU0["GPU 0 / rank 0 / 16 GiB<br/>Dense/router/attention<br/>Scales + lm_head half<br/>Routed cache: 0-255<br/>MTP weights/pool/state<br/>BF16 window + blocks<br/>GDN, tables, scratch"]
    GPU1["GPU 1 / rank 1 / 16 GiB<br/>Dense/router/attention<br/>Scales + lm_head half<br/>Routed cache: 256-511<br/>Resident shared expert 512<br/>BF16 window + blocks<br/>GDN, tables, scratch"]
  end

  FREQ["Optional local disk profiles<br/>Expert counts per model + TP rank<br/>No weights, KV or graphs"]
  FREQ <-->|"Checked priors / graceful save"| RAM0
  FREQ <-->|"Checked priors / graceful save"| RAM1

  RAM0 <-->|"PCIe transfers"| GPU0
  RAM1 <-->|"PCIe transfers"| GPU1
  GPU0 <--> NCCL["NCCL collectives<br/>MoE all-reduce<br/>Logit all-gather"]
  GPU1 <--> NCCL
  classDef gpu fill:#e8f2ff,stroke:#3765a3,color:#152b46
  class GPU0,GPU1 gpu
Loading
  • Replication and sharding: paging currently disables attention-head sharding, so each rank has the full attention/KV layout and its own host backing allocation. Decoder routed experts and lm_head vocabulary columns remain split. With paging disabled, a separate attention-head split is available; it is not the configuration drawn here.
  • Expert movement: host-planned paths use asynchronous H2D copies. The deep-prefill ring reuses decoder pool storage across layers. In device-planned decode, GPU kernels read mapped host banks to fill cache lines; overflow experts can be read in place. Routed caches retain experts for reuse, while the shared expert has a separate resident allocation on rank 1. CPU scheduling does not mean CPU expert execution.
  • KV and snapshots: selected older KV blocks are fetched into the device block cache; recent window rows are written back to RAM during window rebasing or snapshot flushing. Snapshots preserve host KV history, device windows/cache contents, pager tables, and recurrent/PLE/MTP state where present. The PLE table itself is file-backed; gathered embeddings are uploaded.
  • Shared block option: TF_FLASHNEXT_KVPAGE_SHARED=1 uses one block pool per rank with fixed per-lane windows and generation-tagged ownership. Private per-sequence paging remains the default. Shared version-2 snapshots retain only owned blocks and remap them into destination slots; they do not overwrite the whole arena or deduplicate identical-prefix payloads. Capacity pooling can trade cache hits for VRAM, so it is not a throughput claim.
  • Scope: the NCCL box denotes logical communication, not a direct GPU peer link. Memory budgets depend on configuration. Ordinary-context TP=2 paging/cache behavior has been exercised; 200k × 2 with paged KV remains unproven. Prefill expert scheduling/copies remain eager when dense prefill graphs are enabled.

Proposed PR segmentation

This is a proposed split plan, not a claim that the listed PRs already exist. Each future PR should own one coherent layer, add focused tests, and record its correctness and performance evidence. Until then, this mega PR remains a tracking draft and should not be merged as one piece. The current branch already contains prototype implementations for these areas; the listed gates are remaining review/acceptance criteria.

  1. EXL3 foundation and resident forward: isolate format/config parsing, weight loading, and the upstream CUDA adapter. Acceptance: layer/model oracle gates for the resident path.
  2. Expert pool and offload: isolate host-bank layout, device line pools, replacement policy, async copies, and pool lifecycle. Acceptance: pooled output matches resident execution; measure copy/compute overlap rather than assuming it.
  3. TP=2 execution and serving: isolate expert partitioning, shared-expert placement, vocabulary-head split, collectives, and rank lifecycle. Acceptance: TP=2 logits/outputs meet a defined numerical tolerance and the server works on both GPUs.
  4. BF16 KV paging and state reuse: isolate device/host page tables, paging/eviction, paged snapshots/restores, and prefix branching. Acceptance: paged/resident equivalence where comparable; exact state/logit parity for snapshot/restore and cache reuse, plus long-context tests.
  5. MTP drafting: isolate draft-head input, TP=2 draft/verify, and prompt-cache interaction. Acceptance: committed drafted tokens equal serial decoding with drafting disabled.
  6. CUDA graph decode: isolate stable graph inputs/outputs, TP=2 collectives, offload boundaries, and capture/replay lifecycle. Acceptance: graph/eager output equality over repeated replay and snapshot restore.
  7. CUDA graph prefill and scheduling: isolate chunked capture, expert-major scheduling, staging overlap, and profiling-driven tuning. Acceptance: repeatable graph-on improvement in controlled prefill/decode measurements without correctness or memory regressions.
  8. Final capacity and product integration: run repeated 200k-context × 2-concurrency TP=2 tests with BF16 paging/cache reuse, resource margin, and failure cleanup; then consider family/recipe registration. Do not register until preceding gates pass.

Proposed dependencies: the foundation precedes the other slices; expert offload and TP=2 build on it; paging needs stable TP=2 allocation/lifecycle; MTP needs TP=2 and cache semantics; graph work depends on stable paging/offload and eager behavior. Decode and prefill graph slices can be developed in parallel once interfaces are fixed, but should be integrated and reviewed in dependency order. Avoid duplicate implementations: use stacked branches or clean cherry-picks, and keep this umbrella draft as an index until the sequence is complete.

Benchmark report

The detailed tables, exact tested commit, model/checkpoint identity, runtime configuration and methodology are in the 21 October benchmark comment. These historical results apply to source ca2b13c88315c9c1c7a9ce17c002226f3585f73a, not subsequent candidate changes. The single matched graph/eager run did not establish a speedup.

Evidence and remaining gates

  • Prior replay/cache correctness checkpoint: runtime 4afc6169 passes 192 EXL3 host tests, real native/GPU-runner builds, private/shared buffer-reuse/snapshot checks on both cards, and exact TP2 prefill origin/grid rebinding through dense/sparse and paging-split transitions. The native MTP/graph/shared-BF16 cold/warm/branch/rewind gate retains all eight reference hashes. Exact sources, binaries, model, methodology and scope. Correctness-run timings overlapping compilation are excluded; isolated graph speedup remains unproven. Retaining buffers does not retain old-owner graphs.

  • Prior replay/cache telemetry checkpoint: runtime 975c1df9 passes 177 EXL3 host tests, the native CUDA build, diagnostics-enabled TP2 shared-BF16 cache reuse with separate valid expert/KV counters, and diagnostics-disabled c8 hash/replay qualification. Source b3a7b565 also passes the focused real TP2 width-3/4/16 rebind fixture. Full source, model, methodology and bounded measurements. Those receipts do not qualify subsequent runtime changes. No repeatable speedup, independent golden fidelity or 200k capacity is inferred.

  • New shared BF16 checkpoint: historical runtime ccb32fc3; these direct fixture results are not relabeled as current-head tests. 153 EXL3 host tests and real native/GPU-test CUDA builds pass. Matched TP=2 private/shared sparse-paging fixtures pass exact restored-state checks, owned-entry remapping, recycled/asymmetric generations, foreign-request isolation and actual prefill/decode graph replay. Two 16,424-token HTTP histories with MTP and graphs pass cold/warm/branch/rewind reuse against the private reference. The full qualification comment separates these tests from the earlier same-binary 0de41d37 allocation measurement (920 MiB lower sampled peaks per GPU). Shared mode stays opt-in; none of these results establishes independent model fidelity, repeatable graph speedup or 200k × 2 capacity.

  • Served BF16 paging/cache gate on ca2b13c8: two concurrent HTTP histories, each with 16,424 prompt tokens and 32 generated tokens, passed cold, warm, branch and rewind phases with graphs and MTP enabled. Full response hashes matched a separately started cache-disabled reference for every phase. Cache-enabled requests reused 16,407–16,417 tokens on warm/branch/rewind phases; warm native prefill times were 0.944 / 0.974 seconds. This proves ordinary-length prefix reuse and continuation parity, not long-context capacity, independent model fidelity, or exact internal-state parity at this new head.

  • Completed matched graph/eager gate on ca2b13c8: all four exact 1024/512 and 16384/1024 cases at c1/c8 passed in each mode (36 valid responses, 18/18 matching full token/text hashes). Binary and per-rank expert geometry were identical. Both ranks replayed decoder graphs while all eight requests decoded in each c8 cell, and replayed prefill graphs in the long-input cells. Graph-run physical GPU peaks were 14,958 / 14,996 MiB; automatic expert pools were 10 / 23 lines per layer. This is an ordinary-context functional/capacity pass, not a 200k claim.

  • 21 October checkpoint: source ca2b13c8 is integrated without rewriting the draft history. The parent EXL3 host gate passes 90/90 tests, scoped formatting/diff checks pass, all tracked source hashes match the Linux build tree, and the native CUDA sm_120 build succeeds. This adds workload-scaled graph budgets, class-aware local graph charges, selective coordinated TP LRU retirement, and a tested local-reclamation fallback. Graph memory charges remain heuristic, not measured exec sizes.

  • New snapshot hardware receipt: on the preceding d3662d1b runtime with test-only upstream loader compatibility fixes, both RTX 5060 Ti ranks passed the compiled two-lane BF16-paged snapshot fixture. Restored canonical KV history, recurrent/index/PLE state and continuation logits matched exactly. Each graph iteration recorded 27 prefill and 5 decode replays per rank. This uses 24 expert lines per layer and no MTP head; it is not an eight-lane capacity, served prefix-cache, or 200k test. The new checkpoint separately passes the served cache-reuse gate below; this older direct state/logit fixture is not relabeled as a current-tree run.

  • Performance remains an acceptance blocker: graph decode was 3.4–5.4% slower across the four cells in this single matched pair. No repeatable speedup is established. Cache-key churn and the graph/expert/KV memory partition remain optimization work; increasing reserved memory is not itself a performance fix. The earlier interrupted diagnostic overlapped compilation and is not a controlled performance receipt.

  • On earlier source-tree revisions, TP=2 serving, draft-on/off output parity, BF16 paging, snapshot/cache reuse, and graph/eager correctness were exercised on development hardware. These results are not a full validation of the exact current PR head.

  • CUDA graphs currently match eager in tested paths, but controlled profiling has not established a graph-on speedup. That is a hard performance gate, not a claimed win.

  • The strict golden-prompt near-tie and remaining TP numerical-parity questions still require closure.

  • Ordinary-context TP=2 private/shared paging, scoped state/logit restoration, graph replay and served cache reuse now pass on runtime ccb32fc3 as described in the qualification comment. Cancellation/overflow/live-rank failure injection, repeated performance qualification and the 200k × 2 BF16 paging target remain required before merge/registration. The earlier near-200k × 2 retrieval test used resident BF16 KV and is not evidence for paged-KV capacity.

  • Fresh tools/zig/lean_check.py run: 1,762 findings on the current source versus 444 on pinned upstream d1018b318 (1,318 more). This remains a CONTRIBUTING blocker, not a clean result.

  • CPU expert execution is out of scope. BF16 remains the required KV-cache format; int8 KV is not part of the serving path.

Branch: exl3-on-upstream-wip
Current fork head: 0272aafe266299c078976c74fbe5347bdf484f7c (qualified target-layer history, DMA coalescing, opt-in transfer provenance and actual-layer GDN graph keys; bounded TP2 BF16 cache/parity and screening measurements pass)
Upstream base: d1018b318fb51981c4a18f12e40269a4d3ee9713

Persistent expert-profile checkpoint (22 October)

Native source babc9762e2dbc999c9b68df252d619830203d693, binary SHA-256 86a7b20b6bac2bc5b2b78f9c89654a21cd1c0bd2ad9e6806ee1dc70abe110907, passes a real TP2 graceful stop/start gate with graphs, MTP and shared BF16 paging: two waves of two concurrent 1,024-input/64-output requests in each fresh process pair, prefix cache off, fixed pools 32/48. Both ranks save, reload, warm and update their profiles; response hashes match across restart. The leader is signalled and the existing TP stop protocol releases the follower. Startup warms 1,568 / 2,304 existing lines, with no pool enlargement. The profile checkpoint also passes 211 host tests and 15 focused Linux Debug/ReleaseSafe persistence tests; a separate source-53ef CUDA fixture verifies actual bytes/tables and resized pool restart on both GPUs.

Enable with TF_FLASHNEXT_EXL3_PROFILE_DIR. The advisory fingerprint covers routed trellis plus config/index bytes, not every checkpoint tensor; hashing costs about 16.6 seconds per rank at startup in this gate. Counts are decayed once and saved by replacement, not added twice. The separate deep-prefill ring histogram is not persisted; prefill may discard startup residency. Abrupt follower/process kills can lose unsaved updates. These are placement priors, not KV snapshots or elastic budgeting. A separate short-prompt ABBA with drafts off measured 9.0% lower TTFT and 6.5% lower decode latency for warm versus cold persisted profiles (TP=2, graphs and BF16 paging on; 128-token input / 64-token greedy output; identical full output hashes). This narrow result is not evidence for long-context or drafted-serving gains, nor a graph speedup; profile fingerprinting adds about 16.6 seconds of startup per rank. Full methodology and values are in the final report. No independent golden-fidelity, long-prefill-speed or 200k×2 gate is closed by this test.

Latest prefill efficiency candidate

ce10271d starts initial expert copies before CPU member-list construction and coalesces copy-stream dependencies for equal/older release epochs, preserving newer-reader and event-wrap guards. It passes 215 EXL3 host tests, native CUDA host/forward-body compilation, formatting/diff checks and zero new lean findings. Native TP2 BF16 cold/warm/branch/rewind parity now passes for the specified ce10271 workload; the matched ce/babc revision comparison is effectively flat. Independent model fidelity and 200k capacity are not inferred. Previous hardware receipts apply only to their named sources. Copy-grid-only tuning (144/36/36/144, frozen native babc9762, TP2 c2, 1k/256, two waves/server) was 0.3–0.5% slower in both ordered pairs with exact response parity; the default stays unchanged.

Latest measured follow-up

a25fa226 passes a real native TP2 gate with two concurrent 16,424-token histories, MTP, prefill/decode graph replay, BF16 RAM paging and prefix reuse at 4096-row prefill. All eight cold/warm/branch/rewind outputs match the separate cold reference. Demand/initial-prefetch/cross-layer-prefetch copy and requested-byte categories reconcile on both ranks. Native SHA256: 939f5ef182c9bfefb1efe2a3847715c32011b734f703427a52a311ada61df5bf; 222 EXL3 +218 runtime host tests pass, zero new lean findings.

The previous ce10271d revision showed no meaningful speedup against its baseline. Profiling identified expert-transfer volume and many separate projection DMA submissions. The new direct-copy helper combines projections only with proven common pinned-bank provenance and exact adjacency, with guarded fallback; no CUDA arithmetic or graph ownership checks were weakened. The matched ce/a25 code comparison at identical4096-row settings is complete and shows no repeatable gain; one pair has worse decode/ITL. A subsequent matching-target-layer-history candidate passes native cache parity and all16 benchmark hashes/replay checks in four fresh A/B/B/A servers, with about2.1% aggregate decode-service improvement in both screening pairs and only0.2–0.3% effective-prefill improvement. It is integrated with unchanged mandatory loading and graph/BF16-paging guards;227 host tests and native compilation pass. Two pairs do not establish statistical significance or causal graph/eager speedup; diagnostic total transfer volume is effectively unchanged. Tested source and binary, exact ratios and the separate current-default CUDA profile are recorded in the linked measurement comment.

A separate four-fresh-server setting comparison shows 4096 versus forced2048 rows improves TTFT about39% and effective aggregate-prefill about64% on the stated TP2/c2 workload, with exact hashes and actual graph reuse. 4096 is already the engine default; the inherited benchmark harness forced2048. This is a setting comparison, not a new-code gain. The8192 pilot is not accepted because cached-prefill replay failed its unchanged gate. Cross-request graph retention remains disabled pending complete captured-allocation lifetime proof. Full methodology, exact tested commits, units and limits are in the existing measurement comment.

Dense EXL3 prompt-kernel update (22 October; pushed head 5a94359c07c8f716255ff9b0de7a7257dec1432f)

A Blackwell sm120+ mul1/C2 ldmatrix.x4 input-fragment path is now included. The four fresh-server A/B/B/A TP2 screening pairs with 16,384 input / 256 output, c2, graphs/MTP, BF16 RAM paging, 4096-row prefill and pools 32/48 show effective aggregate-prefill +2.27%/+2.23% and TTFT −2.28%/−2.24%; aggregate decode-service +0.77%/+1.23%. All response hashes match. This is a small two-pair screening result, not statistical significance or graph/eager causality. The canonical candidate passes the BF16 paging/cache cold/warm/branch/rewind gate (8/8 responses) and changed-kernel CUDA/resource checks. Full kernel-contract timed out at 300 seconds on both GPUs; broad contract pass is not claimed. Exact methods, hashes, limits and assessment of the reviewer’s cache/page-table pointers are in the latest measurement comment.

Integrates the EXL3 CUDA adapter, weight/projection path, PLE rows, expert pool, and independent reference fixtures as one foundation change. The upstream v1.1.0 base remains unchanged.
Groups rank partitioning, vocabulary head split, NCCL serving, pooled experts, and TP=2 draft integration. Keep the eager TP=2 gate with this change.
Groups expert-major chunked prefill, TP=2 attention placement, and host-resident prompt state for long-context execution.
Adds dynamic BF16 KV paging, host-backed state, snapshots/cache reuse, and initial TP=2 graph integration. BF16 remains the required cache format.
Consolidates graph replay fixes, event ordering, reuse across page origins, profiling gates, and prefill/decode tuning.
Resolve the EXL3 implementation against current upstream main while preserving upstream commit ancestry.
Retain the active BF16 paging and CUDA graph design notes plus the current integration report. Remove obsolete v1.1.0 and int8-first proposals from the draft. Consolidate the branch history into review-sized implementation commits.
@BlivionIaG
BlivionIaG force-pushed the exl3-on-upstream-wip branch from 4ec3c44 to b244063 Compare October 20, 2026 10:48
Integrates the EXL3 CUDA adapter, weight/projection path, PLE rows, expert pool, and independent reference fixtures as one foundation change. The upstream v1.1.0 base remains unchanged.
Groups rank partitioning, vocabulary head split, NCCL serving, pooled experts, and TP=2 draft integration. Keep the eager TP=2 gate with this change.
Groups expert-major chunked prefill, TP=2 attention placement, and host-resident prompt state for long-context execution.
Adds dynamic BF16 KV paging, host-backed state, snapshots/cache reuse, and initial TP=2 graph integration. BF16 remains the required cache format.
Consolidates graph replay fixes, event ordering, reuse across page origins, profiling gates, and prefill/decode tuning.
Retain the active BF16 paging and CUDA graph design notes plus the current integration report. Remove obsolete v1.1.0 and int8-first proposals from the draft. Consolidate the branch history into review-sized implementation commits.
Preserve the original integration resolutions while replaying the six feature commits directly onto upstream main. Restore the paging fixture initialization, Zig 0.17 compatibility, hook placement, field ordering and formatting so the resulting tree exactly matches b244063.

Validated with an exact full-tree comparison, Zig 0.17 formatting checks, and all 22 Python acceptance-harness tests. CUDA runtime and model gates have not been rerun for this history-only experiment.
Upstream chunk execution calls moeBlockKeep and attnBlockKeep directly. Move format and attention-head dispatch into those shared entrypoints so EXL3 weights never reach classic packed expert kernels and both wrapper and retained calls use the same operators.

Compute Sanitizer reproduced invalid global reads in classic expert_rows from moeBlockKeep during the first decode round, with and without MTP. Preserved that failure receipt and checked Zig formatting. Runtime verification and a focused host regression follow on this isolated branch.
Exercise moeBlockKeep with an unattached EXL3 expert bank and a guarded legacy-copy stub. The call must return Exl3PoolNotAttached without entering the classic expert path. Include the regression in the existing EXL3 host test imports.

Validated with Zig 0.17 test-flashnext-exl3-host (exit 0) and formatting checks. The original placement was not separately rerun in this host fixture; Compute Sanitizer retained the actual model failure before the dispatch correction.
Merge codex/exl3-rebase-main onto the existing draft branch without rewriting published history.

Resolve the cuda_launch.zig import overlap by retaining the validated rebased tree, including the retained-block EXL3 dispatch regression test. The resulting tree is identical to 620a886.

Validated: Zig 0.17 focused EXL3 host tests and formatting passed on 620a886; the native CUDA runtime at 418ecdd completed all four TP2 BF16-paged eager benchmark cells. The c=8 graph-instantiation OOM remains unresolved; no graph-performance pass is claimed. git diff --check passes.
Use a per-engine scratch format and one allocation-size definition for sizing and allocation. Preserve common buffers, classic CUDA behavior and growth synchronization; reject format changes after scratch reservation.

Host arithmetic calculates savings of 27.62 MiB per rank at 1024 rows and 55.24 MiB at 2048. Added format/layout tests. Validated with Zig 0.17 test-flashnext-exl3-host, scoped zig fmt --check and git diff --check. GPU correctness, measured VRAM savings and graph fit remain unverified.
Merge the host-tested scratch allocation fix without rewriting draft history. The resulting tree exactly matches the scratch checkpoint; unfinished graph-budget integration remains excluded.

Validated: EXL3 host suite, Zig formatting, whitespace checks and exact merge-tree equality. GPU validation remains pending.
Add checked startup accounting and a bounded graph-ticket ledger across decode, prefill and MTP caches. Coordinate TP cohort retirement before re-instantiation, preserve auxiliary admission room, and count pre-capture prefill admission misses without disabling graphs or treating capture failures as successful execution.

Account pending/update/template lifetimes, protect graph space from pool/lane allocation, let allocator overhead consume its dedicated startup margin, propagate asynchronous capture errors, and transfer synchronous chain ownership before launch. Update checked-budget GPU-test callers.

Validated: combined EXL3 host suite with Zig 0.17, scoped formatting and git diff --check. Previous integration snapshot built native CUDA successfully but failed the new startup-memory postcondition. The corrected checkpoint still requires native rebuild, actual TP2 graph replay/hash checks, VRAM measurements and cache/snapshot regressions. Graph byte charges are explicit heuristics, not measured allocation sizes; no fit or speedup claim.
Integrate d3662d1 into the existing draft without rewriting history. The source tree is exactly the reviewed checkpoint.

Validation: combined EXL3 host tests and native CUDA sm120 build pass. The prior diagnostic reproduced GraphBudgetBusy at eight requests; the updated real-GPU run is in progress. No c8 graph-fit, cache-restore, coverage or performance pass is claimed.
Size heuristic graph reservations from planned streams and decoder layers; distinguish full decoder graphs from local prefill/MTP execs without retained NCCL templates. Protect only the unmaterialized auxiliary allowance.

Agree selective TP eviction victims across asymmetric caches, quiesce and acknowledge destruction, and retain unrelated cohorts and local graphs. Prefer least-recently-used local proposals with deterministic ties.

Validated: combined EXL3 host suite, scoped formatting and diff checks. Prior hardware run d3662d1 completed 1k/512 at c8 without OOM but repeatedly captured instead of reusing graphs; its slow long diagnostic was stopped, not called a completed matrix. This checkpoint still needs the Linux native build, per-cell replay/hash qualification and measured VRAM/performance. Charges remain heuristic estimates.
Pass the optional rank-loader pocket argument explicitly at seven existing test call sites after the upstream rebase. This restores compilation without changing runtime arithmetic or precision.

Validated: Zig scoped formatting and diff checks; full Linux sm_120 default CUDA build succeeded. The compiled TP2 paged snapshot fixture passed on both RTX 5060 Ti cards, preserving exact BF16 history, recurrent/index/PLE state and continuation logits across restore with prefill/decode graph replays. The fixture uses two lanes and 24 expert lines per layer, not the eight-lane capacity benchmark.
When both ranks have exhausted TP retirement victims, coordinate quiescence and destruction acknowledgment for incremental local graph reclamation before retrying admission. Preserve unrelated hot graphs while TP victims remain and fail explicitly only when neither rank can reclaim more.

Validated: combined EXL3 host build, 615 passed and 2 JPEG skips, including 90 Flash Next EXL3 tests; scoped Zig formatting and diff checks. Socket-pair regression covers asymmetric local caches and no-victim exhaustion. Hardware qualification of this new fallback remains pending.
Preserve the existing upstream draft history while incorporating workload-aware graph budgets, selective coordinated TP LRU eviction, and safe local reclamation when TP victims are exhausted.

Validated checkpoint ca2b13c: 90/90 EXL3 host tests, scoped formatting and diff checks. Combined agent host run: 615 passed, two JPEG skips. Changed-file lean findings unchanged at 107; whole-tree lean remains failing at 1762 findings. Full Linux sm_120 CUDA build and two-lane BF16 paged snapshot/graph fixture passed on the preceding d366 runtime with test compatibility fixes; new optimized native build and graph/eager capacity/performance/cache gates remain pending. No graph speedup is claimed.
Separate key-presence misses, pending/unready entries, returning evicted keys, widths, state orientations, paging epochs and allocation generations with fixed-size fingerprint counters. Keep graph equality and arithmetic unchanged; profiling is opt-in and does not claim allocation sizes or replay coverage.

Validated: standalone helper six tests; combined host suite 101/101 after prefixing helper names for the EXL3 host filter; scoped Zig formatting and diff checks. This candidate is not the runtime used for the passing ca2b13c GPU receipts and is not yet hardware-profiled.
Keep full attention batches when the complete old-block universe fits. Otherwise bound each paging/attention sub-batch by the worst-case disjoint block union, reject impossible configurations before launch, and include subdivision topology in retained graph shape compatibility. Preserve selection order, BF16 format and per-row attention arithmetic.

Validated: focused pager tests 10/10 and combined EXL3 host suite 101/101, including 18k/200k schedule arithmetic, boundary/overflow admission, adversarial disjoint selections, mocked dispatch offsets and graph shape hashes. No 200k CUDA/model, sub-batch GPU parity, snapshot or performance result is claimed for this candidate. The previously qualified native runtime remains ca2b13c.

@ashhart ashhart left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @BlivionIaG. A note while this is a draft, since it no longer rebases onto main (the first of 119 commits conflicts in 8 files after main's batch-code restructure and Living Weights changes):

  • Main's Flash Next CUDA already takes KV pages from the core pool (TF_FLASHNEXT_KV_PAGES), so a second BF16 paging system beside it won't land; paging should extend the core pool. Main also has the CUDA start-up budget and the shared prompt cache, which cover the reserve and much of the cuda_snap rewrite. CUDA graphs for Flash Next are new and welcome once they show a repeatable speedup.
  • Rules we'd hold the split PRs to: drafts can't be switched off when experts are offloaded (cuda_exl3_pass.zig, cuda_lanes.zig); TP=2 must be bit-identical to TP=1, not within a tolerance (cuda_exl3_heads.zig); new kernels under the kernel contract with records; far fewer env switches (about 60 new TF_FLASHNEXT_* now); files within 600 lines and lean clean (1375 new findings); no AI co-author trailers, no local user paths (tools/exl3_nsys_step_breakdown.py, the golden JSON); and the 1373-line report kept out of docs/plans.
    Small, separately-measured PRs on current main (graphs first) would be the quickest way in.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Thanks @BlivionIaG. A note while this is a draft, since it no longer rebases onto main (the first of 119 commits conflicts in 8 files after main's batch-code restructure and Living Weights changes):

  • Main's Flash Next CUDA already takes KV pages from the core pool (TF_FLASHNEXT_KV_PAGES), so a second BF16 paging system beside it won't land; paging should extend the core pool. Main also has the CUDA start-up budget and the shared prompt cache, which cover the reserve and much of the cuda_snap rewrite. CUDA graphs for Flash Next are new and welcome once they show a repeatable speedup.
  • Rules we'd hold the split PRs to: drafts can't be switched off when experts are offloaded (cuda_exl3_pass.zig, cuda_lanes.zig); TP=2 must be bit-identical to TP=1, not within a tolerance (cuda_exl3_heads.zig); new kernels under the kernel contract with records; far fewer env switches (about 60 new TF_FLASHNEXT_* now); files within 600 lines and lean clean (1375 new findings); no AI co-author trailers, no local user paths (tools/exl3_nsys_step_breakdown.py, the golden JSON); and the 1373-line report kept out of docs/plans.
    Small, separately-measured PRs on current main (graphs first) would be the quickest way in.

Hi this is indeed meant to be a draft that will be split into pr later, I still have some drafting related things to test and improve.
I have started to reduce the amount of env vars, it's mainly there in this draft to allow tuning and test, final PRs will trim them down to the essential.

@ashhart

ashhart commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. The per-part reviews are now on #1441 to #1446, and #1447 has its own. #1419 says that chain
replaces this draft, and today's re-push of the chain only added Windows build guards, so those reviews stand. This
branch no longer merges with main (17 files conflict), so we suggest closing it and continuing on the chain.

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