Repository navigation
Conversation
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
Qubitium
force-pushed
the
upstream/31-glm-flash-native-calibration-20261108
branch
from
November 9, 2026 09:55
a2140ac to
d9c7040
Compare
Qubitium
reviewed
Nov 9, 2026
Qubitium
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed against current main.
The Flash adapters stay distinct from the full-GLM path, which is the important invariant:
glm5_flash_coreloads the non-mHC source, remaps native names, owns the checkpoint buffers, and keeps the KDA head slicing and shared-down SwiGLU clamp native. The staged mHC replay is asserted byte-exact against the native decoder.glm5_flash_mtp.aligned_inputsuses the unweighted mHC stream mean followed bytarget_normatt, pairs with tokent+1, and uses the shifted-token positiont+1. Because positions are shifted, the position-zero embedding mask correctly does not fire for the first pair — the test pins that behavior so it is not "fixed" into the full-GLM convention.FlashMTPDecoderis a plain residual decoder with its own full indexer and the checkpoint's clamped MoE;load_mtpextends only the three GLM schedules, requires exactly one prediction layer, and validates every envelope tensor as BF16 with exact geometry.GlmFlashMTP.forward_alignedappliesshared_head.normexactly once before the shared target head.
Cleanup only: import ordering and dict(...) → literals.
Validation: ruff check clean; pytest tests/test_glm5_flash_core.py reports 8 passed.
Qubitium
marked this pull request as ready for review
November 9, 2026 09:55
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.
Summary
Carry hybrid KDA/sparse-attention stage boundaries, bounded KDA execution, hyperconnection continuation, original native checkpoint names, and aligned Flash MTP source loading.
This is layer 31/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3610. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream
main.Incremental change: 5 files, +570/−0 lines, including carried tests and the mechanism reference. No merge is automatic. Review value and API shape first; substantial rework can follow that feedback.
Flow and existing-code boundary
flowchart TD S0["GlmFlashBF16Source"] M0_0["GlmFlashBF16Source.__init__"] M0_1["GlmFlashBF16Source.materialize_block"] M0_2["GlmFlashBF16Source.materialize_routed_experts"] S1["bounded_kda"] S2["staged_forward"] S3["GlmFlashMTP"] M3_0["GlmFlashMTP.__init__"] M3_1["GlmFlashMTP.forward_aligned"] E["ValueError"] S0 -. "exposes" .-> M0_0 S0 -. "exposes" .-> M0_1 S0 -. "exposes" .-> M0_2 S0 -->|"raises on rejected input/state"| E S3 -. "exposes" .-> M3_0 S3 -. "exposes" .-> M3_1 style E fill:#fee,stroke:#b22gptqmodel/utils/glm5_flash_core.py:76:GlmFlashBF16Sourcegptqmodel/utils/glm5_flash_core.py:49:bounded_kdagptqmodel/utils/glm5_flash_core.py:267:staged_forwardgptqmodel/utils/glm5_flash_mtp.py:70:GlmFlashMTPCommitted reference: docs/glm-flash-native-calibration.md, linked from README. Class entry points/calls and rejected-state paths describe code present in this branch, rather than planned integrations.
Validation
Carried test files:
tests/test_glm5_flash_core.pyThis packaging pass checked Python parsing, whitespace, dependency order and balanced Mermaid blocks. The author reports successful prior use of these features. Per the requested resource limit and feedback-first scope, existing model quantization, GPU/ROCm tests, heavyweight CPU workloads and full model benchmarks were not rerun; no new performance or model-accuracy claim is made. Tests accompanying earlier stack layers retain their previously reported results.
Existing model support: upstream already supports this GLM/DeepSeek family. This proposal adds calibration/MTP/recovery capability; it does not add a competing MODEL_MAP registration. Native Transformers blocks and upstream model plans remain the integration basis.