Skip to content

feat(tokenization): refactor and improve tokenization support - #685

Draft
binaryaaron wants to merge 18 commits into
mainfrom
feature/full-tokenizer
Draft

feat(tokenization): refactor and improve tokenization support#685
binaryaaron wants to merge 18 commits into
mainfrom
feature/full-tokenizer

Conversation

@binaryaaron

@binaryaaron binaryaaron commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

mostly agent-cycles and review at this point with my driving and corrections; not really ready for human review just yet. agent review is fine.

draft:

Summary

  • Uses one native tokenizer authority for deterministic prompt and record IDs, capacity accounting, and training framing.
  • Routes training and generation JSONL through records_to_jsonl while preserving the current pandas compatibility bytes.
  • Pins production TinyLlama, Mistral, and SmolLM3 prompt, training, and persistence boundaries across tabular, grouped, and time-series modes.
  • Validates persisted vLLM tokenizer parity at production prompt and record seams, with explicit legacy text-prompt behavior.

Test plan

  • mise run check
  • Focused tokenizer and generation contract suite: 148 passed
  • A100 generation smoke with vLLM 0.26.0 and Torch 2.11.0+cu129: 2 passed
  • Full assembler module across eight workers: 32 passed
  • Decimal cache-state regression across separate workers: 2 passed

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 60a1d6a5-5644-4338-a674-5425895e42bc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

Comment thread src/nemo_safe_synthesizer/tokenization/base.py Fixed
Comment thread src/nemo_safe_synthesizer/tokenization/base.py Fixed
Comment thread src/nemo_safe_synthesizer/tokenization/base.py Fixed
Comment thread src/nemo_safe_synthesizer/tokenization/base.py Fixed
Comment thread src/nemo_safe_synthesizer/tokenization/base.py Fixed
Comment thread src/nemo_safe_synthesizer/tokenization/base.py Fixed
Comment thread src/nemo_safe_synthesizer/tokenization/registry.py Fixed
@binaryaaron
binaryaaron force-pushed the feature/full-tokenizer branch from d551849 to 63c7362 Compare August 3, 2026 18:49
@binaryaaron
binaryaaron changed the base branch from main to agonzales/timeseries-prefill-serialization August 3, 2026 18:50
@binaryaaron binaryaaron changed the title feat(tokenization): add extensible tokenizer contracts feat(tokenization): own native tokenizer lifecycle Aug 4, 2026
@binaryaaron
binaryaaron force-pushed the feature/full-tokenizer branch from e5f0823 to 0845a30 Compare August 4, 2026 16:52
@binaryaaron
binaryaaron force-pushed the feature/full-tokenizer branch from 0845a30 to b6cffeb Compare August 4, 2026 17:01
@binaryaaron
binaryaaron changed the base branch from agonzales/timeseries-prefill-serialization to main August 4, 2026 17:01
@binaryaaron
binaryaaron force-pushed the feature/full-tokenizer branch from b6cffeb to 5711f66 Compare August 4, 2026 17:09
for count in range(10):
tokenization.capacity_for(prompt, context_limit=1000, sequence_count=count)

assert calls == 1

class _PromptConfig(Protocol):
@property
def template(self) -> str: ...
def template(self) -> str: ...

@property
def add_bos_token_to_prompt(self) -> bool: ...
def add_bos_token_to_prompt(self) -> bool: ...

@property
def add_eos_token_to_prompt(self) -> bool: ...
def add_eos_token_to_prompt(self) -> bool: ...

@property
def bos_token(self) -> str: ...
def bos_token(self) -> str: ...

@property
def bos_token_id(self) -> int: ...
def bos_token_id(self) -> int: ...

@property
def eos_token(self) -> str: ...
def eos_token(self) -> str: ...

@property
def eos_token_id(self) -> int: ...

class _Metadata(Protocol):
@property
def prompt_config(self) -> _PromptConfig: ...
Comment thread src/nemo_safe_synthesizer/tokenization/core.py Fixed
Comment thread src/nemo_safe_synthesizer/tokenization/core.py Fixed
@binaryaaron
binaryaaron force-pushed the feature/full-tokenizer branch from 0408f2d to 358bb2b Compare August 10, 2026 13:35
Comment on lines +272 to +275
def resolve_masks(
sequences: Sequence[Sequence[int]],
attention_masks: Sequence[Sequence[int]] | None,
) -> tuple[tuple[int, ...], ...]:
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
@binaryaaron
binaryaaron force-pushed the feature/full-tokenizer branch from 358bb2b to 9cee2aa Compare August 10, 2026 22:20
@binaryaaron binaryaaron changed the title feat(tokenization): own native tokenizer lifecycle feat(tokenization): refactor and improve tokenization support Aug 12, 2026
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.

1 participant