Repository navigation
feat(csd): add cross-tokenizer distillation and sub-token preparation - #4679
Closed
avenkateshha wants to merge 1 commit into
Closed
avenkateshha wants to merge 1 commit into
avenkateshha wants to merge 1 commit into
Conversation
Signed-off-by: Adithyakrishna Hanasoge <avenkateshha@nvidia.com>
Contributor
Author
|
/ok to test 22ebcf7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Superseded by #4680 after renaming the contribution branch to
avenkateshha/csd. The implementation commit and stacked base are unchanged.What does this PR do ?
Adds CSD as a separate cross-tokenizer distillation algorithm, with sub-token table preparation and a complete training workflow. Existing X-Token loss behavior, example configurations, and projection-matrix preparation remain available.
CSD provides common-event and prefix-support losses, dense or sparse teacher-logit transport, bounded-memory tensor/context-parallel student losses, multi-teacher weighting, and deterministic lockstep sequence packing. It reuses the existing alignment, colocated teacher execution, and training infrastructure, with integration for Automodel and Megatron, model-load precision controls, and router replay. CSD-specific collation keeps complete source samples and validates durable identities, semantic masks, and sequence limits.
The public guide covers building and validating both table directions, configuring their paths, and launching training. CPU preprocessing includes exact byte-preserving token chains, special-token roles, tokenizer fingerprints, and validation. The provided builder supports fast BPE tokenizers with ByteLevel decoders; unsupported decoder families fail explicitly.
Issues
Depends on and is stacked on #3286. The stack is
main→ #3286 → this PR. Both branches are inNVIDIA-NeMo/RL:avenkateshha/xtoken-offset-alignment, at247493fd04b8eae8af7bcfedf4470750ec11b380when this contribution was prepared.avenkateshha/csd.The parent implementation is inherited through history; this diff contains the additional CSD work and integration changes. This PR does not target
main.Usage
Follow the cross-tokenizer guide for prerequisites, both table-building commands, validation, and a complete two-step GPU training example. The existing X-Token guide documents its separate projection workflow.
Training uses
examples/run_csd.pywithexamples/configs/csd.yamlorcsd_multiteacher.yaml. Each cross-tokenizer teacher consumesteachers[i].aligner.student_to_teacher_table_pathandteachers[i].aligner.teacher_to_student_table_path. Prepare or filter the input corpus so complete rows fit both model context limits; see the guide for a self-contained smoke dataset and launch command.Before your PR is "Ready for review"
Additional Information
Executed focused CPU checks include 162 combined X-Token/CSD controller tests; CSD loss values, gradients, dense/sparse parity and TP2/CP2 Gloo parity; 85 packing/distributed/IPC tests (three GPU skips); dataset/sample-identity, collator supervision, configuration, and table-builder/validator CLI regressions. Ruff lint/import ordering/formatting, recipe minimization, shell syntax, and whitespace checks were also run.
Full GPU training and CUDA IPC validation were unavailable in the local environment. Megatron runtime dependencies were unavailable, and real-model tokenizer checks require model access. Table preparation was exercised with local tokenizer fixtures. The local Python environment was 3.13.13 rather than the checkout's pinned 3.13.14. Full-project type checking is limited by unavailable or mismatched optional dependencies; focused checks cover the new CSD modules. The GPU recipes are registered as manual/disabled tests pending hardware qualification.