Repository navigation
test(qwen): reject prompt token count mismatches - #1625
Closed
davemichael wants to merge 1 commit into
Closed
davemichael wants to merge 1 commit into
davemichael wants to merge 1 commit into
Conversation
Compare native prompt receipts with the reference chat template before generation output checks. Validate each reported tensor-parallel rank and repeated run. Complements the renderer fix in NVIDIA#1617. Co-Authored-By: Codex Signed-off-by: Dave Michael <dmichael@nvidia.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
Author
|
My agent discovered the same bug as #1617 |
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.
Background
Qwen3-4B-Instruct-2507 could pass the generation E2E with different native and reference prompts: native execution received 24 tokens while the reference received 20, but the generated tokens matched. The renderer fix is already covered by #1617; this PR adds the missing E2E validation. Related to #1615.
Exit Criteria
Every Qwen generation E2E checks the native prompt token count against the reference-rendered prompt before comparing output. Missing receipts and a mismatch from any reported tensor-parallel rank or repeated run fail. Existing numerical and output acceptance thresholds remain unchanged.
Implementation
Use the reference chat-template rendering to count prompt tokens. Validate native prefill receipts for regular, sampled and repeated generation. Accept MPI-tagged receipts and check each reported rank separately. Changes are confined to three Qwen test files; no runtime, API, ABI, bundle or dependency changes.
Change categories
Validation
Commands and Results
python -m pytest families/qwen/tests/test_runtime_receipt.py families/qwen/tests/test_builder_policy.py -q: 13 passed, including rejection of the 24-versus-20-token regression, missing receipts and per-rank mismatches.python -m ruff check families/qwen/tests/runtime_receipt.py families/qwen/tests/test_runtime_receipt.py families/qwen/tests/test_e2e.py: passed.PYTHONPATH=core/builder:apps/benchmark:. python -m tools.model_ci validate: passed.PYTHONPATH=core/builder:apps/benchmark:. python tools/test_impact.py --validate: passed.git diff --check github/main...HEAD: passed. Applicable pre-commit checks passed.Hardware, Environment, and Revisions
Tested source:
943a07a01af2f5b14af8633c10f3a6dd8b8c029a, based one6c674eof main. CPU-only checks in a Linux x86_64 development container with Python 3.12 and the pinnedrequirements/community-ci.txttools, including pytest 8.4.2 and Ruff 0.16.4. Unit tests use synthetic runtime receipts; no model checkpoint or GPU is needed for these checks.Not Run / Remaining Gaps
GPU generation, multi-GPU execution, full model parity, performance and protected premerge were not run for this PR head. The Qwen3-4B E2E is expected to expose the known mismatch until #1617 or an equivalent renderer fix lands. Keep this PR in draft pending that dependency and CI.
Contributor Self-Review
Manually reviewed the complete three-file diff at
943a07a01af2f5b14af8633c10f3a6dd8b8c029a, including ordinary/repeated generation, the embedding bypass, reference chat-template counting and tagged rank parsing. No blocking findings within this scope; model execution remains unverified on this head.Notes For Future Readers
Merge the renderer fix in #1617 first. This PR deliberately avoids duplicating its runtime implementation and native template tests. Equal token counts catch the observed defect but do not establish arbitrary token-by-token prompt identity; missing ranks are not detected by the count check. No new third-party implementation is incorporated.
Risk level
Risk rationale: the stricter E2E check may expose existing prompt mismatches or missing receipts in model configurations that previously passed output-only comparison. Runtime behavior and acceptance tolerances are unchanged.