Repository navigation
Conversation
…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.
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.