Skip to content

Record fail-closed MiniCPM tokenizer evidence - #660

Merged
justinchuby merged 3 commits into
mainfrom
justinchuby-exact-minicpm-gguf
Aug 27, 2026
Merged

justinchuby merged 3 commits into
mainfrom
justinchuby-exact-minicpm-gguf

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • pin bounded 16 MiB GGUF headers and official tokenizer assets for MiniCPM-2B and MiniCPM3-4B
  • record ordered vocabulary, score, token-type, source-merge, special-ID, tensor/qtype, and chat-template identities
  • bind both routes to 444-case multilingual/adversarial/special-token oracles at llama.cpp@8d9af256337d1a501250f9bbf4c0859a654bddd6
  • keep the legacy non-BPE pre=default combinations architecture-scoped and fail closed; the generic default census route remains deferred-compiled-semantics

Disposition

Route Artifact Source Oracle Result
MiniCPM-2B mzwing/MiniCPM-2B-sft-bf16-GGUF@121e7290609857006939fca0ec64981009b806b9, Q2_K 9e87235097895a22894c32a1e211f94b93b798d715cc7d99c8e846637927fd13 openbmb/MiniCPM-2B-sft-bf16@4ec16344ac13e6ef5010aeecaa533369ac8eb53c 18/444 mismatches fail closed
MiniCPM3-4B openbmb/MiniCPM3-4B-GGUF@816dc79b35f92827e0d2d87aacea3567e49661a8, Q4_K_M 64913247e927414ecf47fd3e9ea8e3f0c9acae293f583dfa7e24b8872e20fa4c openbmb/MiniCPM3-4B@d6b14ddaefdb11c624dd75c3c779549bc90b08cb 9/444 mismatches fail closed

Both GGUFs flatten scores to -1000, omit the official BPE merge tables, alter token types, and carry divergent chat templates. The first oracle mismatch is standalone 你好,世界!: MiniCPM llama.cpp IDs [29951, 95495, 65, 2925, 67] vs source [95320, 23523, 65, 2925, 67]; MiniCPM3 IDs [29951, 59495, 65, 2925, 67] vs [59320, 23523, 65, 2925, 67].

Tests

  • focused tokenizer evidence: 82 passed
  • broad serial suite: 8,358 passed, 56 skipped, 12 deselected
  • lintrunner f --output oneline --all-files
  • GPT-5.6 Sol medium review completed; wording finding corrected

@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 26, 2026 20:16
@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 939f73d → 44daccf

Model Sub-model Changes Status

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 939f73d → 44daccf

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 105 105 +0.0% ⚪
gpt2 model_size_bytes 324 KB 324 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 265 265 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 127 127 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 450 450 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 176 176 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

Copilot AI 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.

Pull request overview

This PR adds pinned, fail-closed tokenizer mismatch evidence for MiniCPM GGUF artifacts (MiniCPM-2B and MiniCPM3-4B), binds that evidence to a fixed llama.cpp oracle corpus, and updates GGUF tokenizer inspection logic to allow only architecture-scoped legacy pre=default combinations while keeping tokenizer materialization deferred.

Changes:

  • Add a new MiniCPM tokenizer oracle fixture (444 cases/route) and bind it to new mismatch-evidence records.
  • Extend inspect_gguf_tokenizer() to accept legacy tokenizer.ggml.pre="default" only for PLaMo2 and general.architecture in {"minicpm","minicpm3"} under model="llama".
  • Introduce GGUFTokenizerMismatchEvidence records + documentation table for pinned fail-closed routes, with tests ensuring they do not promote the generic default census route.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/data/gguf_minicpm_tokenizer_oracle.json Adds pinned llama.cpp oracle fixture metadata and first-mismatch witnesses for MiniCPM routes.
src/mobius/integrations/gguf/_tokenizer.py Scopes legacy pre=default acceptance to MiniCPM architectures and PLaMo2 while keeping deferred materialization.
src/mobius/integrations/gguf/_tokenizer_test.py Adds unit tests asserting MiniCPM legacy-default handling is architecture-scoped and still rejected elsewhere.
src/mobius/integrations/gguf/_tokenizer_mismatch_evidence.py Adds immutable fail-closed mismatch evidence records with strict self-validation.
src/mobius/integrations/gguf/_tokenizer_evidence_test.py Binds new oracle fixture to mismatch evidence and ensures mismatch evidence can’t promote the generic default route.
src/mobius/integrations/gguf/_docs.py Renders a new “Pinned fail-closed tokenizer evidence” table from live mismatch records.
docs/api/build_from_gguf.md Updates the published docs with the new fail-closed tokenizer evidence table.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@justinchuby
justinchuby force-pushed the justinchuby-exact-minicpm-gguf branch from 4208326 to caa94d3 Compare August 27, 2026 06:02
Pin bounded GGUF headers and official tokenizer assets for MiniCPM and MiniCPM3, then preserve the score, type, merge, chat-template, and llama.cpp oracle divergences as architecture-scoped fail-closed evidence. Keep the legacy default pre identifier deferred rather than promoting its generic route.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: efad223f-3973-40c7-b001-e292e139f0bf
Signed-off-by: Justin Chu <[email protected]>
Add an exact deterministic corpus and bounded-header refresh workflow that builds llama-tokenize from a clean pinned checkout, regenerates oracle hashes and mismatch witnesses, and is covered by default CI discovery. Fix legacy architecture validation and ambiguous Unicode lint findings.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: efad223f-3973-40c7-b001-e292e139f0bf
Signed-off-by: Justin Chu <[email protected]>
Move MiniCPM and MiniCPM3 negative tokenizer evidence into the shared blocker registry introduced for PLaMo. Generalize that registry for zero-merge SentencePiece metadata while preserving bounded-header, source divergence, and reproducible oracle closure.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: efad223f-3973-40c7-b001-e292e139f0bf
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-exact-minicpm-gguf branch from caa94d3 to 44daccf Compare August 27, 2026 07:56
@justinchuby
justinchuby merged commit 72280df into main Aug 27, 2026
19 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-exact-minicpm-gguf branch August 27, 2026 08:00
justinchuby added a commit that referenced this pull request Aug 27, 2026
## Summary

- canonicalize only the MiniCPM oracle generator source as explicit
UTF-8 with LF line endings before computing `generator_sha256`
- render, write, and `--check` the oracle fixture as exact UTF-8/LF
bytes
- pin the committed MiniCPM oracle fixture to LF in Git so Windows clean
checkouts remain byte-canonical
- add network-free LF/CRLF regression coverage without changing
tokenizer semantics, pinned evidence, or expected result hashes

## Root cause

PR #660 hashed `Path(__file__).read_bytes()`, so Git CRLF conversion
changed the generator identity on Windows. Its text-mode fixture
write/check boundary also allowed platform newline translation and
universal-newline comparisons rather than enforcing one canonical
artifact.

## Validation

- `python -m pytest tests/generate_minicpm_tokenizer_oracle_test.py
src/mobius/integrations/gguf/_tokenizer_evidence_test.py -q --tb=short`
— 32 passed
- `python -m pytest tests/build_graph_test.py tests/cli_test.py src/ -q
-k "not phi4mm and not apply_weights_unknown" --tb=short` — 8,616
passed, 63 skipped, 12 deselected, 1 subtest passed
- `lintrunner f --output oneline --all-files` — passed
- independent GPT-5.6 Sol medium review — one Windows checkout finding
fixed by pinning the fixture `eol=lf`; affected gates rerun successfully

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: efad223f-3973-40c7-b001-e292e139f0bf
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.

3 participants