Skip to content

feat: update encode signature - #2274

Merged
McPatate merged 1 commit into
feat/train_encode_splitfrom
feat/update_encode_signature
Aug 4, 2026
Merged

McPatate merged 1 commit into
feat/train_encode_splitfrom
feat/update_encode_signature

Conversation

@McPatate

@McPatate McPatate commented Aug 3, 2026

Copy link
Copy Markdown
Member
  • adds EncodeHandle return type to pave the way for async
  • takes impl Into<Inputs> as an input
    • pairs are not properly supported atm, we still need to handle post-processor logic
  • some of the benchmarks call encode* in a loop because it used to be single sequence only
    • I didn't dig too much to pass in the full batch and have kept it single-sequence for the moment, we could change that eventually

* adds `EncodeHandle` return type to pave the way for async
* takes `impl Into<Inputs>` as an input
    * pairs are not supported atm

Signed-off-by: Luc Georges <luc.sydney.georges@gmail.com>
@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.

Comment on lines +84 to +87
.encode(chunk, true)
.wait()
.unwrap()
.first()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could have a _encode vs encode as you said or something that does this for us when no using any async?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is what happens for sequential input unbatch AFAIK

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo we should keep a consistent API for both, this is sync but allows us to build future/async on top

@McPatate
McPatate merged commit c299c1a into feat/train_encode_split Aug 4, 2026
37 of 42 checks passed
@McPatate
McPatate deleted the feat/update_encode_signature branch August 4, 2026 11:57
ArthurZucker added a commit that referenced this pull request Aug 5, 2026
Conflict resolutions:

- models/bpe/model.rs (modify/delete): kept the deletion. This branch split
  model.rs into bpe_model/bpe_scratch/merge_* and moved its tests to tests.rs.
  The only thing the base added to it was the reused_scratch_matches_fresh
  test, which tests.rs already carries verbatim, so nothing is lost.

- utils/parallelism.rs: took the base version. The fork-safe pool (#2268) is
  deliberate upstream work; this branch's "cleanup" commit had dropped it as
  apparently dead code. Restoring it also means restoring libc, which the
  cleanup removed from tk-encode/Cargo.toml and pthread_atfork needs.

Semantic fixups the textual merge could not do:

- pipeline.rs a_reused_scratch_keeps_its_grown_buffers asserted on
  BpeScratch::word, which no longer exists. The buffer that now grows with
  input length is the merge entry arena (convert_queue reserves one entry per
  byte); symbols only holds the final merged ids, so it stays at its initial
  64 and the assertion has to target merge.entries. Dropped Word::capacity,
  added by the base only for the old form of this assertion.

- tests/bpe_pipeline_oracle.rs used the pre-#2274 encode signature. encode now
  returns EncodeHandle, so wait()/first() as in tests/pipeline_oracle.rs.

Verified: 312 lib tests, 4 bpe_pipeline_oracle, 20 doctests pass.
clippy --workspace --all-targets --all-features is byte-identical to the base
branch (both fail only on the 12 pre-existing dead-code lints for the
not-yet-wired pool).
ArthurZucker pushed a commit that referenced this pull request Sep 2, 2026
Squashed from 3 commits:
  - refactor: make sure the pool is fork-safe (#2268)
  - feat: update `encode` signature (#2274)
  - fix: iterate then wait potential out of bounds panic (#2282)

Area: core-parallelism
ArthurZucker pushed a commit that referenced this pull request Sep 2, 2026
Squashed from 3 commits:
  - refactor: make sure the pool is fork-safe (#2268)
  - feat: update `encode` signature (#2274)
  - fix: iterate then wait potential out of bounds panic (#2282)

Area: core-parallelism
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