Skip to content

Validate exact GPT4O GGUF tokenizer routes - #650

Merged
justinchuby merged 6 commits into
mainfrom
justinchuby-verify-gpt4o-tokenizers
Aug 26, 2026
Merged

justinchuby merged 6 commits into
mainfrom
justinchuby-verify-gpt4o-tokenizers

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • reconstruct the Talkie tokenizer from its exact GGUF-native ordered vocabulary, types, merges, and special metadata, canonicalized to pinned llama.cpp GPT4O semantics
  • validate Talkie and Kanana2 independently against pinned llama.cpp across 444 adversarial, seeded-random, special-token, detokenization, and chat-template cases
  • keep gpt-4o and llama4 fail closed with immutable candidate dispositions: wrong dispatch/inventory for the former, incomplete under-limit shard for the latter
  • generate compact network-free evidence and documentation for artifact/source identities, hashes, embedding rows, padding, and route-specific blockers

Validation

  • all-files lintrunner
  • focused GGUF tokenizer/docs tests: 88 passed
  • broad serial suite: 8,352 passed, 57 skipped, 12 deselected, 1 subtest passed

Pin the immutable Talkie GGUF and official tokenizer source identities, and fail closed on the exact ordered-merge mismatch rather than leaving a generic evidence blocker.

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

Copilot-Session: d5d1d772-b7f9-4243-b8de-a13634d0da7b
Signed-off-by: Justin Chu <[email protected]>
Bind an immutable Kanana2 Q8 artifact to the official source tokenizer, including ordered vocabulary, merges, token types, GPT4O pipeline, special-token insertion, multilingual vectors, embedding rows, and contained materialization.

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

Copilot-Session: d5d1d772-b7f9-4243-b8de-a13634d0da7b
Signed-off-by: Justin Chu <[email protected]>
Materialize Talkie from its GGUF-native ordered merges and pinned GPT4O regex while retaining immutable official asset identity. Bind the result to 444 pinned llama.cpp tokenization and detokenization cases across special-token modes and adversarial multilingual inputs.

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

Copilot-Session: d5d1d772-b7f9-4243-b8de-a13634d0da7b
Signed-off-by: Justin Chu <[email protected]>
Revalidate the canonical adapted GPT4O regex against the independently pinned llama.cpp tokenizer across 444 adversarial, random, special-token, detokenization, and rendered-template cases.

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

Copilot-Session: d5d1d772-b7f9-4243-b8de-a13634d0da7b
Signed-off-by: Justin Chu <[email protected]>
Record immutable fail-closed candidates independently: the GPT4O-named GGUF dispatches llama-bpe with a different inventory, while the only under-limit Llama4 Q4 shard omits tokenizer metadata and embedding rows.

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

Copilot-Session: d5d1d772-b7f9-4243-b8de-a13634d0da7b
Signed-off-by: Justin Chu <[email protected]>
Require GPT4O oracle evidence to match the dispatch commit and reject template processors unless they exactly implement the GGUF-enabled BOS insertion. Apply repository formatting from the all-files lint pass.

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

Copilot-Session: d5d1d772-b7f9-4243-b8de-a13634d0da7b
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 26, 2026 14:34
@github-actions

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing c83c668 → 6304528

Model Sub-model Changes Status

No architecture changes detected. ✅


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

@justinchuby
justinchuby merged commit ee521b0 into main Aug 26, 2026
23 of 26 checks passed
@justinchuby
justinchuby deleted the justinchuby-verify-gpt4o-tokenizers branch August 26, 2026 14:36
@github-actions

Copy link
Copy Markdown

Performance Comparison

Comparing c83c668 → 6304528

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 strengthens the GGUF tokenizer integration for the GPT4O pre-tokenizer family by adding pinned llama.cpp “oracle” evidence, enabling GPT4O pipeline canonicalization, and introducing evidenced/validated routes for the Talkie and Kanana2 artifacts while keeping gpt-4o and llama4 fail-closed with explicit blocker dispositions.

Changes:

  • Add GPT4O-specific tokenizer pipeline canonicalization (regex + byte-level + optional template BOS insertion) and an optional “reconstruct merges from GGUF” mode.
  • Introduce new pinned evidence records for kanana2 and talkie and bind them to compact, network-free oracle fixtures (commit + case count + digest).
  • Update tokenizer route census/docs/fixtures to reflect new validated routes and new deferred blocker categories for gpt-4o and llama4.

Reviewed changes

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

Show a summary per file
File Description
tests/data/gguf_tokenizer_alias_batch2.json Updates alias→evidence mapping to include new validated GPT4O routes for kanana2 and talkie.
tests/data/gguf_gpt4o_oracle.json Adds pinned llama.cpp oracle identity/digest fixture for Talkie GPT4O validation.
tests/data/gguf_gpt4o_kanana2_oracle.json Adds pinned llama.cpp oracle identity/digest fixture for Kanana2 GPT4O validation.
src/mobius/integrations/gguf/_tokenizer.py Implements GPT4O pipeline canonicalization and optional GGUF-native reconstruction hooks during pinned tokenizer validation/materialization.
src/mobius/integrations/gguf/_tokenizer_test.py Adds unit tests covering GPT4O pipeline acceptance/canonicalization, BOS template handling, and GGUF-native reconstruction behavior.
src/mobius/integrations/gguf/_tokenizer_evidence.py Extends evidence schema to include GPT4O reconstruction disposition + pinned oracle identity, and adds new Kanana2/Talkie evidence entries.
src/mobius/integrations/gguf/_tokenizer_evidence_test.py Validates new evidence invariants (oracle binding, reconstruction disposition) and updates census expectations.
src/mobius/integrations/gguf/_tokenizer_census.py Adds explicit blocker categories and pinned candidate dispositions for gpt-4o and llama4.
src/mobius/integrations/gguf/_docs.py Expands tokenizer evidence table rendering to include oracle and reconstruction disposition fields.
docs/api/build_from_gguf.md Updates published route disposition counts and expands the tokenizer route table rows for GPT4O-related identifiers.
Suppressed comments (1)

src/mobius/integrations/gguf/_tokenizer.py:1123

  • When reconstruct_gpt4o_from_gguf=True, the code assigns model["merges"] = metadata.get("tokenizer.ggml.merges") without validating that merges are present and an array. If the GGUF metadata is missing or malformed here, the failure will surface later as a generic "model.merges must be an array" error rather than clearly attributing the problem to missing tokenizer.ggml.merges needed for GPT4O reconstruction.
    if reconstruct_gpt4o_from_gguf:
        if policy is None or policy.pre_type != "GPT4O" or not isinstance(model, dict):
            raise ValueError("GGUF-native reconstruction is supported only for GPT4O BPE")
        model["merges"] = metadata.get("tokenizer.ggml.merges")
        config = _canonicalize_gpt4o_tokenizer_config(metadata, config)

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

Comment on lines +845 to +860
config = dict(config)
tokens = metadata["tokenizer.ggml.tokens"]
for suffix, name in (
("bos_token_id", "bos_token"),
("eos_token_id", "eos_token"),
("unknown_token_id", "unk_token"),
("padding_token_id", "pad_token"),
):
token_id = metadata.get(f"tokenizer.ggml.{suffix}")
if token_id is not None:
config[name] = tokens[token_id]
for name in ("add_bos_token", "add_eos_token", "add_sep_token"):
value = metadata.get(f"tokenizer.ggml.{name}")
if value is not None:
config[name] = value
return config
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.

2 participants