Repository navigation
Validate exact GPT4O GGUF tokenizer routes - #650
Merged
Merged
Conversation
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]>
Performance Comparison
|
Contributor
There was a problem hiding this comment.
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
kanana2andtalkieand 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-4oandllama4.
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 assignsmodel["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 missingtokenizer.ggml.mergesneeded 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gpt-4oandllama4fail closed with immutable candidate dispositions: wrong dispatch/inventory for the former, incomplete under-limit shard for the latterValidation
lintrunner