Skip to content

train 1121190609: #3949 #4210 (CI only) - #4417

Closed
ashhart wants to merge 11 commits into
mainfrom
lead/train-1121190609
Closed

ashhart wants to merge 11 commits into
mainfrom
lead/train-1121190609

Conversation

@ashhart

@ashhart ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

CI for a landing train: #3949 #4210 stacked on main in that order. Nothing merges from this PR: each PR above lands on its own once this tip is green, and this PR is then closed.

bjornmonnens and others added 11 commits November 21, 2026 19:06
…s, state and snapshot plans (#3063)

Full GLM-5.3 keeps 79 latent caches (78 DSA layers and the MTP layer) of
576-value rows (kv_lora 512 and qk_rope 64), a pooled key a row and no KDA
layers. config.zig reads qk_rope_head_dim into Config.rope (still refused
unless 0 for GLM-5.3-Flash) and latentRow() is kv_lora + rope. cuda_state's
Shape carries the cache count, the row width, the index key dims and the
pool size (Config.kpool) that pages, a State's arena and onPages lay out
from, and the snapshot plan takes its latent and pooled spans from the same
shape; its parts hold up to 79 caches instead of max_layers' 47. The KV host
gather's row bytes follow latentRow(). GLM-5.3-Flash's 12 caches of 512
values and pools of 4 give the same 13,056 bytes a row and the same plans.
…arameters (#3063)

Full GLM-5.3 scores every index key (no pooling, top 2,048 over the whole
history) and ropes the first 64 dims of its index keys and queries in
interleaved pairs. cuda_sparse.Geometry carries the pool size, the pools a
row keeps, the roped dims and their fp32 frequencies; dsa_block.Index holds
one, set from Config.kpool and index_topk (GLM-5.3-Flash: 4, 512, none).

The kernels take the pool size where they divided by 4: tf_glm_scores,
tf_glm_index_scores (a page's pools become 512 / pool), tf_glm_select_rows
and its wide form, tf_glm_index_pools, tf_glm_dsel_scan and _merge, and
tf_glm_dsa_tokens (pool K tokens and a tail of pool - 1). tf_glm_pool_keys
keeps its gated softmax for pools of 4; pools of 1 store each LayerNormed
key as written and read neither gates nor ape, so scoring pool 1 is scoring
every key directly. tf_glm_index_write ropes its LayerNormed key below
`rope` before the bf16 store, and both score kernels rope the query
fragments they load (glm_index_rope.cuh; the angle's sincosf out of line).
A State's index key rows come from Shape.keys (index_ring, or maxInt for a
whole sequence) and its rebase keeps whole pools of State.pool. Every
existing call passes GLM-5.3-Flash's values, so its launches compute the
same bytes.

The emulator (test-glm-index-emulate) adds pool-1 scores, paged at 512 keys
a page, with queries roped on 64 dims against a model that ropes them
itself, and pool-1 top-2,048 picks through tf_glm_index_pools and the
decode select. The GPU contract and check launchers pass the new arguments
at GLM-5.3-Flash's values, and nvcc 13.0's records follow the six changed
launches (tf_glm_pool_keys, tf_glm_scores, tf_glm_index_scores,
tf_glm_select_rows, tf_glm_dsel_merge, tf_glm_dsa_tokens).

The contract also runs full GLM-5.3's values on these kernels
(contract_glm_full.zig): tf_glm_scores at pools of 1 with 64 roped query
dims against float64, allowing the roped queries' bf16 rounding;
tf_glm_index_scores bit-equal to it; tf_glm_dsa_tokens at pools of 1; and
tf_glm_index_write's LayerNormed keys roped on 64 dims against float64. Four
planted controls go red: queries or keys left unroped, keys read as pools of
4, and token lists one position late. A score's -inf (a pool the row cannot
see) is checked exactly.
… the mla image (#3063)

Full GLM-5.3 keeps 64 roped key columns past its 512-value latent and splits
each 256-wide q head into 192 latent-path dims and 64 roped ones. The DSA
block's Layer carries rope (Config.rope, 0 on GLM-5.3-Flash) and its fp32
frequencies; row() is lw + rope and qHead() qk + rope, which size the kv_a
and q_b widths, the latent and absorbed q rows, their scratch and the token
lists' page rows, and the softmax scale is 1 / sqrt(qk + rope) (1 / 16 on both).

A roped row takes cuda.mla's image (loaded only when Config.rope is set): its
GPT-J rope turns k_pe at pos + r into the latent row before the cache write
and each head's q_pe into qa past the absorbed latent; the chunk tiles are
tf_mla_chunks_r16 (chunks_wide<16, false, 64>), now launched on pages and over
token lists through Mla.chunksOn as GLM's own chunks are. Roped rows keep 16
heads a block in prompt chunks too: wide_smem<32, 64>() is 113,408 bytes, past
the 99 KiB a block may take on sm_86 to sm_121. The merge and expand_v stay
GLM's (the values are the latent's). The one new kernel is tf_mla_absorb_q_192
(tf_mla::absorb_q<192>, q rows 256 apart, qa rows 576), under the contract with
a planted control and nvcc 13.0 records (72 registers on every SM).

A page is padded to whole 576-wide rows and whole token bytes (their lcm), so
a token list's page rows stay whole: full GLM-5.3's 79 caches take 4,096 bytes
more a page (49,440 rows). GLM-5.3-Flash's page, buffers, kernels and launch
arguments are unchanged, pinned by host tests at both shapes.
Main 7948cc4 routes GLM launches through cuLaunchKernelEx.
Forward that entry through main's pdl.forwardEx in the new recording fixtures and keep the merged code in zig fmt style.
First world-4 Flash Next receipt on HIP: Qwen3.8-Flash-Next-MLX-oQ2-MTP
at --tp 4 on four Radeon AI PRO R9700, with a same-binary world-2 control
run isolating the world effect. Decode 122.9 tok/s, concurrent code
123.8/242.0, chat 103.5/205.2, cold prefill 1412/1358/1263 tok/s; all
alone and serial comparisons equal. Refs #2401.
Point the build note at provenance.json (build.log is the build's quiet
output), reference #3608 for the tp 2 receipt until it lands, and
regenerate the README.md line in SHA256SUMS.
@ashhart ashhart closed this Nov 21, 2026
@ashhart ashhart reopened this Nov 21, 2026
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Stopped at #3949: it moved after it was stacked.

@ashhart ashhart closed this Nov 21, 2026
@ashhart
ashhart deleted the lead/train-1121190609 branch November 21, 2026 20:32
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