Skip to content

model-hf: a GLM folder's target load no longer plans the NextN tensors it does not use - #727

Merged
juliankang4 merged 3 commits into
midagedev:mainfrom
juliankang4:fix-glm-folder-nextn-refusal
Oct 23, 2026
Merged

juliankang4 merged 3 commits into
midagedev:mainfrom
juliankang4:fix-glm-folder-nextn-refusal

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

GLM 체크포인트 폴더를 target으로 열 때, target이 쓰지 않는 NextN tensor의 양자화 거부가 로드를 막던 결함을 고칩니다.

Part of #565. Tracked in #699.

What and why

Opening a GLM-5.3 checkpoint folder as a target failed when the quantization planner refused a NextN tensor, for example a NextN eh_proj.weight stored as U32. The target never reads NextN, so a refusal there should not stop the load. The folder open handed every tensor of the whole text model to the planner, NextN layers included, and returned the first refusal. The required-tensor check had the same reach and also asked for NextN tensors the target does not read. This came in with 146c130 (#519), which plans a checkpoint folder over N ranks.

Fixes in crates/model-hf/src/arch/glm5next.rs:

  • placed_map passes the planner only the layers of the geometry it is given, and open gives it the target trunk geometry. A refusal on a trunk tensor still fails the open.
  • The required-tensor check covers the requested geometry. A missing trunk tensor is still refused by name. NextN tensors that are missing or unreadable no longer block the target.
  • The checkpoint-name parsing that map already did moved into text_name and text_layer, so the map and the planner filter read the three accepted name prefixes through one function. GGUF blk.* names are not taken as checkpoint names.

The GGUF MTP path (NextnInputs::read) still checks NextN's count, attention kind and required tensors and is unchanged. The only production caller of the folder open is the GLM tensor-parallel plan, which already refuses BLOOMERY_DRAFT=mtp, so this adds no NextN support for folders. The existing NextN-missing test stays: under the full geometry the planner and the required-tensor check still refuse a NextN problem, and the same fixture opened as a target gives the same rank bytes as before. The narrower check scope carries a dated PIN comment.

The Qwen folder open is a separate path and is not touched here.

Code shape

  • No second copy. The folder-name parsing has one owner, shared by map and the planner filter.
  • Model code holds only architecture facts. The change is in the GLM architecture file and adds no flag or option to a common owner.
  • Dead code is gone. Read::all and the geometry required used to return are removed, since nothing needs them now.
  • No silent failure. A planner refusal on a trunk tensor and a missing trunk tensor are still named errors.
  • Comments state what is true now.
  • No relaxed gate. The NextN-missing check is kept under the full geometry. The narrower scope of the required check carries PIN(2026-10-23): and its reason.
  • cargo fmt is clean on the file (rustfmt --edition 2024 crates/model-hf/src/arch/glm5next.rs, and git diff --check). I did not run cargo clippy for this change.

Duplication found or removed (path:line): none. The two checkpoint-name parsers in other crates (crates/model/src/fixture/plan.rs:222, crates/model/src/arch/classify.rs:46) only accept GGUF blk.* names, so text_layer does not reuse them.

What I ran

FAIL first, on the commit that adds only the reproducing test to main, on a DGX Spark:

RUSTFLAGS="-C target-cpu=native" cargo test -p bloomery-model-hf --lib a_target_opens_when_only_nextn_quantization_is_refused -- --nocapture
test arch::glm5next::tests::a_target_opens_when_only_nextn_quantization_is_refused ... FAILED
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 32 filtered out; finished in 0.15s

The failure is the U32 planner refusal on the NextN tensor reaching the target open.

On the head, on a Linux machine, with the target directory rebuilt from this head:

RUSTFLAGS="-C target-cpu=native" cargo test -p bloomery-model-hf --lib arch::glm5next::tests:: -- --nocapture
test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 24 filtered out; finished in 0.59s

The new test covers a target that opens when only a NextN projection or expert is refused (the full geometry still refuses it, and every part of the opened target is read), the same U32 on a trunk attention projection or expert (the target refuses it), and all three name prefixes. The existing GLM folder tests, including the N = 1, 2 and 4 part match against the GGUF, pass.

Not run: the PR's other checks (lint, cargo clippy, the workspace-wide tests and GPU gates). This change touches no GPU code, public signature or device arithmetic.

What I ran into

This does not block the PR. A new HF folder draft caller would need the full geometry with the strict planner so that a NextN refusal reaches its draft choice; no such caller exists today.

Hardware

No GPU path changes. The tests are host-only and ran on a DGX Spark (FAIL first) and a Linux machine (head).

Release notes: Fixed: A GLM-5.3 checkpoint folder opens as a target even when a NextN tensor it does not use is refused by the quantization planner.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CLEAN: Target loading excludes unused tensors and preserves named failures for required trunk tensors.

Non-blocking

⚠ Reusable diagnosis: crates/model-hf/src/arch/glm5next.rs:1422. The planner-refusal probe lives only in the unit test. Expose it through an existing checkpoint tool or record, or explain why the named load errors provide sufficient diagnosis. This keeps real-folder investigations from rebuilding the probe.

Checked

Duplicates: 3 new functions checked; no duplicate requiring another owner. The existing module classifier also accepts mtp.; GGUF layer parsers accept a different namespace. Dryer reported 0 pairs.
Complexity: crapper flagged no changed functions.
Silent failure: 2 parsing/fallback sites followed. Unprefixed names are supported; malformed layer names reach a named mapper error.
Tests: static mutation review of all 3 added or changed tests. Removing either planner filter at crates/model-hf/src/arch/glm5next.rs:452 breaks the new successful-open cases; suppressing required-tensor errors at line 714 breaks the completeness assertions; dropping a mapped trunk tensor at line 734 breaks the rank test's tensor-set comparison.
Gates: the narrowed completeness check carries PIN(2026-10-23) and its reason; full-geometry NextN completeness remains tested. No numeric bands or lint levels moved.
Adversarial checks: trunk quantization refusal, missing boundary-layer tensors, malformed layer indices, and vision-only tables remain named errors. The production caller rejects MTP for folder TP loading. Qwen resolves refusals only for mapped sources.
Performance: folder loading only; no decode, prefill or kernel path changed.
Escape catalog: no C1–C4 pattern matched.

Notes

Tests were not run in this review. The PR reports a FAIL-first reproduction and 9 passing GLM tests. It carries no GPU gate evidence.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 7a1bb92 into midagedev:main Oct 23, 2026
7 checks passed
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