Skip to content

fix(qwen4): apr import and the CUDA loader refuse qwen4_exp by name - #7173

Merged
noahgift merged 4 commits into
mainfrom
feat/qwen4-exp-guards
Nov 16, 2026
Merged

noahgift merged 4 commits into
mainfrom
feat/qwen4-exp-guards

Conversation

@noahgift

Copy link
Copy Markdown
Member

What

Follow-up to #7171 (S1 of #7169). It closes the gaps the S1 review found.

  • apr import now refuses qwen4_exp. It used to map an unknown model_type to Auto, and the q/k-norm tensors then pointed it at Qwen3, so it could write a mislabelled .apr. Now refuse_qwen4_exp in import_include_01.rs refuses with the named message, called from apr_import, reading only config.json. No tensor read happens and no .apr is written.
  • The CUDA safetensors loader refuses it by name too. It used to fail with "missing hidden_size". The new non-gated helper qwen4_exp::check_config is called by both the CPU converter and SafeTensorsCudaModel::load.
  • One source for the message: a new crates/apr-format/src/qwen4_exp.rs. aprender-core cannot depend on aprender-serve, so both depend on apr-format. This adds an apr-format dependency to aprender-serve and one Cargo.lock line.
  • Wording: "nothing was loaded" becomes "no tensor data was read (headers may have been parsed)", which is accurate: the safetensors header is mmapped first.
  • classify_tensor: split into a prefix table, cyclomatic 14 → 6. A new test asserts that an unknown name returns None, so the "every index tensor classified" test cannot pass through a catch-all.

Measured (2026-11-16, head 4754355)

  • cargo test -p aprender-serve --lib qwen4_exp: rc 0, 7 passed. --test qwen4_exp_refusal: rc 0, 1 passed.
  • cargo test -p apr-format --lib qwen4_exp: rc 0, 1 passed. cargo test -p aprender-core --lib qwen4_exp: rc 0, 1 passed (the import refusal). The worker also ran cargo test -p aprender-core --lib import at e10490f: rc 0, 290 passed.
  • Red first: the import test failed before the fix (no refusal), and the CUDA helper test failed to compile before check_config existed.
  • cargo clippy --lib -- -D warnings on apr-format, aprender-serve and aprender-core: rc 0. cargo check -p aprender-serve --lib --features cuda: rc 0. cargo fmt --all -- --check: rc 0. scripts/check_lockfile_current.sh: PASS.

Known limits

  • The CUDA loader's own call is compiled under --features cuda but not run: no GPU test.
  • GGUF still defaults an unknown arch to Qwen2. No qwen4_exp GGUF exists.
  • tensor_names_fallback has no qwen4_exp row.

PRE-FLIGHT

  • GATE CHANGE: no. No guard, gate script or workflow changes.

ont-delta: none (no contract or ontology source edit)
Closes #7172
Refs #7169
keep-open: #7169 Qwen 4 master; S2 per-op parity and S3 end-to-end remain

🤖 Generated with Claude Code

noahgift and others added 4 commits November 16, 2026 17:41
…s by name

Typed Qwen4ExpConfig (all new indexer_/ngram_/ple_/hc_/output_gate/mtp keys),
tensor-family classifier over the real index, and a named refusal in the
safetensors convert path. Metadata only; no new op implemented.

Pmat-Ticket: PMAT-7169
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A new tests/*.rs is dark until a fragment names it.

Pmat-Ticket: PMAT-7169

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
apr import mapped an unknown model_type to Auto and q/k-norm evidence then
labelled it Qwen3; the CUDA loader failed with an unnamed 'missing hidden_size'.
Both now refuse with the shared text (apr_format::qwen4_exp, one source).
Wording: 'no tensor data was read (headers may have been parsed)'.
classify_tensor split into a prefix table (cyclomatic 14 -> 6).

Pmat-Ticket: PMAT-7169
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
S1 (#7171) landed as a squash; the branch side of qwen4_exp.rs and safetensors_infer_convert.rs is S1 plus this slice, verified blob-equal.

Pmat-Ticket: PMAT-7169

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@noahgift noahgift added the expedite OUT-112 expedite lane label Nov 16, 2026
@noahgift
noahgift enabled auto-merge (squash) November 16, 2026 17:30
@github-actions

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=7173 head=4754355c3d9adc2e8499ce94c3561ec1cc72e892 verdict=REFUSE class=Q1 arm_rc=1

Shadow mode: this records a verdict and merges nothing. A refusal
to arm is not a block (§13 adds zero rows to §7) — the pull request is
exactly as green as it was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

expedite OUT-112 expedite lane

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qwen 4 S1b: apr import and the CUDA loader refuse qwen4_exp by name

1 participant