Repository navigation
glm cuda: DFlash2 reads complete prompt taps at TP>1 - #1623
Conversation
|
Thanks @BadAd84, the change is coherent and applies cleanly to main. Two things before it lands:
|
|
Thanks. Item 1 and the per rank tap comparison are in, the ABBA matrix is running now.
The matrix you listed (main vs this head, fresh boot ABBA, split / ring / gather, 2047 / 2048 / 2049 / ~8k / ~31k, prose / copy, 1 and 4 streams, greedy / fixed seed sampled, cache off, pinned model and drafter revisions) is running on the same 2 GB10s. I will post the hashes, logs and the acceptance / TTFT / throughput / memory tables when its all done Also merged main again (1ddac96); the only conflict was the test command list in |
|
Thanks @BadAd84. The code is right, and ask 1 is fully answered: the recording CUDA and NCCL test of the real |
|
The matrix is done: GB10 x2 at TP=2, 12 fresh boots in ABBA order (main, cand, cand, main for each of split, ring, gather), GLM-5.3-Flash-EXL3 4bpw with the DFlash2 4-bit drafter, FP8 KV, prompt cache off, main = 37a4a84 (ai-engine:upm37, build label 623cb3da762fc92e), candidate = b2c6cda. The prompts are natural text: prefixes of upstream's own docs at 1ddac96 (the eight prose-heavy files, 28,627 words, doc sha256 233b26ffe0b3946f), under a continue-the-document head (prose) or a repeat-verbatim head (copy), at 2047 / 2048 / 2049 exactly (straddling prefill_rows and dflash.WIN) and 8192 / 31744. Full tables: report below. Exactness. Candidate and base solo replies are identical at every prompt, greedy (temp 0) and fixed-seed sampled (temp 1.0, seed 1234): the tap write is a pure side output. bench_concurrent's own checks pass with zero failures on both arms: concurrent == solo (40/40 equal a prompt) and drafted == plain (20/20). Draft acceptance, the runtime view of the taps (the direct proof stays glm-tap-split-check from the comment above):
Base loses about 1.5 points under split and ring; the candidate recovers the gather level on both. Performance (each arm's geometric mean over the 20 prompt x sampling cells; a cell repeats within an arm to about 1 percent, so an arm difference is the drafts each tap set produces on that prompt, with identical replies):
One stream: 15 of 20 cells faster on the candidate (up to +7.3 percent), geomean +1.8 percent, and the candidate's split and ring sit at gather's level, which is what complete taps should do. Four streams: 12 of 20 cells faster, geomean -0.6 percent, and the whole of that is one cell (len2047_prose, greedy, -16.2 percent): with complete taps the drafter is more confident, it drafts 15 percent more tokens and accepts more of them, but the wider shared verify window at 4 streams costs more than the extra accepted tokens return on that prompt. Both gather arms (whose taps are complete by construction, on main as well) land at the candidate's value on that cell, 47.4 and 47.6 against the candidate's 48.0: the base's 57.2 is the outlier, a lucky draft sequence from the stale taps. The replies are identical; this is the confidence cut interacting with concurrency, not the taps. Section 4b of the report lists every cell. Peak device memory is identical at 85.0 GiB in all six (control, arm) pairs. Provenance (model revision, drafter sha256s, image labels) and the exact-head reply hashes are in the report. Full report (all tables: provenance, per-prompt lengths, exactness, acceptance, every performance cell, hashes)PR #1623 TP=2 prompt-tap qualification receiptRun folder: Two DGX Spark GB10 (rank 0 + rank 1, ConnectX-7 direct cable), TP=2, GLM-5.3-Flash-EXL3 4bpw, DFlash2 4-bit drafter, FP8 KV, prompt cache disabled, fresh-boot ABBA (main,cand,cand,main) per control. Hostnames and IPs are redacted; raw server logs stay in the run folder, not here. 1. Provenance
1b. Prompt lengths (server-verified)Prompts are prefixes of upstream's own docs at
2. Exactness (within each control)Replies equal = candidate vs base solo reply digests match (same control); the tap write is a pure side output, so within a control the main forward is byte-identical and replies MUST match. concurrent==solo and drafted==plain are bench_concurrent's own equality counts (equal / not equal), summed over that arm's boots, base then candidate.
3. Draft acceptance by arm and control (runtime evidence for the taps)The direct proof is
Expected: base split/ring show a negative 4. Performance (cold cache; ABBA)Each (prompt, temperature) cell repeats within an arm to about 1% (the same replies and the same drafts every boot), so a difference between the arms is the drafts each tap set produces on that prompt. The table gives each arm's geometric mean over the 20 cells, TTFT and prefill as medians; 4b lists every cell.
4b. Every cell: base -> candidate
5. Exact-head reply hashes (raw TP2 digests)Distinct solo reply digests per control/prompt/temperature (greedy = temp 0 has one; sampled = temp 1.0 has one per seed). Candidate and base produce the SAME set within a control.
|
|
Just FYI, we have 6 sparks currently dedicated to tensorfold speed improvements, we are attacking concurrency next and all the patches should stack. We have got single stream to approximately 85% of the speed we tweaked the mia-ai python tensorfold built, up from around 50%. Will keep working, as want to get our fleet all running on thw zig based engine (glm 5.3 flash tp3, DS 4.1 Flash tp2 and qwen flash next tp1) |
|
The matrix is in my comment just above yours - 12 boots, natural text, pinned revisions, acceptance back at the gather level on split and ring. Happy for you to rerun it on your pair as well. |
|
Thanks @BadAd84, this is a thorough receipt. Twelve fresh boots in ABBA order with pinned model and drafter, replies equal in every control, prompt and temperature, drafted equal to plain and concurrent equal to solo, and acceptance back at the gather level under both split and ring (0.6073 and 0.6080 against 0.6080). Peak memory and cold TTFT don't move. That's everything we asked for. The one slow cell at four streams (2,047-token prose, greedy, −16.2%) lands where both gather arms land, and gather's taps are complete on main too, so it's the old stale taps that were lucky there, not a slowdown. This is ready to land. |
ad65c84 to
3a4e008
Compare
With TF_GLM_PREFILL_REDUCE=split (the default) a split piece's glue posts only a rank's own rows of the residual and shares normed, never x, so the tap after layers 5/14/24/33/42 read stale rows for every row another rank owns: half of a prompt's drafter context at TP=2, two thirds at TP=3. Replies never change; draft acceptance does. Each rank now taps its own rows of a split piece (tapPieces; .local copies the owners' rows in first), and shareTaps hands the tap rows to every rank once the pass is done, through the relay that shares normed, at the taps' width (5 x 4096). The glue stays split. A chunk that ends before the drafter's window (dflash.promptRun) carries no taps, so a long prompt shares only its last window.
…ainst gather (review)
3a4e008 to
ff71538
Compare
|
Thank you @BadAd84. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
|
Thanks @BadAd84! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3 |
With TF_GLM_PREFILL_REDUCE=split (the default) a split piece's glue posts only a rank's own rows of the residual and shares normed, never x, so the tap after layers 5/14/24/33/42 read stale rows for every row another rank owns: half of a prompt's drafter context at TP=2, two thirds at TP=3. Replies never change; draft acceptance does. Each rank now taps its own rows of a split piece (tapPieces; .local copies the owners' rows in first), and shareTaps hands the tap rows to every rank once the pass is done, through the relay that shares normed, at the taps' width (5 x 4096). The glue stays split. A chunk that ends before the drafter's window (dflash.promptRun) carries no taps, so a long prompt shares only its last window. Upstream PR ashhart#1623 (ashhart#1623), cherry picked from commit 4b0dac0 onto the recipe stack unchanged. Origin: MiaAI-Lab/GLM-5.3-Flash-DGX-Sparks-1104@13f2464 patches/engine 0013-glm-cuda-DFlash2-reads-complete-prompt-taps-at-TP-1.patch sha256:82c33c5feb9953d8697a28075ec771cf2fcdcce05ea4a90c1195b9239b808711
… would be alone TF_GLM_PROMPT_PAIR refused every step while a drafter was loaded, so with --drafter (the recipe's DFlash2) a prompt never paired and its exchanges stayed exposed. A pair now carries the drafter's taps: - The twin (Pair.init's new `drafter`) holds the second chunk's tap rows, a chunk's worth of DFlash2 rows; the first chunk keeps taps_prefill. - Each chunk taps only when it reaches into the drafter's last window (prefillChunk's rule, dflash.promptRun). - pairBody taps each ffn piece on the side stream right after its glue there posts the rows (tapPiece: ashhart#1623's split rule, the rank's own rows; in-process ranks copy the owners' rows in first), and once both chunks' last sites are in, shares each chunk's taps on the main stream (ashhart#1623's shareTaps) while the side stream holds nothing else. - The drafter then ingests a's rows from taps_prefill and b's from the twin's (Drafter.promptFrom), in that order, as two chunks one at a time do; the MTP head's prompt rows stay skipped beside a drafter. The pass's kernels, their inputs and their order per chunk are pairing's own, and the taps are the same kernel on the same rows, so the drafter's context is the one an unpaired step builds. Origin: MiaAI-Lab/GLM-5.3-Flash-DGX-Sparks-1104@13f2464 patches/engine 0057-glm-cuda-paired-prompt-steps-beside-DFlash2-each-chu.patch sha256:238e9281a2be4e2e84136c8d17bd1bbd5a91565355ad73d02e40ba07ecdcc65a
DFlash2 reads stale prompt taps at TP>1
With
TF_GLM_PREFILL_REDUCE=split(the default), a prompt piece's glue is split across ranks - each rank applies the post for its own rows, then sharesb.normed(b.hiddenafter the last layer) and neverb.x. So a rank's residual is only current for its own rows, which is fine for the target as every layer just reads the sharedb.normed.But the DFlash2 tap after layers 5/14/24/33/42 reads
f.ranks[0].b.xfor every row of the pass, so each rank's drafter ends up ingesting a stale residual for the other ranks' rows - half its prompt context at TP=2, 2/3 at TP=3. (Verify windows aren't pieced, so their taps were always current.) Replies never change, as the verify only accepts the target's tokens - what suffers is draft acceptance after every prompt.The fix
The glue stays split. Each rank taps its own rows of a split piece (
tapPieces), then after the passshareTapshands the tap rows to every rank via the same relay that sharesnormed(relay.glued/splitGlued), at the taps' width (5 x 4096). Every rank runs the drafter's passes, so every rank needs every row. Unsplit pieces tap as before, and with.localexchange the owners' residual rows are copied in before the tap instead.A chunk that ends before the drafter's window (
dflash.promptRun'skeep_from) carries no taps at all, so a long prompt only taps and shares its last window. Nothing read those taps before either.No host test, as the defect needs split glue (i.e. more than one rank on separate GPUs). The check is the receipts below: acceptance comes up to exactly what
TF_GLM_PREFILL_REDUCE=gather(no split glue, so complete taps) gives on the same build, and replies don't change at all. A first version that glued the drafter's window whole got the same acceptance but cost 0.35 s of TTFT at 7.9k tokens - this one costs nothing measurable.Measured
3x GB10, TP=3,
Mia-AiLab/GLM-5.3-Flash-EXL3-4bpw-TensorFold@078455ffe6472f9a52fbc1139f58b9db2881b25c,--drafterDFlash2 at 4 bits,--kv-cache fp8,--prompt-cache-gib 0, 8 slots, 196,608 context, a fresh boot per cell, main7c0688951against this change on it, in ABBA order. Since rebased ontod33dcfc76- none of the 21 commits in between touch these four files.tools/bench_concurrent.py --levels 1,2,4,6,8 --temperatures 0 --reps 3 --tokens 256 --alone --serial, aggregate tok/s, two boots each:Long prompts, cold, 300 tokens greedy, accepted drafts a round from
/metrics:Every
--alone --serialcheck is equal and every reply digest is identical between the 2 builds. Short prompts gain less as the drafter's prompt context is short - the long-prompt rows are where the stale taps showed.Gates on this branch (
d33dcfc76+ 1):zig build check-native-cuda-host,compile-cuda-tests,test-cuda-hostall green,zig fmt --checkclean,tools/zig/lean_new.pyagainstd33dcfc76: 0 new.