Repository navigation
Description
Description
ais-bench-prefix-cache prepare can fail with canonical prefix does not round-trip for group-1 when two or more prefix groups select the same corpus text and the tokenizer merges across the deterministic marker/corpus boundary.
Confirmed against current master (e330dc134c33f47671926144d9c143b554bc71cc). The affected generation.py is also identical to the version at 7bcb6440da11bef020943b2af9ed7c1ac8362306 (Prefix Cache plugin 0.5.0).
Minimal reproduction (no model service or model weights required)
Run from plugins/prefix_cache:
from ais_bench_prefix_cache.generation import GSMRecord, build_canonical_prefixes
class BoundaryTokenizer:
# A reversible subword tokenizer with a token for a space followed by s.
def encode(self, text, add_special_tokens=False):
result, i = [], 0
while i < len(text):
if text[i:i + 2] == " s":
result.append(256)
i += 2
else:
result.append(ord(text[i]))
i += 1
return result
def decode(self, ids, skip_special_tokens=False):
return "".join(" s" if token == 256 else chr(token) for token in ids)
record = GSMRecord(0, "same question", "fixture")
groups = {f"group-{i}": [record] for i in range(3)}
build_canonical_prefixes(
BoundaryTokenizer(), groups, {group: 96 for group in groups}, 4
)Actual result:
ArtifactValidationError: canonical prefix does not round-trip for group-1
Root cause
The collision fallback separately encodes the marker and concatenates its IDs with the corpus IDs:
marker = tokenizer.encode(f"{group_position} prefix-cache-group-{group} ", add_special_tokens=False)
token_ids = marker + source_tokensSubword tokenization is not compositional across that boundary. Decoding the concatenated IDs and encoding the resulting wire text can merge the marker's trailing space with the first corpus token, invalidating the saved IDs. The existing character-only collision test does not exercise this behavior.
Expected behavior
Duplicate corpus selections should still produce distinct, reproducible group prefixes. Keep round-trip and first-cache-block collision validation; construct the marker and corpus as text and encode them together instead of concatenating separately encoded IDs.
Additional offline verification
With a locally available DeepSeek-V4-Flash tokenizer, one source record, block size 32, and 82,944 shared prefix tokens:
- Latest official function: 3/3 identical failures in the minimal three-group case.
- Proposed text-first encoding fix: 3/3 pass, three distinct first blocks, all token IDs round-trip.
- Group source pools of 54/53/53 repeated selections: official function fails; proposed fix passes.
- Single-group output remains unchanged.
No model requests, cache resets, or service restarts were used for this reproduction.
Environment
The original failure was reproduced against pristine source at e330dc134c33f47671926144d9c143b554bc71cc. The installation environment was rechecked read-only on 2026-11-09:
- Host OS: openEuler 22.03 LTS-SP4, Linux aarch64.
- Container userland: openEuler 24.03 LTS; kernel
5.10.0-313.0.0.216.oe2203sp4.aarch64. - Python: system CPython 3.11.6, built with GCC 12.3.1.
- Python Environment for Tool Installation: a dedicated standard-library
venvcreated from/usr/bin/python3.11with--system-site-packages; not Conda. The venv uses pip 23.3.1 and inherits preinstalled AISBench dependencies from the container. AISBench core and the Prefix Cache plugin are installed using that venv'spython -m pip, including their source distributions/checkouts. - AISBench core: 3.1.0 (
ais-bench-benchmark); Prefix Cache plugin: 0.5.0 (ais-bench-prefix-cache). - Dependency versions in that environment: transformers 5.12.1, tokenizers 0.22.2, datasets 3.6.0, torch 2.12.0+cpu, aiohttp 3.14.1, pyarrow 24.0.0, Pillow 11.2.1.
- No model service, NPU, model weights, or network access is required for the minimal fake-tokenizer reproduction above.
Fix and follow-up validation
PR #646 contains the fix. Follow-up commit 8a0588a also adds a minimum-length check and bounded corpus replenishment after joint encoding, preserves collision/round-trip rejection, and addresses the test-fixture review.
On 2026-11-09, an isolated local Windows/CPython 3.11 test environment ran the updated plugin suite: 202 run, 201 passed, 1 skipped, no failures/errors. The existing optional full AISBench model-import test was skipped because the full model dependencies/PyTorch are not installed locally; this is separate from the original Linux reproduction environment described above. Core and pipeline tests: 50 passed.
Local DeepSeek-V4-Flash and Qwen tokenizer checks each reproduced the pristine-source failure 3/3 and passed the fix 3/3, with 82,944 shared tokens, block size 32, and three duplicate groups. Both also passed offline preparation and artifact validation for six 1,024-token requests at a 90% target.
All follow-up tests ran locally. Remote activity was limited to read-only environment inspection and copying tokenizer files; installed tools, application/model services, queues, and running tests were not modified. No inference requests or cache resets were sent.
Activity
github-actions commentedon Nov 6, 2026
🌟 Welcome to file an issue for the AISBench benchmark tool. We will process your request as soon as possible~
github-actions commentedon Nov 6, 2026
🤖 issue content check result from AI robot:
问题内容检查结果
检查状态
FAIL
详细检查
👉 If you want to re-check, please comment @issue_checker.
[Strongly recommended❤️🔥]Ensure your issue description is complete, then try to ask
for help, as deepwiki contains all the knowledge related to the tool.
AtlasLeong commentedon Nov 9, 2026
已在 Issue 正文补齐 Python Environment for Tool Installation:系统 CPython 3.11.6、venv --system-site-packages、pip 23.3.1、容器/宿主 OS 与实际依赖版本,并关联修复 PR #646。@issue_checker 请重新检查。
github-actions commentedon Nov 9, 2026
🤖 issue content check result from AI robot:
问题内容检查结果
检查状态
FAIL
详细检查
👉 If you want to re-check, please comment @issue_checker.
[Strongly recommended❤️🔥]Ensure your issue description is complete, then try to ask
for help, as deepwiki contains all the knowledge related to the tool.
github-actions commentedon Nov 9, 2026
🤖 issue content check result from AI robot:
问题内容检查结果
检查状态
PASS
详细检查
👉 If you want to re-check, please comment @issue_checker.
[Strongly recommended❤️🔥]Ensure your issue description is complete, then try to ask
for help, as deepwiki contains all the knowledge related to the tool.