Repository navigation
glm/cuda: TF_GLM_MOE_DIRECT=1 runs a decode window's EXL3 MoE without its row copies and put_slot (for #3570) - #3659
Conversation
|
The |
|
Hi @ultradaoto, thanks for the re-pins. The diff registers TF_GLM_MOE_DIRECT as a strict 0/1 flag that is off by default, keeps the top-k and combine bodies otherwise unchanged, and pins both new kernels to the paths they replace with planted controls; the two serving-source hashes are updated under gradient-serving.tsv. It applies to current main and every file is under the size limit. The GB10 contract receipts you posted cover the opt-in path. Nothing is needed from you.
|
|
A note for when this and #3776 meet, since both are open. #3776 turns In a local merge of the two I added The extra line changes the |
|
Thank you @ultradaoto. Nothing further is needed from you on this PR; the opt-in flag, pins and GB10 receipts are accepted. Noted for landing: if #3776 lands first, tf_glm_combine_tail needs its glm_pdl::enter() line and a fresh pin of glm_glue_rows.cuh. This PR can land first without that change. CI on this head fails some serving-hash pins against current main; refreshing them is mechanical and we will do it ourselves before landing.
|
95b2e27 to
504909a
Compare
|
Thanks @ultradaoto. As promised, we rebased this onto current main ourselves and refreshed the serving-hash pins for the files it changes, in one commit of ours; your commits are as they were. It is in the landing queue now; nothing is needed from you.
|
-- 2.43.0 -- 2.43.0
504909a to
22218be
Compare
|
I checked The trial merge against Rechecked Igor Lessio - AIFLOW LABS |
-- 2.43.0 -- 2.43.0 -- 2.54.0 (Apple Git-157) -- 2.43.0
22218be to
27de1aa
Compare
|
Thanks @ultradaoto. Nothing more is needed from you on this one. Main has moved since your push, with edits next to
|
27de1aa to
ef86ad1
Compare
|
I checked the #4460 CI train at zig build test-qwen3-asr-host test-chunked-write test-glm-exl3-prompt-host \
test-exl3-prompt-host test-gradient-serving compile-glm-native-open \
-Dcpu=apple_m1 -j4 --summary allThe Linux ARM64 GLM open path compiled. The planned GB10 PDL, launch-limit and kernel checks remain device work. Igor Lessio - AIFLOW LABS |
joshuaswarren
left a comment
There was a problem hiding this comment.
Read at head ef86ad134 (lab-side review, joshuaswarren's fleet).
The diff matches the #3570 spec exactly, and the kernel is bit-faithful:
tf_glm_combine_tailistf_glm_combinewith the last slot's load pointed attail + r * d— same slot loop order, same__fmaf_rnchain, samewts[r * slots + k]indexing including the tail's weight index. The sums are unchanged by construction.direct()'s gate is tight: opt-in env only,!prompt,l.exl3 != null,top_k == exl3.top_k,rows <= chunk_rows— decode-window EXL3 only, prompts and NVFP4 untouched as specced.fill'serror.BadWindowonlo != 0under direct is the right defensive check for the whole-window invariant.runSlotson flat picks reuses the same grouped kernelscompact()uses — the two memcpys are removed without touching expert math.TF_GLM_MOE_DIRECTregistered.glm/.flag(default off — opt-in first, the conservative answer to your question 1), contract records + the 375-line contract test carry the bit-equal evidence.
LGTM from this lane. CI all green at head. We can also run the SM120 single-GPU served A/B on our RTX box (TF_GLM_MOE_DIRECT=0/1 on one binary) and post it as a second receipt if a maintainer wants non-GB10 coverage.
|
The current zig build test-glm-exl3-prompt-host test-exl3-prompt-host test-environment-host \
test-gradient-serving compile-glm-native-open \
-Dcpu=apple_m1 -Doptimize=ReleaseSafe -j2 --summary allThis verifies the standalone host integration, including strict environment handling and EXL3 prompt behavior. The GB10 launch limits and TP3 decode comparison remain in the device receipts. Igor Lessio - AIFLOW LABS |
ef86ad1 to
aefdc24
Compare
|
I checked the updated head zig build test-glm-exl3-prompt-host test-exl3-prompt-host test-gradient-serving compile-glm-native-open check-native-cuda-host -Dcpu=apple_m1 -Doptimize=safe -j3 --summary allThe newest commit changes CUDA contract teardown order. That teardown still needs execution on CUDA. Igor Lessio - AIFLOW LABS |
… its row copies and put_slot (ashhart#3570)
aefdc24 to
f3eb913
Compare
|
Thank you @ultradaoto. 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. |
…fill #3659 (TF_GLM_MOE_DIRECT) sums a direct decode window with combineTail inside fill; this PR split fill into shared and combine. shared now stops after the shared expert on a direct window (no slot put), and fill does the combineTail there, so the direct path runs the same launches in the same order as on main. Paired prompt chunks never take the direct path.
…fill #3659 (TF_GLM_MOE_DIRECT) sums a direct decode window with combineTail inside fill; this PR split fill into shared and combine. shared now stops after the shared expert on a direct window (no slot put), and fill does the combineTail there, so the direct path runs the same launches in the same order as on main. Paired prompt chunks never take the direct path.
…fill #3659 (TF_GLM_MOE_DIRECT) sums a direct decode window with combineTail inside fill; this PR split fill into shared and combine. shared now stops after the shared expert on a direct window (no slot put), and fill does the combineTail there, so the direct path runs the same launches in the same order as on main. Paired prompt chunks never take the direct path.
For #3570, as agreed there: opt-in behind a strict 0/1 switch, off by default; the top-k kernel changed in place with one optional pointer; the new slot sum registered bit-equal to what it replaces; a direct byte check at every row count up to one chunk.
What
TF_GLM_MOE_DIRECT=1changes, in a GLM decode window whose routed experts are EXL3 (prompt chunks, NVFP4 experts and the default path launch exactly as on main):tf_glm_topktakes one more argument,int* flat. When it is not null, the lanes that writepick[r][k]also writeflat[r * top_k + k], the[rows][top_k]array the EXL3 grouper reads. Nothing else in the body moves;glue.selectpasses null unless the switch is on. One symbol, one body.cuda_exl3.runDirect, which iscompact's one-chunk call without its firstcuMemcpy2DAsync) and leave their slot rows where they write them.tf_glm_combine_tailsums those rows ([rows][top_k][d]fp32) and then the shared expert's row ([rows][d]fp32, read in place of slottop_k): the same__fmaf_rnchain from 0 in the same slot order astf_glm_combineover the slot rows. Soput_slotandcompact's secondcuMemcpy2DAsyncgo too. Two copies and one launch fewer per MoE layer, 45 layers a round.cuda_moe.directdecides once per layer: the switch, a decode window (not a prompt chunk), EXL3 experts,top_k8 and at most one chunk (1,024) of rows. A decode window's fill is always whole (Forward.ffn); a direct fill asked for rows from anywhere but 0 returnserror.BadWindowrather than read slots it never wrote.Registration:
TF_GLM_MOE_DIRECTis a.glm.flagrow inplatform/environment.zig(exactly0or1, other text refused by name when the family opens), a row incuda_env_test.zig's reader list, and a row indocs/environment.md. Read once at load (Modules.moe_direct, asTF_GLM_DSELis); a rank logs one line when it is on.glm_cuda_records.zigfortf_glm_topk(32 threads,__launch_bounds__(32)) andtf_glm_combine_tail(128 threads), nvcc 13.0's usage on sm_80, 86, 89, 120 and 121 fromcuobjdump -res-usageof a five-SM build ofglm_glue.cuwith the build's flags (the same recipe gives the file's existingtf_glm_router_tile,tf_glm_scores,tf_glm_lat_writeandtf_glm_pool_keysnumbers exactly).later_pendingastf_glm_router_tile's: I have no 13.2 or 13.3 here.zig/tests/cuda/contract_glm_moe_direct.zig, in the runner's family sets:tf_glm_topkwith flat picks: raw out, the stated rule checked by the test itself. On every prepared call, finite and planted NaN and infinities alike:flatequalspick's routed columns,pickandwtsare byte-equal to the launch withoutflat, the shared slot holds expert 288 at weight 1. On finite logits also the rule the kernel holds: in order, no unpicked expert's sigmoid + bias is above a pick's by more than 1e-5 against float64; experts with bit-equal logit and bias go to the lower id first (every row plants such a pair at the top); each weight is its sigmoid over the picks' sum times the scale, within 1e-5 of float64. Served at 1, 4, 32, 129 and 1,024 rows of 288 experts. Its control launches without the pointer and must go red at gate 3.tf_glm_combine_tail:replaces = "tf_glm_put_slot, the EXL3 slot-row copy and tf_glm_combine", raw out. The baseline is the old path exactly as main runs it: thecuMemcpy2DAsyncof the routed rows into slot rows,tf_glm_put_slotof the shared row,glue.combine. Served at every row count from 1 to 1,024 at 4,096 dims and 9 slots, so gate 3 is the byte check at every row count up to one chunk; gate 1 runs the same comparison on NaN, +inf and -inf planted in the routed and shared rows. Its control puts slot 0's routed rows in the shared row's place and must go red at gate 3.Checks on the branch as pushed (aarch64, a GB10, nvcc 13.0):
zig build -Dgpu=sparkbuilds;zig build test-cuda-hostpasses 6,829 of 6,863 with 33 skipped, and its one failure iscli_config_test'sserve --config: expand ..., which fails the same way on main on this host;test-kernel-symbols-hostandtest-kernel-contract(host) pass;pr_check: 0 errors, 0 new lean findings;git merge-treeagainst main25de9d7is clean.Device contract, on one GB10 (sm_121) with the server stopped:
tf-cuda-test kernel-contract tf_glm_topk tf_glm_combine_tail:Receipts: three GB10s cabled as a switchless ConnectX-7 triangle, TP=3, GLM-5.3-Flash EXL3, one build (
a437511plus this branch). Settings:--parallel 4 --kv-cache fp8 --decode-share 0.5,--drafterincoai/GLM-5.3-Flash-DFlash2 at 6cc6c481,TF_GLM_DENSE_BITS=8 TF_GLM_HEAD_BITS=8 TF_GLM_KDA_PAD=1 TF_ROCE=1(NCCL carries every gather here; the setting splits the drafter's MLP), greedy. Four starts in one session, in this order: unset, 1, 1, unset, each a fresh server with an empty window-cost cache. With the switch on, rank 0 logsTF_GLM_MOE_DIRECT=1: a decode window's EXL3 experts read flat picks, one slot sum. One number per start:TF_GLM_MOE_DIRECT=1TF_GLM_MOE_DIRECT=1tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0, code, median tok/stools/bench_concurrent.py --tokens 256 --reps 3 --temperatures 0 --levels 1,4 --alone --serial, code, 1 / 4 streams, aggregateAt one stream that is +1.6% over the 16 requests (59.30 against 58.37, the starts' means), +1.5% on
bench_openaicode and +1.2% on chat; at four streams the two settings are level within the starts' spread.Tokens: 13 greedy replies (8 prompts alone, 4 at once, one prompt of about 8K tokens) hash the same in all four starts, and the same as the 1.2.9 release's with these bits and no drafter.
Where the time goes:
TF_GLM_PROF=1with MTP drafts (--mtp-confidence 0.5, no drafter), so verify calls run 4 rows; four more starts, unset, 1, 1, unset. Each rank's mean over its 4-row verify calls (12 to 15 a start), ms:=1=1The call is 0.69 ms shorter on rank 0 (47.26 against 47.95, -1.4%), about as #3570 estimated; of that, 0.50 ms is in the MoE block's own parts (
routed-0.31,shared-0.20), the two copies and one launch a layer fewer. The 13 hashes of three of these starts match the release's too; the second=1start's hash run was cut short when a node's Ethernet cable came loose, after its profile had been taken.The branch is cut from
a437511, main just before40a46d6(a workflow change my token may not push). None of the files here changed betweena437511and main25de9d7exceptplatform/environment.zig,docs/environment.mdandCHANGELOG.md, which merge cleanly.