Skip to content

Fix ONNX GenAI special-token authority - #644

Merged
justinchuby merged 3 commits into
mainfrom
justinchuby/special-token-authority
Aug 26, 2026
Merged

Fix ONNX GenAI special-token authority#644
justinchuby merged 3 commits into
mainfrom
justinchuby/special-token-authority

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • emit execution-relevant numeric token IDs once under package.tokenizer.special_tokens
  • preserve ordered multi-EOS package defaults while making workflow EOS tensors runtime-bound request overrides
  • remove authored package.eos_ids and package.eos_token_ids literals from decoder and VLM workflows
  • cover image, video, audio, and vision-start placeholders; restrict CTC metadata to relevant blank/padding semantics
  • stamp schema v1.2 independently of tokenizer availability and retain public SpecialTokenFact compatibility
  • refresh decoder, static-cache, and VLM conformance fixtures

Contract

Token IDs are package facts. Token spellings, added-token mappings, and chat templates remain authoritative in tokenizer assets. Termination policy consumes resolved package defaults or an explicit request replacement but owns no duplicate IDs.

Consumer schema/runtime: justinchuby/onnx-genai#2171 (merged as e599dc0f067d35aa5326ce5c97d83d2fd6d02f78)
Reader guide: justinchuby/onnx-genai#2143
Baseline coverage repair: #647

Validation

  • 1,095 passed / 250 skipped across src/mobius/integrations/onnx_genai and tests/model_coverage_test.py
  • full lintrunner
  • generated schema and fixture validation
  • git diff --check
  • architecture and benchmark checks report no graph or performance regression
  • merged consumer validation passes 28/28 hosted repositories and 56/56 metadata files

This branch is temporarily stacked on #647 solely to avoid known current-main coverage failures. After #647 merges, rebase this PR onto current main so only the two producer commits remain, rerun the focused gates, and merge.

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

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 2e08e9bfd1689b

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 updates Mobius’s ONNX GenAI inference-metadata producer to make numeric special-token IDs authoritative package facts under package.tokenizer.special_tokens, while removing duplicated/literal EOS defaults from workflows and aligning the local JSON schema to the corresponding onnx-genai metadata proposal.

Changes:

  • Migrate package.tokenizer.special_tokens from text-bearing SpecialTokenFact objects to numeric TokenFacts (including ordered multi-EOS), while keeping SpecialTokenFact import-compatible.
  • Remove authored package.eos_ids literals and make workflow EOS tensors runtime/request-bound inputs (eos_token_ids / eos_token_lengths), including VLM + decoder workflows.
  • Narrow CTC package token facts to the padding/blank relationship and bump schema stamping to v1.2 where the new fields are emitted.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/mobius/integrations/onnx_genai/workflow_metadata.py Removes package.eos_ids literals; makes EOS request/runtime-bound; restricts CTC token roles; bumps schema_version where needed.
src/mobius/integrations/onnx_genai/workflow_metadata_test.py Updates VLM test to assert EOS token IDs live under package.tokenizer.special_tokens and package.eos_ids is absent.
src/mobius/integrations/onnx_genai/package_facts.py Introduces TokenFacts numeric special-token facts; preserves ordered multi-EOS; updates tokenizer facts emission and stamps schema v1.2 when attaching facts.
src/mobius/integrations/onnx_genai/package_facts_test.py Updates tests to numeric token facts, multi-EOS ordering, placeholder roles, CTC pad-only facts, and legacy import compatibility.
src/mobius/integrations/onnx_genai/auto_export_test.py Adjusts dispatch expectations for runtime-role EOS inputs.
src/mobius/integrations/onnx_genai/_schema/inference_metadata.schema.json Syncs schema: replaces SpecialTokenFact with TokenFacts, relaxes tokenizer required fields, clarifies EOS override roles.
src/mobius/integrations/onnx_genai/init.py Re-exports TokenFacts to keep public API aligned with new producer types.

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

Comment on lines 172 to +176
def to_metadata(self) -> dict[str, Any]:
facts: dict[str, Any] = {
"algorithm": self.algorithm,
"vocab_size": self.vocab_size,
"byte_level": self.byte_level,
}
facts: dict[str, Any] = {"byte_level": self.byte_level}
if self.algorithm is not None:
facts["algorithm"] = self.algorithm
if self.vocab_size is not None:
Comment on lines 583 to 584
address nothing, so the vocabulary is the width a caller can actually render.
"""
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 2e08e9bfd1689b

Model Sub-model Changes Status

No architecture changes detected.


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

@justinchuby

Copy link
Copy Markdown
Member Author

The metadata-specific failures are resolved: regenerated decoder/static-cache/VLM fixtures now match schema v1.2, and the integration subtree passes locally (566 tests). The remaining cross-platform test failures reproduce on main and are tracked by the focused repair PR #647; #644 will be rebased after that lands.

@justinchuby

Copy link
Copy Markdown
Member Author

Producer branch refreshed and validated:

  • Temporarily stacked on Restore model coverage gates #647's green coverage-gate head so this PR can exercise its own metadata changes without the unrelated current-main coverage failures.
  • Local validation: 1,095 passed / 250 skipped across src/mobius/integrations/onnx_genai plus tests/model_coverage_test.py.
  • Full lintrunner and git diff --check pass.
  • Decoder, static-cache, and VLM fixtures now emit schema v1.2 nested token facts and runtime EOS roles.

Merge order remains deliberate: merge #647 first, then the onnx-genai consumer schema/runtime in justinchuby/onnx-genai#2171, then rebase this producer PR on current main and enable auto-merge.

@justinchuby
justinchuby force-pushed the justinchuby/special-token-authority branch from 408013b to 031ee3b Compare August 26, 2026 06:43
justinchuby added a commit to justinchuby/onnx-genai that referenced this pull request Aug 26, 2026
…2171)

## Summary

- establish `package.tokenizer.special_tokens` as the sole package
authority for execution-relevant numeric token IDs
- preserve ordered multi-EOS defaults while treating request EOS values
as replacement overrides
- require complete-generation workflows to execute termination
semantics; keep logits-only packages explicitly valid without
sampler/termination claims
- materialize one effective token set for workflow graphs and
fused/native runtime paths
- document capability obligations, portable state invariants, policy
graphs, ONNX ABI versus workflow authority, and reserved versus
extensible identifiers
- validate and publish schema-v1.2 canonical plus annotated metadata
across the hosted collection

## Contract

Token IDs are package facts under `package.tokenizer.special_tokens`.
Token spellings, added-token mappings, and chat templates remain
authoritative in tokenizer assets. Workflow ports route semantic values
but do not duplicate ONNX physical ABI, and termination policy consumes
resolved token facts without owning another numeric copy.

Request EOS values replace package defaults when supplied. Pre-v1.2
compatibility may derive EOS from legacy tokenizer assets; v1.2 packages
fail closed on retired workflow/package EOS literals.

## Reader documentation

- [Metadata capability
model](https://github.com/justinchuby/onnx-genai/blob/justinchuby/special-token-authority/docs/genai/METADATA_CAPABILITY_MODEL.md)
- [Normative inference metadata
decisions](https://github.com/justinchuby/onnx-genai/blob/justinchuby/special-token-authority/docs/genai/INFERENCE_METADATA_DECISIONS.md)
- [Reader tracking issue
#2143](#2143)

## Producer and hosted examples

- Mobius producer migration:
onnxruntime/mobius#644
- Mobius baseline coverage repair:
onnxruntime/mobius#647
- Hosted collection: **28 repositories / 56 canonical+annotated files**,
including 12 complete-generation packages migrated to schema v1.2
- Catalogue revision:
[`8ba416600109201e10256841e20f0c1d2777af6e`](https://huggingface.co/datasets/justinchuby/onnx-genai-inference-metadata-catalogue/tree/8ba416600109201e10256841e20f0c1d2777af6e)

## Validation

- metadata and genai-config test suites
- engine authored-workflow and multi-EOS tests
- ORT tokenizer/chat-template tests
- server multimodal tests and Rust 1.98 Clippy with warnings denied
- generated schema synchronization, formatting, and `git diff --check`
- collection validator: semantic YAML equality, inline comments, README
links, provenance hashes, generation scope, token authority, executable
termination, schema, and shapes for all 56 files

The non-required **Mobius metadata packages (signal)** job is expected
to reject current Mobius `main` fixtures until producer PR #644 lands;
v1.2 validation is intentionally not weakened for that transition.

---------

Signed-off-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@justinchuby

Copy link
Copy Markdown
Member Author

Coordination update: main advanced through #649, so this temporarily stacked branch now reports merge conflicts in workflow_metadata.py plus the decoder and static-cache fixtures. The overlap is understood: #649 owns the new batching-capacity semantics, while this PR owns schema v1.2 token authority/runtime EOS roles. I am intentionally deferring the branch rewrite until prerequisite #647 merges, to avoid resetting both already-queued shared-A10 jobs. After #647 lands, I will rebuild #644 from current main with only the two producer commits, resolve these three files by preserving both semantics, rerun targeted/full validation, and force-push with lease.

@justinchuby

Copy link
Copy Markdown
Member Author

Rebuild preview update (not pushed yet): I rebuilt this producer change on current main (5a192106, including #649) plus the current #647 head and resolved the decoder/static-cache fixture overlaps while preserving both authorities:

  • Fix workflow batching capacity declarations #649 remains authoritative for component.batch_capacity.
  • This PR remains authoritative for schema-v1.2 package.tokenizer.special_tokens and runtime-bound EOS roles.
  • Retired package.eos_ids remains absent.

The preview also exposed one real cross-change issue: #649's batch-capacity helper unconditionally assigned schema v1.1 after token facts had already selected v1.2. The prepared fix upgrades only exact legacy v1 metadata, so v1.2 and future versions are not downgraded.

Validation on the clean preview:

  • targeted producer/fixture/coverage suite: 1,188 passed, 250 skipped
  • standard non-integration suite: 8,343 passed, 56 skipped
  • full lintrunner: passed
  • git diff --check: passed

I am intentionally holding the force-push until #647 merges, so its coverage repair is inherited from main rather than duplicated in this branch and the currently queued A10 job is not reset.

justinchuby and others added 3 commits August 26, 2026 13:31
Emit schema-v1.2 numeric token facts under package.tokenizer.special_tokens, preserve ordered multi-EOS defaults, and make decoder/VLM EOS inputs runtime-bound request overrides instead of package workflow literals. Cover image, video, and audio placeholders, keep CTC limited to its pad/blank fact, synchronize the consumer schema, and retain the prior public SpecialTokenFact import for compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: justinchuby <justinchuby@users.noreply.github.com>
Regenerate decoder, static-cache, and VLM conformance metadata with schema-v1.2 package tokenizer facts and request-bound EOS roles. Also apply the formatter change required by the current main branch lint gate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: justinchuby <justinchuby@users.noreply.github.com>
Keep schema v1.2 after declaring batch capacities and resolve the decoder fixtures against the latest batching contract. This prevents the batching helper from downgrading token-authority metadata emitted by the producer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: justinchuby <justinchuby@users.noreply.github.com>
@justinchuby
justinchuby force-pushed the justinchuby/special-token-authority branch from 031ee3b to fd1689b Compare August 26, 2026 13:33
@justinchuby
justinchuby merged commit c83c668 into main Aug 26, 2026
20 of 21 checks passed
@justinchuby
justinchuby deleted the justinchuby/special-token-authority branch August 26, 2026 13:33
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