Skip to content

PMAT-3733: apr inspect --json shows every GGUF header key (qwen35.* was dropped by a parse allowlist) - #3744

Closed
noahgift wants to merge 3 commits into
mainfrom
fix/3733-inspect-all-gguf-keys
Closed

noahgift wants to merge 3 commits into
mainfrom
fix/3733-inspect-all-gguf-keys

Conversation

@noahgift

Copy link
Copy Markdown
Member

Closes #3733

What was wrong

apr inspect --json on a Qwen3.5 GGUF showed 24 of the header's 46 keys, and none of the 18 qwen35.* keys, so qwen35.context_length (262144) was missing. The cause was in the GGUF reader, not in inspect. GgufReader::from_bytes parsed a key only if it started with tokenizer., general., llama., qwen2., qwen3., phi., mistral. or gpt2.. It skipped everything else by length. qwen35. does not start with qwen3..

I traced the RosettaStone path: run_rosetta_inspect → RosettaStone::inspect_gguf → load_gguf_raw().raw_metadata. None of those layers filtered anything.

Fix

  • No key is skipped. Keys outside the allowlist are decoded into a new GgufReader::display_only_metadata, and raw_metadata is the union of both maps.
  • keep_all was deliberately not used here. The config accessors (context_length(), num_layers(), …) read metadata, and their values feed apr import. Widening metadata would give every unlisted architecture a config the import path has never seen. A test pins that the accessors are unchanged.
  • read_metadata_array is hardened. It now checks the array span before allocating, and uses the checked readers instead of data[..] indexing. Parsing instead of skipping would otherwise hand a hostile element count to Vec::with_capacity.
  • rosetta_json is split out. It is now its own function, so the --json document is testable.

Measured

On lambda, with the post-fix binary pinned by scripts/apr_bin.sh (apr 0.69.0 (336b7230b)). The header count comes independently from python gguf.

file pre-fix, apr 0.68.2 (reader/inspect code unchanged since) post-fix / header KVs
Qwen3.5-4B-Q4_K_M 24, no qwen35.* 46 / 46
Qwen3.5-0.8B / 2B / 9B Q4_K_M — 46 / 46 each
Qwen3.5-27B-Q4_K_M — 49 / 49
Qwen3-1.7B-Q4_K_M (control, already allowlisted) — 32 / 32

Every Qwen3.5 file now shows all 18 qwen35.* keys, including context_length 262144 and full_attention_interval 4.

Mutants, each red: skip restored; the union dropped; one prefix (quantize.*) dropped; the bounds check removed; a qwen35. filter in rosetta_json.

Suites:

  • cargo test -p aprender-core --lib -- format::gguf format::rosetta: 645 passed
  • cargo test -p apr-cli --lib -- inspect: 140 passed
  • clippy -D warnings on aprender-core and apr-cli: clean
  • cargo test -p aprender-contracts --lib: 1689 passed

AD-04 quorum: 3/3 PASS (docs/audits/quorum-PMAT-3733.json). The full record is in docs/roadmaps/entries/PMAT-3733.yaml.

Per the batching default this PR is not armed: it is for the cop to fold.

🤖 Generated with Claude Code

noahgift and others added 3 commits September 21, 2026 18:41
…r parsed only an arch-prefix allowlist

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ni-3.1-pro-low, gemini-3.8-flash-high)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=3744 head=9d19ed68851ba414f256ea1b97edb8a95bc1b480 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.

@noahgift

Copy link
Copy Markdown
Member Author

Superseded — this PR's content is already on main (operator 1-day PR rule triage, 2026-09-24).

Carrying commit: 8c7822f — release(0.69.1): batch 1 (#3772).
Evidence (measured against origin/main @aa7c6ef03): 359/359 added lines present on main; 9/10 files byte-identical (inspect.rs edited further on main). #3733 stays open for its own acceptance.

Branch is NOT deleted: fix/3733-inspect-all-gguf-keys @ 9d19ed688.

@noahgift noahgift closed this Sep 24, 2026
@noahgift
noahgift deleted the fix/3733-inspect-all-gguf-keys branch October 9, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:code Work is a code change (derived rule, #4159)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apr inspect --json drops every qwen35.* metadata key (context_length 262144, block_count, full_attention_interval…): 46 header KVs, 24 shown

1 participant