Skip to content

[None][feat] Add a glm_kpool sparse attention config - #20811

Closed
ruocheng-nv wants to merge 1 commit into
NVIDIA:mainfrom
ruocheng-nv:feat/glm53-kpool-sparse-config
Closed

ruocheng-nv wants to merge 1 commit into
NVIDIA:mainfrom
ruocheng-nv:feat/glm53-kpool-sparse-config

Conversation

@ruocheng-nv

@ruocheng-nv ruocheng-nv commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Description

GLM-5.3-Flash's sparse-MLA layers build their glm_kpool backend inside the model (create_attention(..., sparse_params=GlmKpoolSparseParams(...))), so no sparse_attention_config names it and the engine resolves plain TrtllmAttention.

This PR only adds the config:

  • GlmKpoolSparseAttentionConfig in llm_args.py, added to the SparseAttentionConfig union. algorithm: "glm_kpool" is its only field. Like CSA2SparseAttentionConfig, the geometry comes from the checkpoint: to_sparse_params(pretrained_config=...) reads index_topk, index_kpool, index_kpool_always_select_tail and index_head_dim from the GLM-5.3-Flash text config (composite or flattened) and returns GlmKpoolSparseParams. The existing sparse registry already dispatches those params to GlmKpoolSparseAttention.
  • supports_backend is PyTorch only.

Nothing fills the config yet, so serving behavior is unchanged. A follow-up can have ModelConfig fill it for GLM-5.3-Flash so the engine dispatches to the same backend the layers use; that needs the hybrid-model sparse allow-list to accept glm_kpool and the vision tower to drop the config.

Generated files and approvals

  • tensorrt_llm/usage/llm_args_golden_manifest.json: glm_kpool added to sparse_attention_config.algorithm's allowed values (scripts/generate_llm_args_golden_manifest.py). Needs telemetry/privacy CODEOWNER approval.
  • tensorrt_llm/schemas/trtllm-serve-config.schema.json, trtllm-serve-disagg-config.schema.json: regenerated (scripts/generate_trtllm_serve_schemas.py).
  • tests/unittest/api_stability/references/llm.yaml: union annotation updated.

Test Coverage

  • tests/unittest/_torch/modeling/test_glm5_next_contracts.py::test_glm_kpool_sparse_config_lowers_the_checkpoint_geometry: lowering from the composite and the flattened config, backend support, and registry dispatch to GlmKpoolSparseAttention.
  • tests/unittest/usage/test_llmapi_config_capture.py: the new union arm is captured.
  • Local run on B200: 258 passed (test_glm5_next_contracts.py, usage/test_llmapi_config_capture.py, api_stability/, llmapi/test_trtllm_serve_config_schemas.py); generate_trtllm_serve_schemas.py --check is clean. These ran on a slightly older main with the identical change, because the local build predates the current main bindings.

PR Checklist

  • Please check this after reviewing the above items as appropriate for this PR.

GLM-5.3-Flash's sparse-MLA layers build their glm_kpool backend inside the
model, so there is no sparse_attention_config that names it. Add
GlmKpoolSparseAttentionConfig (algorithm "glm_kpool") to the sparse
attention configs. Like CSA2, it has no geometry fields: to_sparse_params
reads the indexer top-k, pool size, tail selection and key width from the
GLM-5.3-Flash text config and lowers to GlmKpoolSparseParams, which the
existing registry dispatches to GlmKpoolSparseAttention.

Nothing fills the config yet, so serving behavior is unchanged.

Signed-off-by: Ruocheng Jia <ruochengj@nvidia.com>
@ruocheng-nv
ruocheng-nv force-pushed the feat/glm53-kpool-sparse-config branch from 8f91ca3 to 4587521 Compare October 22, 2026 08:30
@ruocheng-nv ruocheng-nv changed the title [None][feat] Give GLM-5.3-Flash a model-level glm_kpool sparse attention config [None][feat] Add a glm_kpool sparse attention config Oct 22, 2026
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.

1 participant