mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1385] Intermittent 'int' object has no attribute 'ranks' in tokenizer #559
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#559
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mustafaerdinc on GitHub (Oct 7, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1385
During an OpenCode coding session, Strata logged this exception 12 times while preparing requests. OpenCode showed Bad Gateway, retried, and eventually finished. The Strata service did not restart and its cgroup OOM counters stayed at zero.
Environment
6f32ec070f, engine 0.1.3982f46a8c8f, engine 0.1.40The same exception also occurred during the update test, in a separate Python client process calling the tokenizer to count a long synthetic prompt. It happened before that process sent the long-prompt HTTP request. The client did not load Strata's native engine or NVML bindings. The server was running in another process at the time.
What we checked
_bpeimplementations are identical. The failing line is in the short-word scan._bpereadsself.HEAP_MINearlier and does not assign toself.Synthetic workload
Synthetic workload
This describes the workload used in the CPU retests. It is not a reliable reproducer: those retests passed.
From the Strata checkout, with the affected pack's tokenizer loaded as
tok:We found #268, but that reports long-word tokenization latency rather than this exception. CPython python/cpython#156319 reports frame corruption with Tier 2 and active monitoring; we have not established those conditions here.
Is this a known tokenizer/runtime issue? If not, which process-level diagnostics or isolated Python-version comparison would help narrow it down? We currently have no confirmed root cause.
@Niko1221 commented on GitHub (Oct 7, 2026):
Thanks for the careful report, and for ruling out so much before sending it.
We read tools/strata_tokenizer.py end to end for a way
selfcould become an int inside_bpe: there is no cache or decorator on a method, no__slots__or__getattr__, no staticmethod/classmethod mix-up, no callback or thread that passes an argument in, and the regex module is only called forfindall/finditeron plain strings._bpeis pure Python, takesselffrom the callself._bpe(mapped)and does not assign to it. We also ran 8 threads sharing one tokenizer against a single-threaded run (new test in serve/test_detok.py) and every id matched. So we cannot reproduce it and we do not see a path in our code that produces an intself.That leaves what you pointed at: a fault in the interpreter. A local variable slot holding the wrong object in the middle of a loop, in a function that has run millions of times, is what a broken Tier 2 / JIT optimisation or frame bug looks like, and the CPython issue you linked (frame corruption with Tier 2 and active monitoring) matches that shape. It also fits that fresh processes on the same text pass.
What we changed in 0.1.40.3:
_bpenow readsself.ranks.getonce before the scan instead of re-readingselfon every symbol pair, which removes the line that failed from the hot loop. We want to be clear that this is hardening, not a confirmed fix.If you see it again, the most useful single test is to run the server with
PYTHON_JIT=0(and, if you can, once on CPython 3.13) and see whether the error goes away. If it still happens with the JIT off, please send the log and we will look at it again. Leaving this open until then.@mustafaerdinc commented on GitHub (Oct 8, 2026):
I tested v0.1.40.3 (
d5ea713) in a separate checkout with PYTHON_JIT=0.The upstream CPU test now reproduces failures intermittently, without loading a model or sending an HTTP request:
STRATA_TOKENIZER was unset: four synthetic tests execute and five pack-only tests are skipped.
_bpe, line 167, duringtest_words_directly.TypeError: 'int' object is not callableat line 162,r = ranks_get((parts[i], parts[i + 1])), duringtest_synthetic_vocab.PYTHONMALLOC=debug.Both Linux environments use regex 2026.9.10 and MarkupSafe 3.0.3. Faulthandler lists only
markupsafe._speedupsandregex._regexas extension modules. This does not establish which component caused the failure.The 3.13 build is Astral python-build-standalone 20261003, configured with
--enable-experimental-jit=yes-off. PYTHON_JIT=0 was supplied at startup; ignore_environment=0, optimize=0 and GIL enabled=true. This build has nosys._jitAPI, so I cannot report its JIT state through that API.For comparison, the same source and package versions passed five fresh processes on macOS arm64 with CPython 3.14.8. A separate stdlib-only check using the exact Tokenizer class and bound
_bpe/_bpe_heapmethods also passed 22,981 synthetic words on both Linux interpreters. These controls differ in execution history or platform and do not rule out an intermittent fault.The Linux host has an i9-13900K, microcode 0x133. Readable kernel logs showed EDAC initialization and “No ECC support,” with no matching machine-check error. That does not establish hardware health.
I have kept the production service unchanged. Would the sanitized faulthandler logs or the bounded test runner be useful for the next investigation step?
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.
If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
autotoo 4X gain in the prefill in 4 way ring #2889