Repository navigation
Conversation
|
This is a big piece of work, @drowzeys, thank you: full GLM-5.3 on four Sparks, drafted replies bit-identical to serial ones, and level with a tuned vLLM on the same checkpoint (24.6 against 23.9 tok/s on prose, 32.4 against 30.3 on code with DFlash2). It came in after tonight's 0.6.0 freeze, so it's a 0.6.1 review. One honest constraint: we have two Sparks, not four, so we can't run TP=4 ourselves yet. We'll start with the generic core you split out ( |
|
Thanks again for this, @drowzeys. An update to my note above: we'll try it on four Sparks, so we can run the TP=4 engine end to end ourselves, not just the generic core. We'll post what we find here. Your run logs and SHAs would still help us compare like for like. |
|
Thanks! Here are the run logs and SHAs: Versions
What's in the folder
If you're short on Sparks, the README there covers checking the rank protocol on one GPU: the |
|
Thanks. We've read the full PR. Decode and the 1M-context path are bit-identical to serial through the rank-order merge, and the EXL3 change keeps every existing caller's bits. The branch sits on 0.5.0, so we'll rebase it onto 0.6.1 ourselves, keeping your commits, with these changes:
As promised, we'll run it end to end on four Sparks and post the results here. Your run logs and token SHAs would still help us compare. |
A new family serving the full GLM-5.3 (753B, ~40B active) across four ranks, one per DGX Spark, with drafted replies bit-identical to serial ones and every rank computing the same bits. Core: --tp 1|2|4 (per-family CUDA_TP); NCCL all_to_all and all_reduce; a trellis row stride in the universal EXL3 experts kernel (gu_stride, default 0: unchanged); an optional tf_mtp request field. Family: config, four-way split rules, a rank reader over safetensors slices; a fused CUDA-graph forward with row-invariant kernels (MLA with RoPE on the 576-wide latent, the token-level top-2048 indexer, EXL3 linears and experts); MTP (merged cache refresh), DFlash2 and auto drafting; a fast prompt path (equal chunks, two micro-batches with overlapped all-reduces, optional cuda-exl3 grouped GEMM over a shared expert layout); optional RoCE one-shot reductions for decode windows. Tests: four ranks as threads on one GPU against real weights (reference agreement, verify windows == serial steps, sparse rows, wide prompt chunks, MTP / DFlash2 / auto == serial). Docs: docs/recipes/glm-5.3-full-tp4.md (how to run, GB10 node settings), design notes updated. Measured on four DGX Sparks (2.75 bpw EXL3, 32K context, T=1.0): MTP 24.6 prose / 27.3 code tok/s, DFlash2 23.0 / 32.4, prefill 773-783 tok/s at 8K; vLLM on the same checkpoint 23.9 / 30.3, ~755. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0193EEks8KJLoeL7wviSCo1h
… ring buffer, on-policy capture - DCP 4: KV positions interleaved over the ranks (p % 4), distributed tie-free top-2048 (local top-k, candidates gathered, the same global choice on every rank), all-gathered absorbed queries, every rank attends all heads over its own keys, log-sum-exp partials merged in rank order (RoCE all-gather for decode windows, NCCL all-to-all for prompt chunks). On automatically past 200K context. Decode windows stay exact (test: close to the replicated cache, windows == serial). Needles on four DGX Sparks: 128K / 512K / ~1M (966,562 tokens) pass. - DFlash2 drafter: a 4096-slot ring of its sliding window (memory and per-pass work no longer grow with the context; DFlash2 works with DCP). - Capture for DFlash2 training (TF_GLM53_CAPTURE_DIR): rank 0 writes the drafter trainer's sequence layout - fp8 target taps and the target's top-32 logits for every sampled row. - Load-time memory: the checkpoint reader is released before the caches allocate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0193EEks8KJLoeL7wviSCo1h
…torch.topk + sort), 4-byte scores on one rank Adapted from glm5_next's _select_rows. Exact vs torch.topk+sort on packed keys (ties, relu zeros); 3.6-7x faster per 128-row block (1.5 vs 5.4 ms at 128K keys). TF_GLM53_RADIX=0 restores the torch path. Design notes for prefill and concurrency work. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…orer) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…_taps checks .capacity) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
… chunk >= index_topk: no partials/merge) Bit-identical to one chunk + _merge. Measured per 2048-row half-layer: 32K ctx 5.39 ms default vs 6.29 ms one-pass (slower: half the programs); 128K ctx 16.18 vs 13.82 ms (2048,32,4,3) = 1.17x. Default unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…tch reuses the first's decoded dense weights glm_moe_dsa enables it (TF_GLM53_UNPACK_CACHE_MB, default 384; 0: off). Same bits (weights never change); saves one full fp16 unpack per dense linear per chunk (~1.3 s of unpack at a 32K prefill -> about half). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…bit-identical, up to 3x per shape on GB10) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…its) tensorfold/cuda/exl3/prompt_experts: prompt_routed(x, pick, wts, ex, out) for hundreds to thousands of rows in three launches a <= 4096-row chunk: - route: one block groups the pairs by expert into items of <= 112; - gate|up: per (item, 128 gate + 128 up columns), 16 warps, m16n8k16 with the decoded trellis tile as the A fragment over the item's rows staged once in shared memory (cp.async, bf16 -> fp16 in place, 3 stages); each expert's input rotation moves onto its weights (W_eff = diag(suh) H W_q: two mma against constant H16 fragments a tile, the H8 butterfly across a chunk's 8 tiles), decode of chunk c+1 interleaved with chunk c's mma, trellis L2 prefetch 3 chunks ahead; epilogue FWHT, svh, SwiGLU, suh_d, FWHT -> xd fp16; also zeroes out; - down: per (item, slab of 256-column blocks), items fastest so the out slab stays in L2; output FWHT, svh, routing weight, red.add.v4 into fp32 out. No dequantized weights and no rotated [pairs, D] inputs in memory. Design after MiaAI-Lab's GLM-5.3-Flash prompt kernels (Apache-2.0), decode from the universal experts kernel (after ExLlamaV3). GB10, synthetic GLM-5.3 rank layer (D 6144, I 512, top-8 of 256, 68/184/4 experts at 2/3/4 bits, mul1): R=4096 12.7 ms a call (gate|up 8.0, down 5.0) vs ~25 ms for cuda-exl3's path; relative error vs float64 7.5e-4 (routed 3.6e-4). experts_cx: prefill takes it under TF_EXL3_PROMPT_EXPERTS=1 (off by default). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…default off) prompt_routed(..., f16_acc=True) or TF_EXL3_PROMPT_F16_ACC=1: the down kernel adds the slots into an fp16 buffer with red.add.noftz.v2.f16x2 (half the atomic traffic, an L2 slab twice as wide), converted to out at the end. GB10, R=4096: down 4.99 -> 4.18 ms, but the fp16 -> fp32 conversion adds ~0.6 ms when out is fp32 (net 12.70 -> 12.41 ms); relative error vs float64 7.4e-4 -> 8.9e-4. Default stays fp32. New test: test_f16_accumulation_mode. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… measured neutral) route(..., by_count): experts with the most pairs first (an expert's items stay adjacent for L2 reuse of its weights), after MiaAI-Lab's prompt-experts-order idea. TF_EXL3_PROMPT_ORDER=1 to enable. GB10 R=2048/4096/8192 with mildly skewed routing: within noise (+-1%), so the default stays expert-id order. New test: test_item_order_by_count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…64K keys (radix loses there) One radix program a row: 1-16 rows x 128K keys 0.64-0.77 ms vs torch 0.17-0.24 ms (GB10); at 32K radix still wins (0.16 vs 0.22). Same picks either way. ~10 ms/round at 128K decode (23 selects/round). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KhJBmLNaYXWdzg38Dc49Ya
…State slots; Runner.prefill_chunk The fused kernels (_kv_write, _ik_write, _absorb, _qrope, _iq_rope, _attn_chunks, _index_scores, select) take a ROWS constexpr: off, the code is the old one exactly; on, row r reads its position and its stream's cache base from int32 device tables (fused.Rows), DCP 1 only. State(slots=N) stacks N streams' caches; State.view(s) is one stream for the one-stream kernels. Runner's prompt loop becomes chunks() + prefill_chunk(st, ...), so a concurrent fill takes a lone request's chunking. mtp_compute(last=...) picks each stream's last MTP row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
multi.GlmMultiDecoder: N cache slots, rounds that pack every live stream's [token + MTP drafts] into one verify window (N x (k+1) <= 16 rows: the lone request's RoCE reductions and tilings), a batched MTP chain over per-stream backlogs, prompts filled a chunk per round with the lone chunking, graphs keyed by window shape with per-row tables copied in before replay, rank 0 deciding and sampling, ranks 1-3 following ADMIT/FILL/ROUND/DONE one-shot messages. Engine: parallel=N -> Scheduler (concurrent=True), follow -> multi.follow, close(); DFlash2 not loaded with N > 1; DCP refused with N > 1. --parallel 1 is unchanged. Protocol after families/qwen3_5/cuda/multi.py; per-row positions/bases after MiaAI-Lab's GLM-5.3-Flash multi-stream patches (Apache-2.0: 0029, 0030, 0035, 0049). Tests (tests/cuda/test_glm_moe_dsa_multi.py, layers 0-3 + MTP): 2, 3 and 4 concurrent streams, staggered, greedy and seeded sampled, one prompt past index_topk - each reply equals the request alone; graphs; engine + Scheduler; memory flat over admit/finish cycles. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…(same bits) Decode windows (1-16 rows) of the EXL3 dense linear ran at ~180-200 GB/s on GB10. - transposed walk: the decoded tile is the mma's A and 8 rows of x its B, so up to 8 rows take one mma a tile and 32 accumulators (126 registers instead of 168-222: 4 blocks of 4 warps an SM, no partial second wave); x is loaded a step ahead. mma.m16n8k16 gives A@B and (B^T@A^T)^T the same bits, so outputs are unchanged. - the weights of a k step come as 16-byte ld.global.nc.L1::no_allocate loads a step ahead, staged per warp in shared memory (whole lines a warp instruction). - rot_in and the linear launch with programmatic dependent launch: the linear's first weight loads overlap rot_in. TF_EXL3_LINEAR_LOADS selects the path (0: the original walk, kept as the reference; default 35). tests/cuda/test_exl3_linear_loads.py checks every path against the original bit for bit and every row alone in windows 1..128; the decode benchmark is tests/cuda/bench_exl3_decode_linear.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… q_a+kv_a, wq_b+q_b, gate+up linear / rot_in take 1 to 3 layers of one input (same K, width, codebook and warps a block; each its own K splits): one rot_in launch (grid z = layer) and one linear launch whose blocks are the layers' blocks back to back. A layer's blocks do exactly what its own call does, so each output keeps its bits (test_group_same_bits). GLM-5.3 decode windows (fused.lins) run q_a+kv_a, the indexer's wq_b with q_b (q_b moves up next to it: select leaves b.q alone) and the shared expert's gate+up as one launch each. tune_groups, after tune_linears, gives a group one warps-a-block when the one launch times faster (CUDA graphs over 8 groups) than the layers one by one; the engine logs its picks. A MoE layer's linears at TP=4, rank 0 (synthetic 5-bit mul1, rot_in included, glue kernels between): 295 -> 223 us at R=3, 309 -> 229 us at R=8. Co-Authored-By: Claude Opus 5.5 <[email protected]>
While other streams decode, a prompt chunk goes TF_GLM53_FILL_LAYERS layers a step (default 8; 0: whole chunks) with a decode round between steps. Same chunk boundaries, rows, layers and kernels, only paused: rows wait in the prompt buffers, the two micro-batches' in-flight reductions are waited for at the pause. FILL carries the layer range. A prompt with no stream decoding takes whole chunks, exactly as alone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e windows up to 32 rows (Phase B) - fused.Buffers(decode=True): every window of the verify/MTP buffers is a decode window up to DECODE_ROWS=32 (RoCE one-shot / rank-order reductions, ATTN_DECODE tiling, full-width head buffers); prompt buffers unchanged. Measured row-invariant at 32 rows vs 8- and 1-row windows (target and MTP layer). - dflash.MultiDrafter (port of MiaAI-Lab 0027-glm-multi-dflash2, Apache-2.0): ring per stream, batched block pass and context updates, graphs per stream count / tap bucket; drafts equal the solo drafter's. - multi.GlmMultiDecoder: per-request serial/MTP/dflash/auto, per-stream depth and confidence cut, per-stream auto arm, prompt taps per stream, drafts computed on every rank; prewarm of 1..32-row verify windows. - engine: loads DFlash2 with --parallel > 1; mtp_mode per request reaches the scheduler. - roce: startup check also at 32-row windows. - tests/cuda/test_glm_moe_dsa_multi_dflash.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ong long) Unit: tests/cuda/test_exl3_prompt_experts.py 12 passed on a DGX Spark; fixed point vs fp32 atomics rel 5.9e-8, float64 error equal (7.44e-4 / 7.62e-4); two identical calls bit-identical in both deterministic modes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
…m); fixed-point slab width back to int64 4 Sparks prefill 8K/32K/128K: fp32 atomics 1044-1087/1035-1124/996 (not reproducible); slots 944/976/899; fixed point 917/944/867 (u64 red.add: 4 ops a float4, L2-atomic bound); fixed with fp32 slab width 879/840/830. slots16 halves the slot rows' traffic. Extension _v4. NOT YET RUN ON A GPU. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
… to -6% prefill) 4 Sparks, full GLM-5.3: identical requests at 8K / 16K / 32K differed run to run with fp32 red.add (greedy diverged at tokens 12-108); with slots16 every pair is identical (serial and DFlash2, 8K and 32K). Prefill 8K/32K/128K: 1000/969/952 tok/s vs fp32 red.add 1044-1087/1035-1124/996. Unit: tests/cuda/test_exl3_prompt_experts.py 14 passed (slots16 vs fp32 sums rel 2.07e-4, float64 error within the atomic path's bound). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
…; TF_EXL3_PROMPT_DET=slots16 for reproducible prompts Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
Conflicts: cuda/comm.py (our NCCL argtypes + upstream's timeout_s store), cuda/server.py (0.6.5 serves token-id prompts itself: ours dropped). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
…serve Four rank threads on one GPU (the CUDA tests) left 2.4 GiB free and the fixed 6 GiB reserve refused a ~0 GiB cache (tests/cuda/test_glm_moe_dsa_multi.py: 6 failures). 4 x 140K (47 GiB of 38 free) is still refused; 140K x 1 and 1M at DCP 4 still fit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
…eads share one GPU The 8192-row serving default (one rank a GPU), allocated four times in one process, exhausted a 128 GB DGX Spark (OOM panic) during tests/cuda/test_glm_moe_dsa_multi.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
…or four rank threads on one GPU test_glm_moe_dsa_fused.py exhausted a DGX Spark's memory (the node rebooted) with the 8192-row serving default. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
…d path (FILL_MIN_ROWS 0) Since 2595488 chunks under 2048 rows fill whole while others decode, so these short-prompt tests never paused ({'whole': 64, 'paused': 0}); long prompts still take the stepped path in production. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
SP prompts are on by default since ce69faa and the fake single-thread comm has all_to_all, which turned the two-micro-batch overlap on in a test written for the plain path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc
…_DCP=4): the full 1M window on TP4 Opt-in startup mode (every rank must agree; TF_GLM_DCP must equal the ranks). Each rank holds a quarter of every cache plane, so the window reaches the model's native 1,048,576 tokens. The design follows TensorFold PR ashhart#159 by drowzeys (dc43ca6), restated for this fork's kernels and cache formats (dcp.py): - Position p lives on rank p % 4 at slot p // 4 in every plane (latent, rope key, indexer keys, the MTP head's); the bf16, FP8 and Q writers store only their own rows. - Selection past the dense limit: each rank scores its own slots with the replicated scorer's arithmetic, keeps its top 2,048, the ranks all-gather those candidates as (score, position) keys and every rank takes the same global top 2,048: the replicated selection exactly (positions are unique, so the merge never ties). - Attention: the ranks all-gather every head's absorbed query; each rank attends all heads over the keys it holds (rows below the dense limit: every visible one; past it: its share of the selection), normalizes each head's partial and keeps its log-sum-exp; the partials go to the rank that owns the head and merge in rank order (decode: one all-gather; prompt chunks: grouped send/recv). Only held slots are read. - Admission counts a quarter of every slot plus the exchange buffers; the RDMA gather is sized for a decode window's partials; prompt chunks run without the micro-batch overlap under DCP. tools/tf_admit.py counts TF_GLM_DCP. Measured on TP4 with the Q5 cache and the embedding split: - tests/cuda/test_glm_dcp.py 21/21 (four ranks emulated on one GPU): the merged selection equals the replicated one token for token (bf16, FP8, Q8 indexer keys); attention over the four shares within 6e-3 of a float64 reference (bf16, FP8, Q8 latents; rows below and past the dense limit). - Drafted == serial (tf_bitcheck, 28,409-token prompt): serial == MTP-3. Replies have their own bits (the merge order differs from the replicated one), so the lane's gate uses a DCP serial reference. - Decode against replicated (tf_decode_depth): serial 18.47 vs 19.48 tok/s at 32k (-5.2 %), 17.99 vs 18.67 at 128k (-3.6 %); a round's verify forward +6.8-9.6 %. Prefill 289-307 tok/s against 449-451 (-32-36 %). - Admission: the full 1,048,576 window on every node (startup estimate 88.1 of 103.7-104.5 GiB a rank). - Lane at 1,048,576, MTP-3: greedy gate 4/4 against its serial reference, tf_bench passed, needles found at 130,909 tokens (prefill 305 tok/s, decode 29.2 tok/s), 523,777 (279, 28.6) and 1,039,064 (247, 24.5). - Default (TF_GLM_DCP unset) unchanged: tf_bitcheck identical to 835a68b (first token, every cache checksum, last hidden row, serial and MTP-3 tokens). CPU gate 119/119. Ported-from: TensorFold PR ashhart#159 (drowzeys, dc43ca6) fused._attention_dcp, _merge_lse, _dcp_combine, dcp_gather and its selection (THIRD_PARTY_NOTICES.md) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Independent four-Spark run of this PR, for @ashhart and @drowzeys: the three checks from the 2026-10-03 comment, plus speed, on our own cluster. We are not affiliated with the PR. The summary is below; raw outputs, all four ranks' logs and the scripts are available on request. Summary. All three checks hold whenever the prompt itself is reproducible. With default settings that means prompts of 128 tokens or fewer. Above that, the same request sent twice gives a different reply, Setup
Launcher:
# single stream (DFlash2 loaded); one boot adds TF_EXL3_PROMPT_DET=slots16
NODES="192.168.1.101 192.168.1.102 192.168.1.103 192.168.1.104" IF=<port> HCA=<rdma dev> GIDS="<per node>" \
IMAGE=<image above> CKPT=/models/GLM-5.3-EXL3-2.75BPW DOCKER_ENV="-e TF_GLM53_DFLASH=/models/GLM-5.3-DFlash2" \
tools/tp4_run.sh serve --context 36864
# concurrent: + -e TF_GLM53_CONC_MODE=dflash, serve --context 32768 --parallel 4Every request carried Prompts:
1. Drafted ==
|
| Settings | Prompts | Equal |
|---|---|---|
| default | 31-53 tokens, 3 prompts × greedy/sampled × MTP/DFlash2 | 12/12 |
| default | bench_concurrent.py ... --levels 1 --alone --serial, MTP and DFlash2 |
8/8 serial, 24/24 alone |
| default | 8K and 32K, prose and code × greedy/sampled × MTP/DFlash2 | 0/16 |
slots16 |
short + 8K + 32K, same matrix | 28/28 |
The 0/16 is not a drafting problem: two identical serial requests also differ (repeat table below).
2. Resumed conversation == fresh replay
This family has no prompt cache: cached_tokens was 0 on every request. A resumed turn therefore re-runs the whole conversation through prefill. We sent turn 1, then turn 2 ([user, assistant reply 1, user 2]), then an unrelated request, then the same turn 2 again. We also sent turn 2 as /v1/completions with the token ids from /tokenize.
| Settings | Conversation length | Resumed == fresh | chat == completions(ids) |
|---|---|---|---|
slots16 |
327 / 8,325 / 32,327 tokens × greedy/sampled × MTP/DFlash2 | 12/12 | 12/12 |
| default | 327 / 8,325 tokens | 0/8 | 0/8 |
We also tried a stricter test that is not in the contract: a token-level continuation. We sent the prompt plus the first 85 reply tokens as a new prompt and compared the continuation with the rest of the uninterrupted reply. On this PR it never matched (0/20). The harness is not the cause:
- Between 2 and 110 continued tokens matched the reply before it diverged, so the comparison offset is right.
- chat == completions(ids) was 12/12, so the token-id path and template are fine.
- MTP and DFlash2 gave the same continued sha, so drafting is not involved.
The reason is that the reply tokens are prefilled with prompt arithmetic, not the decode arithmetic that produced them. The README's prompt-caching section describes this: "the previous reply is prefilled again under the current prompt".
For reference, we ran the same continuation test on a single-GPU model that TensorFold already serves exactly: Qwen3.6-35B-A3B (MLX 4-bit + MTP, f84b054c), TP1, built from this PR's source with its prompt cache active (cached= in the done lines). It matched only 3 of 12 continuations (cuts 8 / 40 / 85, greedy and sampled, 53- and 1,568-token prompts; all 3 matches were the sampled 1,568-token prompt). Repeats of the full request matched 4/4. So this is general TensorFold behaviour, not a gap in this PR, and we don't count it either way.
3. Concurrent == alone (--parallel 4 --context 32768)
| Server env | Test | Alone equal | Serial equal |
|---|---|---|---|
CONC_MODE=dflash |
bench_concurrent.py --levels 1,2,4 --alone --serial (DFlash2 per stream) |
84/84 | 10/10 |
| same server | same tool, every request "tf_mtp": "normed/normed" (MTP) |
84/84 | 10/10 |
| same server | drafted vs "draft": false, short prompts |
12/12 | |
+ slots16 |
bench_concurrent.py as above |
84/84 | 10/10 |
+ slots16 |
4 different prompts at once (2 short + 2 at 8K), greedy/sampled × MTP/DFlash2 | 16/16 | |
+ slots16 |
2 × 32K prompts at once | 8/8 |
Reproducibility of the prompt (identical greedy request sent twice)
| Prompt tokens | 31-53 | 122 | 135-148 | 344-357 | 1.0K | 2.0K | 4.0K | 8.0K | 32K |
|---|---|---|---|---|---|---|---|---|---|
| default | equal | equal | differ | differ | differ | differ | differ | differ | differ |
slots16 |
equal | equal | equal | equal | equal | equal | equal | equal |
- Default settings: 0/45 equal from 135 tokens up, serial included. The first differing token was between 2 and 95.
slots16: 42/42 equal.
The boundary is fused.MAX_ROWS = 128. Up to 128 rows, a prompt's experts run through the row-invariant decode kernel. Above that, experts_part (fused.py:1071) uses the prompt-experts kernel with fp32 red.add. So "long prompts" in the PR description and recipe ("prompts longer than one chunk (~4K tokens)", "short prompts only") means more than 128 tokens, which is most chat turns.
slots16 cost us 1-6% prefill:
| Prompt tokens | default | slots16 |
|---|---|---|
| 4.4K | 779 tok/s | 887 tok/s |
| 8.7K | 1,022 | 961 |
| 17.4K | 1,054 | 1,022 |
| 34.6K | 1,135 | 1,082 |
The 4.4K default figure includes a slow first run (687 and 870 tok/s).
Across server restarts
Within one server process every check above holds. Across restarts, the same short prompt (≤ 53 tokens, so reproducible within a boot) gave a different reply in every pair of boots we compared:
- Our runs: our first boot against a boot with the same env and
--context 140000matched 0/18. Against theslots16boot (which does not touch ≤ 128-token prompts) it also matched 0/18. - Cause:
tune_linearspicks each shape's K splits from load-time timings, and the picks differ between boots. For example, rank 0's 3072x6144 linear got(1, 8)in one boot and(8, 4)in the next. A different K split is a different summation order. - With
TF_GLM53_TUNE=0, two separate boots gave identical replies: 18/18. The short-context MTP round went from 64.3 to 65.0 ms, about 1% slower.
Whether restart-to-restart identity is in scope is your call. The README scopes exactness to "the same engine, weights, runtime and settings", and tuned tiles make the settings differ per boot.
Speed (ours: 100 GbE switch; PR: 200 GbE)
These are the author's tfbench.py / ppbench.py and the in-tree bench_concurrent.py, all with the public incoai draft. Our context-32k.txt is Moby-Dick, and ppbench's 4.3 chars/token overshoots by about 8% on it.
Single-stream decode, tok/s (tokens per round, round ms):
| PR / author README | Ours, 100G switch | |
|---|---|---|
| 32K, T = 1.0, DFlash2, prose | 29.2 (2.20, 75 ms) | 27.2 (2.06, 75.9 ms) |
| 32K, T = 1.0, DFlash2, code | 34.5 (2.84, 83 ms) | 33.6 (2.82, 83.9 ms) |
| 32K, T = 1.0, MTP k = 2, prose | 27.3 (69.7 ms) | 26.7 (1.91, 70.5 ms) |
| 32K, T = 1.0, MTP k = 2, code | 29.9 | 29.9 (2.12, 71.0 ms) |
| short, greedy, DFlash2, prose | 31.4 (2.25) | 29.2 (2.14, 73.2 ms) |
| short, greedy, DFlash2, code | 40.2 (3.32) | 39.7 (3.34, 83.7 ms) |
| short, greedy, MTP, prose | 31.1 (62.6 ms) | 31.7 (2.04, 64.3 ms) |
| short, greedy, MTP, code | 35.1 | 34.1 (2.20, 64.6 ms) |
Our figures are medians of 3 repeats × prompts. The PR body's 30.6 / 37.0 come from the author's own fine-tuned draft and are not comparable. Round times match within about 1-3%. The prose gap tracks DFlash2 acceptance, which depends on the context text.
Prefill and TTFT (default settings):
| Prompt tokens (ours) | 4.4K | 8.7K | 17.4K | 34.6K | 69K | 130K |
|---|---|---|---|---|---|---|
| Ours, tok/s | 779 | 1,022 | 1,054 | 1,135 | 1,004 | 890 |
| Ours, TTFT | 5.7 s | 8.6 s | 16.6 s | 30.6 s | 69 s | 146 s |
| PR, tok/s (4K / 8K / 16K / 32K / 128K) | 922 | 1,044-1,087 | 1,089 | 1,036-1,124 | 996 | |
| PR, TTFT | 4.5 s | 7.5-7.8 s | 15.0 s | 29-31 s | 131 s |
Our 69K and 130K figures are single runs with --context 140000.
Four streams, aggregate tok/s, DFlash2 per stream:
| 1 stream | 2 streams | 4 streams (TTFT max) | PR, 4 streams | |
|---|---|---|---|---|
| chat, greedy | 37.8 | 54.0 | 69.0 (1.44 s) | 69.7 (README, public draft); 75.0 (PR, fine-tuned draft) |
| code, greedy | 54.3 | 74.4 | 91.8 (0.95 s) | 95.4 / 96.4 |
| chat, T = 1.0 | 36.4 | 50.8 | 64.5 (1.42 s) | 64.9 (fine-tuned draft) |
| code, T = 1.0 | 41.4 | 53.1 | 68.2 (0.88 s) | 68.7 (fine-tuned draft) |
With MTP per stream: chat greedy 34.2 / 50.2 / 67.6, code greedy 38.0 / 56.0 / 75.8.
Other observations
-
Cache-fit guard and page cache. Our first
--parallel 4 --context 32768boot was refused on rank 3:context 32771 x 4 streams needs 11.0 GiB of caches a rank, 14.1 GiB is free (keeping 6 GiB spare)Clean page cache from earlier runs counts as used memory on GB10. Rank 0 then waited in NCCL and logged
IBV_WC_RETRY_EXC_ERRinstead of exiting. Dropping clean page cache (vm.drop_caches=1) on the nodes while loading fixed it. The recipe currently suggests that only for 1M contexts. -
Load-line counter.
engine.py:123reusesnfor theshare_tilescount, so the load line prints that count as a layer count: rank 0 prints0 layers loaded, rank 3420 layers loaded. -
First-start TCPStore retry. On the first start, ranks 2 and 3 logged a c10d TCPStore connect timeout followed by a retry while rank 0 was still building
tensorfold_exl3_linear_v5. The retry succeeded and nothing else went wrong.
Everything above ran on 48c8196 source. We have not run the tests/cuda suites or the 1M / DCP path.
48c8196 to
689596d
Compare
|
Thank you, @drowzeys. Full GLM-5.3 on four Sparks, with drafted replies equal to serial ones and every concurrent reply equal to the same request alone, is a big piece of work, and the GB10 findings in your recipe help well beyond GLM. The Python engine is frozen (#286) and new work goes into the Zig engine, so this won't merge. The Zig engine has no GLM-5.3 family yet, and Zig CUDA runs only Nemotron so far. When GLM-5.3 comes to it, we'd carry over your radix-select indexer top-k, the sequence-parallel prompt chunks and every rank taking rank 0's tiles, with your credit. One thing would change there. The prompt experts would add their slots in slot order as the only mode, so a long prompt always gives the same reply. |
…rts over NCCL, byte gathers, peer exchanges Two-rank engines reach for faster or different transports (one-shot RoCE all-gathers on DGX Sparks, point-to-point exchanges for split work, ashhart#159's all-to-all), and each one is wired into one engine by hand today. This gives them one place to plug in: - Comm states what every engine assumes of a communicator (rank, world, all_gather, barrier). Module functions cover the optional capabilities, each with a fallback: fast_gather (a model exchange takes the communicator's all_gather_fast where there is one, else all_gather), exchange (NCCL.exchange: each send lands in the peer's matching receive, one ncclSend / ncclRecv group on the current stream; a communicator without exchange trades through its all-gather, two ranks only) and check (raise a failure the transport recorded). - Transport is a base that wraps NCCL and forwards whatever a subclass does not define (all_gather, store, ready, and later NCCL methods such as all_reduce or all_to_all), so a transport overrides only what it speeds up. - register_backend / open_comm: TF_COMM_BACKEND names a registered transport; unset (or nccl), open_comm builds the same NCCL as NCCL(...) does. The ranks compare the name through the rendezvous store and refuse to start with different ones (a transport on one rank only would hang the first exchange). NCCL stays the control channel. - NCCL gathers uint8, int8 and float16 too, and takes the rendezvous timeout and store key (defaults: 600 s and "tf_nccl_uid", as before). Same bits: nothing in the tree calls the new functions yet; NCCL's existing methods, and its constructor with the defaults, are unchanged. The next commit opens the two-rank engines through open_comm. Tests: tests/test_cuda_comm.py (CPU, a two-rank fake): fast_gather and check with and without the optional methods; exchange through the all-gather for float32, bfloat16 and int32 with unequal sizes, through a communicator's own exchange with the default peer and a named one, refused past two ranks without one; backends wrap NCCL, unknown names are refused, ranks naming different backends are refused; a Transport forwards store, ready and the all-gather. docs/recipes/cuda.md: the communicator paragraph.
Full GLM-5.3 on four DGX Sparks — TensorFold's first tensor-parallel-4 engine (on TensorFold 0.6.5)
This adds a
glm_moe_dsafamily that serves the full GLM-5.3 (753B, ~40B active) across four DGX Sparks(GB10, one rank per Spark, ConnectX-7 RoCE). Decode keeps TensorFold's guarantees: a drafted reply is bit-identical to
a serial one, every rank computes the same bits, and concurrent replies equal the same request alone. Prompts longer
than one chunk run the routed prompt-experts kernel, whose default fp32 atomic slot sums vary run to run;
TF_EXL3_PROMPT_DET=slots16makes them reproducible (see "Reproducibility" below).Based on v0.6.1 with TensorFold 0.6.5 merged in (conflicts in
cuda/comm.pyandcuda/server.pyonly; 0.6.5's owntoken-id prompts replace ours). Neither costs anything: an interleaved A/B of the v0.5.0- and 0.6.1-based trees measured
the same decode rounds, and the 0.6.5 merge matches the 0.6.1-based numbers below (32K DFlash2 29.2 prose / 34.5 code,
prefill 8K / 32K / 128K 1,045 / 1,115 / 1,000 tok/s, needles 32K / 128K pass).
Measured (four DGX Sparks, 2.75 bpw EXL3 checkpoint, default settings — no environment flags)
Decode, single stream (DFlash2 = incoai/GLM-5.3-DFlash2 fine-tuned on-policy against this checkpoint, depth 7,
confidence 0.3; MTP k = 2). 32K-token context, temperature 1.0 / top-p 0.95, 3 repeats:
Short context, greedy: DFlash2 32.8 prose / 38.6 code; MTP 31.1 / 35.1 at a 62.6 ms round.
Prefill / TTFT (single runs; boot-to-boot spread ~4-8%):
Needles (passphrase at half depth) pass at 32K and 128K.
Concurrency (
--parallel 4, 32K context, DFlash2 drafts per stream;tools/bench_concurrent.py --alone: every replyequal to the same request alone, 63/63):
Checkpoint: drowzeys/keys-GLM-5.3-EXL3-2.75BPW
(KL 0.124 nats / top-1 89.6 % vs BF16 over 65,536 tokens).
What changed since the previous revision
Prefill (~700 -> ~1,000-1,100 tok/s at 8-32K, 128K TTFT 262 s -> 131 s):
torch.topk+ sort; decode windows keeptorch.topk, which is faster at few rows).(2/3/4-bit per expert), both on by default; one-pass prompt attention; per-shape prompt GEMM tiles; an UnpackCache
so a chunk's two micro-batches share decoded dense weights.
Decode (78.5 -> 69.7 ms a round at 32K):
loads, PDL launches (same bits). Their tiles are tuned at load and every rank takes rank 0's tiles: tiles picked
per rank from load-time timings differed on most linears and the slowest pick paced every layer.
Concurrency (
--parallel N): streams decoded together with MTP or DFlash2 drafts per stream, decode windows up to32 rows; long prompts fill a few layers between other streams' decode rounds, short chunks (< 2048 rows) fill whole.
Robustness: the runner refuses a
--contextx--parallelwhose latent caches would not fit (on GB10's unifiedmemory an overcommitted cache swaps the node rather than failing);
--context 32768 --parallel 4fits, 140K x 4 doesnot.
Draft training support (opt-in):
TF_GLM53_CAPTURE_DIRwrites on-policy DFlash2 training data from the serve;TF_GLM53_CAPTURE_LABEL=1labels replayed replies at prefill speed; completions accept a token-id list as the prompt.Shared code touched:
cuda/exl3/linear*(grouped launches, tiles),cuda/exl3/prefill.py(prompt tiles,UnpackCache),
cuda/exl3/prompt_experts*(new),cuda/comm.py(reduce-scatter, grouped all-gathers),cuda/server.py(token-id prompts),cli*.py(--tp). Other families' EXL3 suites pass (see Tests).Tests (on four Sparks' GPUs, real weights via
TF_GLM53_CKPT, four ranks as threads of one GPU)test_glm_moe_dsa_{fused,prompt_sp,multi,multi_dflash,engine,weights,model,topk,attn_onepass}.py,test_comm_world4.py,test_glm_moe_dsa_split.py(CPU, all tensors at world 4): all pass.test_exl3_*,test_glm_exl3,test_qwen27_exl3,test_qwen4_exp_exl3):208 pass, 36 skip (checkpoints not present), 3 fail —
test_decode_matches_exllamav3_reconstruct[2-3/5/7], whichpredate this PR and come from the exllamav3 version in our test image.
hidden and accepts none with this checkpoint (the v0.5.0 tree too); drafted == serial is still asserted.
Reproducibility of long prompts
Identical 8K-32K requests diverged run to run (greedy replies after 12-108 tokens; every comm setting) because the
prompt-experts down kernel adds a row's top-8 slot outputs with fp32
red.addin arrival order.cuda/exl3/ prompt_experts*now hasTF_EXL3_PROMPT_DET:0(default, fp32 atomics, fastest),slots16(each slot's row storedas fp16 and summed in fp32 in slot order; rel 2e-4 vs the fp32 sums),
slots(fp32 rows),fixed(64-bit fixed-pointred.add: exact, but u64 atomics are L2-bound). Measured on four Sparks, prefill 8K / 32K / 128K tok/s:TF_EXL3_PROMPT_DET0(default)slots16slotsfixedtests/cuda/test_exl3_prompt_experts.py::test_deterministic_slot_sumschecks bit-identity of two calls and accuracyagainst float64 for each mode (14 pass).
GB10 findings worth knowing (in the recipe)
vm.compaction_proactiveness=0: proactive compaction migrated pages under the GPU and stalled a rank ~130 ms at a time.NCCL_MAX_NCHANNELS=2: with NCCL's default channels an all-reduce could not run beside compute on GB10.1M-token context (decode context parallelism 4)
Validated on the previous revision (needles at 128K / 512K / ~1M pass; decode 25.9 prose / 28.6 code at short
context with DCP on). Not re-run on this revision: the indexer top-k changes reach the DCP path too.
Not done
fine-tune is in progress.
Built and measured by @drowzeys on a four-Spark cluster; happy to split this up or change anything.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GxeDLuxcVa8Nsh6Knfhjvc