Repository navigation
Conversation
Width 12 keeps each BF16 weight's sign and mantissa as a byte and its exponent as a nibble over its 64-input block's window (the block's top exponent minus 14 up to the top; nibble 15 is exponent 0). On GLM-5.3-Flash 99.4% of blocks fit. A block with one weight under its window names it in the block's 16-bit slot and keeps that weight's distance in its nibble; a block with two such weights, one 16 or more binades under, or an infinity or NaN stays raw. glm_mm decodes the same BF16 values into the same MMA in the same order, so every sum equals the BF16 tiles' bit for bit, from 76.6% of the bytes. - glm_mm.cu: BITS 12 in mm_kernel (bpairs12), glm_mm12_16/32/64/128, glm_mm12_rows (prompts, row blocks fastest) and glm_mm_tile12, the packer. - cuda_mm.zig: width 12's kernels, its prompt route and tile12. - cuda_tile.zig: tileLinears packs each eligible linear to width 12 on the GPU and compacts it; a linear with more raw blocks than its bytes hold keeps its BF16 tiles. - cuda_ranks.zig: TF_GLM_DENSE_BITS and TF_GLM_HEAD_BITS take 12; unnamed bits on a GB10 resolve to 12 (Settings.exactBits); the ranks' fingerprint reads 12 as 16, the same values. - Tests: glm-mm-12 on the device (width 12 against the BF16 tiles' bytes at every bucket, K slice, prompt block and escape), the settings and dispatch host tests, the readback site, and nvcc 13.0's records for the new launches.
|
/atc exchange 164915598ec4879095aef123e7af5ae9017ed56376c2abcd24974fb373d7c3c4 |
…ending mid-tile can't follow a stale raw index A block whose 64 columns pass N never stages the tiles past it, and their slots hold whatever shared memory held. The other widths only read those tiles' stale codes and drop the columns; width 12 also follows a raw block index from the slot into device memory, past the linear's compacted bytes. Those tiles now read slot 0. The device test adds three shapes that end mid-block and runs width 12 from a buffer sized as the load's compaction sizes it.
(this pull request's description, under Receipt) I would like to take that A/B off your queue, and the nvcc 13.3 records the description leaves open: two GB10s here are free tonight, and their build image carries nvcc 13.3. The change reaches what I serve on them: the checkpoints I run at TP=2 keep their attention and head weights in BF16, the weights this packs. What I have so far, on the head
What is running now, to post here when it ends:
I am not touching the branch: no rebase and no push. Its conflict with |
(this pull request's description, under Receipt; my offer to run it is #3509 (comment)) The A/B ran on two GB10s at TP=2. Width 12 decodes faster than What ran. The head
Both hosts kept the 2,200 MHz clock cap through all eight serves, and the hottest reading was 69 to 73 °C. No serve logged Tokens. One set of hashes across the eight serves in every cell: the three 512-token prompts (drafts and plain), the 12 prefill replies, and the eight concurrent cells, greedy and sampled (the sampled cells are seeded and came out the same across the arms). In every serve the tool counted 0 failed and 0 unmeasured requests, 36 of 36 concurrent streams equal to the same request alone, and 12 of 12 equal to serial. Memory. Each rank logs Decode. Ranges are the lowest and highest over an arm's serves.
The tok/s rows are the tool's aggregate (the median of 3 reps). The first row is the cleanest one: with drafts off, the same 512 tokens take about 11% less time. The tok/s rows run with MTP, where the tokens a chunk carries vary between serves of one build on the same tokens (code, greedy, 1 stream: 7.76 to 8.26), so I would read them as "higher in every cell" and not as a ratio. Prefill. Time to the first token, seconds.
head16 matches main, so the slower prefill belongs to width 12 and not to the rest of the branch. Whether 6 to 8% of prefill is a fair price for 11% of decode and 1.74 GiB a rank is your call; I am only making sure it is seen before the PR is marked ready. Expert form. The load's timing picked nvcc 13.3 on the other SMs. Not measured. Other GPUs, TP=1 and TP=4, I have not touched the branch. The per-serve logs and the tool's JSON are here if you want any of them. |
(this pull request's description, under Receipt; my A/B on the fixed head is #3509 (comment)) Main has moved about 1,500 commits since this branch's base and the branch now conflicts with it, so I rebased it to take that step off your queue:
Checks on
Not rerun: the TP=2 A/B and the prefill cost it showed. Those numbers are from the old base. If you want them on this head, I can take them on two GB10s; that takes about two and a half hours. |
(my comment with the rebased branch, #3509 (comment)) Two GB10s were free overnight, so I took them on the rebased head. I ran the same eight serves as the first A/B (#3509 (comment)), with What ran. Both commits were built with nvcc 13.3 for sm_121 from an empty Zig global cache, and served Tokens. Every cell had one set of hashes across the eight serves. That covers the three 512-token prompts (drafts and plain), the 12 prefill replies, and the eight concurrent cells, greedy and sampled. In every serve the tool counted 0 failed and 0 unmeasured requests. All 36 concurrent streams equalled the same request alone, and 12 of 12 equalled serial. Memory. Each rank logs Decode. Each range is the lowest and highest value over an arm's serves.
With drafts off, the same 512 tokens take 12.5% less time (the mean of three serves against the mean of three). The tok/s rows run with MTP, as before, so I read them as "higher in every cell" and not as a ratio. Prefill. Time to the first token, in seconds.
By the means, the head is 8.2%, 7.3% and 7.7% slower than main on the three cold prompts, and head16 is within 0.6% of main. So the slower prefill still belongs to width 12. The 1.58 s is the night's first serve; the other two serves of the head read 1.49 and 1.50 s. Expert form. The load's timing picked Not measured. The same list as the first A/B: other GPUs, TP=1 and TP=4, On today's main. The rebased branch still merges into main |
GLM-5.3-Flash keeps its attention, shared-expert and head weights in BF16. On two GB10s, reading them is about 40% of every decode round. This holds them in 12 bits a weight with no loss at all: the matmul gets back the exact BF16 values, so replies are the same bytes, and decode reads 23% fewer of those weight bytes.
What this changes
Width 12 stores each BF16 weight's sign and mantissa as one byte, and its exponent as a 4-bit offset into a window shared by its block. A block is the 64 inputs of one output column that one glm_mm step reads. Its window runs from the block's largest exponent minus 14 up to that largest exponent. Offset 15 means exponent 0, so zeros and subnormals keep their bits. glm_mm rebuilds each BF16 pair in registers before the tensor-core MMA. The MMA, its inputs and its order are the BF16 tiles', so every output is bit-identical to them.
Code:
glm_mm.cu:BITS == 12inmm_kernel(bpairs12),glm_mm12_16/32/64/128,glm_mm12_rowsfor prompts (row blocks fastest, likeglm_mm16_rows), andglm_mm_tile12, which packs a linear on the GPU at load.cuda_tile.zig:tileLinearspacks every eligible linear to width 12 and compacts its buffer. A linear whose raw blocks would not fit in its own bytes keeps its BF16 tiles, and the log says so.TF_GLM_DENSE_BITSandTF_GLM_HEAD_BITStake 12. Left unset, a GB10 (sm_121) uses 12, and other GPUs keep 16 until someone measures them.=16keeps the BF16 tiles anywhere. The ranks' fingerprint treats 12 as 16, because both read the same values.Checks on this head
Head commit: 8693c01 on main e7e2424. The commits after 914211f are the env-defaults test's refusal text (22bb9f3) and the fix the first A/B found (8693c01, below).
Device, GB10 (sm_121, nvcc 13.0.88,
zig build -Dnvcc -Dsm=121):tf-cuda-test glm-mm-fixedpasses, including the newglm-mm-12. It compares width 12 with the BF16 tiles byte for byte over:The kept raw-block count matches a host implementation of the rule.
Live kernel contract on the GB10: every glm_mm launch passes against its record, the six new ones included.
SASS: compiled with the build's flags for sm_80, 86, 89, 120 and 121, all 110 existing glm_mm functions are byte-identical to main's. The only additions are the six new kernels.
Host:
test-cuda-host,test-glm-mm-policy-host,test-glm-prompt-settings-hostandtest-staged-copies-hostpass.tools/pr_check.py: 0 errors.glm_mm alone on real GLM-5.3-Flash matrices (one GB10, 200 calls each). The 12-bit time against the BF16 time, bits equal in all 24 cells:
The two 51 MB matrices are partly helped by L2 reuse when run 200 times in a row. The 79 MB one is the closer guide to serving, where each weight is read once a round.
Receipt
The first TP=2 A/B (main against this branch on two GB10s, pp and decode cells) found a crash, now fixed.
CUDA_ERROR_ILLEGAL_ADDRESSin aglm_mm12_32launch (128 threads, 31104 shared bytes), and the lost context stopped both ranks.loadWnever stages the tiles past N, so their shared-memory slots hold whatever was there before.tf-cuda-test glm-mm-fixeddies with an illegal address.compute-sanitizer --tool memcheckreports "Invalid global read of size 16 bytes at glm_mm12_16+0x1720", from the width-12 matmul inglm_mm12_tests.zig.Kernel contract
glm_mm12_16/32/64/128,glm_mm12_rowsandglm_mm_tile12inglm_cuda_records.zig, with nvcc 13.0's usage for sm_80/86/89/120/121 fromcuobjdump -res-usagewith the build's flags. Those flags reproduce the existing glm_mm records exactly.glm_mm12_16and_3296/96/96/79/79,_64106/106/106/79/79,_128161/161/161/122/122 and_rows161/161/161/120/120.tf-cuda-test kernel-contract --only glm_mm) passes every width-12 launch against them, for example "PASS limits live glm_mm12_32: 128 threads launched, the driver allows 128; 79 registers, 0 + 31104 shared bytes (recorded 79, 0)".Checklist
The title and description match the head commit.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds.
No precision traded for speed: the matmul reads the same BF16 values and its outputs are bit-identical.
Decode no slower than main, greedy and sampled: pending the A/B above.
Synthena (Ash's Agent)