bench: gigatoken per-step profile + take/have/skip analysis - #2233
Draft
ArthurZucker wants to merge 13 commits into
Draft
bench: gigatoken per-step profile + take/have/skip analysis#2233ArthurZucker wants to merge 13 commits into
ArthurZucker wants to merge 13 commits into
Conversation
Branched off #2223. Profiles marcelroed/gigatoken's encode pipeline per step (split / cache-probe / added-token / merge) via its public API on the wiki corpora, and compares each stage to what tk-encode already has. Finding: merge dominates (1.5-25 ns/B) by ~10x over everything else (split+probe+added <4 ns/B); warm all-hit encode is 0.86-5.7 ns/B. So the only throughput levers are cache hit rate and merge speed. Verdict — take: inline value packing in the word cache (98% of pretokens are <=2 ids, avoids the second arena load), PairRankTable for the merge path (bench head-to-head), fused key-hash-in-span-walk. Have (>=): normalization, split, the 4-way L2 WordCache (correct regime — gigatoken's is DRAM/training-tuned). Skip: huge pages, prefetch ladder, DRAM-resident growth (only pay >64MB), asm csel probe, parquet/py-bindings. Harness: notes/gigatoken_profile_steps.rs (needs a gigatoken clone).
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…33x gap, not merge/split/norm
SBrandeis
force-pushed
the
feat/bpe-cache
branch
2 times, most recently
from
July 27, 2026 10:37
6b26583 to
42a00a7
Compare
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.
Stacks on #2223. Profiles marcelroed/gigatoken 0.9.0 per encode step and compares each stage to what tk-encode already has, to decide what's worth porting.
Adds (
tk-encode/benches/notes/): the analysis doc + the reproduction harness (gigatoken_profile_steps.rs— drop into a gigatoken clone asexamples/profile_steps.rs). No workspace deps added (gigatoken is edition-2024 + pyo3/parquet/icu — too heavy to vendor as a dev-dep).Finding: merge dominates (1.5–25 ns/B) by ~10× over split+probe+added (<4 ns/B); warm all-hit encode is 0.86–5.7 ns/B. The only throughput levers are cache hit rate and merge speed.
Verdict:
WordCache(98% of pretokens are ≤2 ids → drop the second arena load);PairRankTablefor the merge path (bench head-to-head — merge is the dominant cost); fused key-hash-in-span-walk.WordCache— correct for inference; gigatoken's is DRAM/training-tuned, do not swap.Draft — this is a notes/analysis PR, not shippable code.