Skip to content

bench: gigatoken per-step profile + take/have/skip analysis - #2233

Draft
ArthurZucker wants to merge 13 commits into
feat/bpe-cachefrom
bench/gigatoken-compare
Draft

bench: gigatoken per-step profile + take/have/skip analysis#2233
ArthurZucker wants to merge 13 commits into
feat/bpe-cachefrom
bench/gigatoken-compare

Conversation

@ArthurZucker

Copy link
Copy Markdown
Collaborator

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 as examples/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:

  • Take: inline value packing in WordCache (98% of pretokens are ≤2 ids → drop the second arena load); PairRankTable for the merge path (bench head-to-head — merge is the dominant cost); fused key-hash-in-span-walk.
  • Have (≥): normalization (atomnorm ahead), split (atomsplit comparable), the 4-way L2 WordCache — correct for inference; gigatoken's is DRAM/training-tuned, do not swap.
  • Skip: huge pages, prefetch ladder, DRAM-resident growth (only pay >64 MB), asm csel probe, parquet/py-bindings.

Draft — this is a notes/analysis PR, not shippable code.

SBrandeis and others added 12 commits July 22, 2026 09:42
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).
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@SBrandeis
SBrandeis force-pushed the feat/bpe-cache branch 2 times, most recently from 6b26583 to 42a00a7 Compare July 27, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants