Skip to content

Add a targeted HFTokenizer encode-latency benchmark#194

Open
digantdesai wants to merge 1 commit into
gh/digantdesai/1/basefrom
gh/digantdesai/1/head
Open

Add a targeted HFTokenizer encode-latency benchmark#194
digantdesai wants to merge 1 commit into
gh/digantdesai/1/basefrom
gh/digantdesai/1/head

Conversation

@digantdesai

@digantdesai digantdesai commented Jun 12, 2026

Copy link
Copy Markdown

Stack from ghstack (oldest at bottom):

Standalone Release-optimized benchmark for the HFTokenizer long-prompt encode
path. It repeats prose/code/dialogue templates to long inputs (~0.5k-8k tokens)
and prints mean encode latency. This is a targeted latency benchmark for this
code path, not a generic tokenizer harness; correctness is covered by the unit
tests and it exits nonzero if any encode errors.

Baseline latency on the original (pre-fix) code, Gemma-4-31B tokenizer, Release,
mean of 5 reps:

  vector          chars     ids     mean_ms
  prose_0.5k       2240     491       241.4
  code_1k          4514    1891       789.2
  dialogue_1.5k    6720    1345      2212.5
  prose_2k         8946    1450      3905.4
  prose_8k        49416    8005    123504.8

Latency grows with the square of input length (chars x5.5 from prose_2k to
prose_8k -> time x31.6 ~= 5.5^2); an 8k-token prompt takes ~123 s. Gemma's
normalizer turns spaces into the word marker before the space-splitter runs, so
the whole prompt is BPE-merged as a single piece.

Authored with assistance from Claude Code.

[ghstack-poisoned]
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 12, 2026
@digantdesai digantdesai marked this pull request as ready for review June 15, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants