[Refactor] Pass GLM DSA top-k IDs explicitly - #1988
Conversation
9d80c69 to
9ba1c5f
Compare
|
Rebased this branch onto the current #1981 tip (`9d500b44`) — the SAC stack below was rewritten, so this branch had lost its base. New head is `9ba1c5f3`; the old one is preserved as `9d80c694` if you want to diff. What changed in your commits: only the deleted is exactly 6 lines, all of them Worth knowing if you rebase this again: That replays only your own commits (4 conflicting files, all of them the Checked: |
9ba1c5f to
de7b305
Compare
de7b305 to
d451a68
Compare
d451a68 to
d144b93
Compare
d144b93 to
bcf1db4
Compare
d237120 to
e4c4124
Compare
e4c4124 to
6929e00
Compare
6929e00 to
86beb77
Compare
86beb77 to
1f0e76c
Compare
Stack (bottom to top):
feat/sac-nonlegacy-base→mainfeat/sac-engine→feat/sac-nonlegacy-baserecompute_cfgand per-model recompute declarations (3/3) #1981feat/sac-recompute-cfg-v2→feat/sac-enginefeat/unify-offload→feat/sac-recompute-cfg-v2← you are herefeat/dsa-topk-selective-checkpoint→feat/unify-offloadSummary
This is the stack-compatible port of #1978. The explicit DSA top-k dataflow and offload design stay the same, while the integration is adapted to the non-reentrant and selective checkpointing APIs introduced by #1979–#1981.
torch.int32dsa_topk_idsexplicitly through GLM decoder layers, intra-layer micro-batches, and MTP, removing the mutableSequenceContextcache and manual cross-layer lifecycle runtime.xtuner/v1/model/moe/glm52/:GLM52AttnOutputs, GLM dense/MoE decoder layers, DSA MLA, and GLM MTP layers/blocks. Generic attention, decoder, and MTP APIs no longer expose DSA fields or parameters._call_decoder_layerextension point to the main MoE and MTP loops. GLM-5.2 overrides it to arrange DSA inputs/results and contain the saved-tensor offload window without duplicating the full decoder stack.Checkpoint-stack adaptation
TypedDictdecoder contract, list-based micro-batch API, and keyword checkpoint inputs instead of restoring the old reentrant-compatible flattened tuples.dsa_topk_ids; common outputs remain model-agnostic.Validation
xtuner.v1.model.moe.glm52package are included.Performance evidence from #1978
These measurements are from the original isolated implementation in #1978; this stacked port reran the functional coverage above.
Follow-up
PR #1989 keeps DSA top-k selection resident with selective checkpointing so backward replay does not recompute it.
Result
GLM-5.2 retains explicit, offloadable DSA top-k dataflow while the common attention, decoder, MTP, and checkpointing paths stay free of model-specific DSA APIs.