Repository navigation
bench: make target tokenizer overrideable in bench_he and bench_llm - #93
Merged
Merged
Conversation
Both bench scripts hardcoded Qwen/Qwen3.5-27B as the HF tokenizer
reference, making them unusable for Qwen3.6 or future Qwen variants
without forking the repo. This was already inconsistent with run.py,
which honors $DFLASH_TOKENIZER and defaults to Qwen/Qwen3.6-27B.
Each bench script gets the override via its own idiomatic API:
bench_he.py: --target-tokenizer CLI flag (joins the existing
argparse surface). Default falls back through
$DFLASH_TOKENIZER → "Qwen/Qwen3.5-27B", so:
- no flag, no env → Qwen/Qwen3.5-27B (current behavior)
- $DFLASH_TOKENIZER set → that wins
- --target-tokenizer foo → that wins over both
bench_llm.py: TOKENIZER module-level read from $DFLASH_TOKENIZER
(matches the file's existing env-driven config style
— TARGET, DRAFT, TEST_DFLASH, etc. are all env vars).
Same default chain. Logged on the [bench] line.
Defaults preserve current behavior on both scripts; existing call sites
that don't set the env var or pass the flag are unaffected. Users
running Qwen3.6 set DFLASH_TOKENIZER once and both scripts pick it up,
matching run.py's convention.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configurable HuggingFace tokenizer reference to the benchmarking scripts so users can run benches against newer Qwen variants (or any compatible tokenizer) without editing the repo, aligning with the existing DFLASH_TOKENIZER convention used by run.py.
Changes:
bench_llm.py: readsTOKENIZERfrom$DFLASH_TOKENIZER(fallbackQwen/Qwen3.5-27B), logs it, and uses it forAutoTokenizer.from_pretrained(...).bench_he.py: adds--target-tokenizerCLI flag (defaulting to$DFLASH_TOKENIZERthenQwen/Qwen3.5-27B) and uses it for prompt tokenization, logging the chosen tokenizer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
dflash/scripts/bench_llm.py |
Makes tokenizer configurable via DFLASH_TOKENIZER, logs it, and removes hardcoded tokenizer id. |
dflash/scripts/bench_he.py |
Adds --target-tokenizer override (with env var fallback) and logs/uses it during tokenization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="dflash/scripts/bench_he.py">
<violation number="1" location="dflash/scripts/bench_he.py:300">
P2: `--target-tokenizer` is not reflected in the cached prompt files, so `--skip-tokenize` can reuse tokenization from a different tokenizer and corrupt benchmark results.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…lm env var
Two review-feedback fixes:
1. bench_he.py cached prompt files at TMPDIR/he_prompt_NN.bin with no
tokenizer in the path, so a sequence like
run 1: --target-tokenizer Qwen/Qwen3.5-27B (no --skip-tokenize)
run 2: --target-tokenizer Qwen/Qwen3.6-27B --skip-tokenize
would silently feed Qwen3.5 token IDs to the bench under the
pretense of Qwen3.6 — corrupting results without any signal.
Cache path is now TMPDIR/he_prompt_<slug>_NN.bin where <slug> is
re.sub(r'[^A-Za-z0-9._-]+', '_', target_tokenizer). Different
tokenizers cache to distinct files; switching back is free. As a
safety net, --skip-tokenize now sys.exit's with a clear message if
no cache exists for the requested tokenizer (instead of falling
into a misleading file-not-found later in the bench loop).
Threaded the slug through both call sites (tokenize loop + bench
loop). Also moved the [bench] tokenizer = ... print up to the
header so the resolved tokenizer is visible regardless of
--skip-tokenize.
2. bench_llm.py docstring's env-var list didn't mention the new
DFLASH_TOKENIZER knob (the "TOKENIZER" module constant was
reading it but the docstring stayed silent). Added it to the
list with a note that it matches run.py's convention.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
oliveagle
pushed a commit
to oliveagle/lucebox-hub
that referenced
this pull request
May 22, 2026
bench: make target tokenizer overrideable in bench_he and bench_llm
This was referenced Sep 14, 2026
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.
Both bench scripts hardcoded Qwen/Qwen3.5-27B as the HF tokenizer reference, making them unusable for Qwen3.6 or future Qwen variants without forking the repo. This was already inconsistent with run.py, which honors $DFLASH_TOKENIZER and defaults to Qwen/Qwen3.6-27B.
Each bench script gets the override via its own idiomatic API:
bench_he.py: --target-tokenizer CLI flag (joins the existing
argparse surface). Default falls back through
$DFLASH_TOKENIZER -> "Qwen/Qwen3.5-27B", so:
- no flag, no env -> Qwen/Qwen3.5-27B (current behavior)
- $DFLASH_TOKENIZER set -> that wins
- --target-tokenizer foo -> that wins over both
bench_llm.py: TOKENIZER module-level read from $DFLASH_TOKENIZER
(matches the file's existing env-driven config style
- TARGET, DRAFT, TEST_DFLASH, etc. are all env vars).
Same default chain. Logged on the [bench] line.
Defaults preserve current behavior on both scripts; existing call sites that don't set the env var or pass the flag are unaffected. Users running Qwen3.6 set DFLASH_TOKENIZER once and both scripts pick it up, matching run.py's convention.