Skip to content

perf: enforce minimum BPE tokenization job size - #66

Merged
AlonKejzman merged 2 commits into
crusoecloud:mainfrom
jthomson04:jthomson04/min-bpe-job-size
Sep 10, 2026
Merged

AlonKejzman merged 2 commits into
crusoecloud:mainfrom
jthomson04:jthomson04/min-bpe-job-size

Conversation

@jthomson04

@jthomson04 jthomson04 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Small BPE workloads can create too many Rayon jobs when the thread pool is large, adding scheduling and synchronization overhead under concurrent requests.

This change keeps buffers below 64 KiB sequential and otherwise selects min(pool_threads, split_count, byte_len / (32 * 1024)) jobs. Both tokenization paths divide splits evenly across those jobs and fall back to sequential processing when fewer than two jobs are selected. Token order and the configured thread-pool size are unchanged.

Validation:

  • cargo fmt --check: passed.
  • cargo clippy -- -D warnings: passed.
  • cargo test pre_tokenized::tests: all 11 tests passed, including byte-threshold boundaries and split/thread caps.
  • cargo test: 255 passed, 9 ignored, 11 failed. All 11 failures were Hugging Face cache-lock acquisition errors while loading model files; full-suite validation remains incomplete.

Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
@jthomson04
jthomson04 marked this pull request as ready for review September 9, 2026 21:56
Comment thread src/pre_tokenized.rs Outdated
Comment thread src/pre_tokenized.rs Outdated
@AlonKejzman
AlonKejzman merged commit 49063b5 into crusoecloud:main Sep 10, 2026
19 checks passed
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.

2 participants