Skip to content

feat(tokenization): add optional gigatoken tokenizer backend - #3603

Open
aminehd wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
aminehd:aminehd/feat/gigatoken-backend
Open

feat(tokenization): add optional gigatoken tokenizer backend#3603
aminehd wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
aminehd:aminehd/feat/gigatoken-backend

Conversation

@aminehd

@aminehd aminehd commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What

Adds an optional gigatoken tokenizer backend, addressing #3177. gigatoken is a Rust BPE tokenizer whose .as_hf() compatibility mode produces token IDs identical to the source HuggingFace tokenizer, so it can accelerate the plain-text tokenization path.

Scope

This is an additive, opt-in base backend — it is not yet wired into NeMoAutoTokenizer dispatch, so it changes no existing behavior:

  • nemo_automodel/_transformers/tokenization/gigatoken.pyis_available() and build_gigatoken_tokenizer(hf_tokenizer), guarded by safe_import so it is a no-op when gigatoken is not installed.
  • gigatoken optional-dependency group in pyproject.toml.
  • Unit tests: availability, HF-fallback when unavailable, wrapping when available, and token-ID parity against the HF tokenizer (CI-safe skips when gigatoken/network absent).

Notes / open questions

gigatoken is BPE-only (no SentencePiece/WordPiece) and its .as_hf() does not implement apply_chat_template. Before wiring it into dispatch end-to-end, a few design questions remain — chat/SFT template coverage, bulk encode_files vs. per-sample drop-in, and the interface (a use_gigatoken flag vs. a config option). Happy to follow up in a subsequent PR once the interface is settled.

@aminehd
aminehd requested review from a team as code owners August 21, 2026 03:45
@copy-pr-bot

copy-pr-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@akoumpa akoumpa linked an issue Aug 21, 2026 that may be closed by this pull request
@akoumpa

akoumpa commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

/ok to test 3dc0ebc

Add an optional, additive gigatoken tokenizer backend for issue NVIDIA-NeMo#3177.
gigatoken is a Rust BPE tokenizer whose .as_hf() mode yields token IDs
identical to the source HuggingFace tokenizer, accelerating the plain-text
tokenization path.

The backend is guarded by safe_import so it is a no-op when gigatoken is not
installed, and it is not yet wired into NeMoAutoTokenizer dispatch. Includes a
gigatoken optional-dependency group and unit tests covering availability, the
HF-fallback path, wrapping, and ID parity against the HF tokenizer.

Signed-off-by: Amineh Dadsetan <amineh.dadsetan@gmail.com>
@aminehd
aminehd force-pushed the aminehd/feat/gigatoken-backend branch from 3dc0ebc to 5655e95 Compare August 21, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support gigatoken

2 participants