feat: add TrainerRank API#740
Draft
bradhilton wants to merge 13 commits into
Draft
Conversation
Closed
…o feat/trainer-rank-api
…o feat/trainer-rank-api
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.
Summary
This PR depends on #739 and contains the user-facing TrainerRank layer moved into a new module,
art.trainer_rank. The intent is to keep Austin-facing Megatron/CP/GDN changes separate from the higher-level API work.Public API
ForwardInput/ForwardOutputare typed and support target logprobs, multi-target labels, top-k, logits, hidden states, and per-request adapter routing.TrainerRank.dp_rank_forward(...)is the explicit API for already-DP-local inputs.TrainerRank.forward_micro_batches(...)is the DP-aware adaptive training iterator. It slices only shallow top-level items, returnsMicroBatchobjects withinputs,outputs,indices, and planning stats, and raises proactively when the smallest safe batch is expected not to fit.set_checkpoint,set_lora,push_checkpoint,push_lora, andpop_pushed_lora_or_checkpoint.optim_step(...)supports the Megatron optimizer path plus ART-managed dynamic checkpoint slot optimizers.Implementation highlights
src/art/trainer_rank, notsrc/art/megatron/trainer_rank.py.art.trainer_rank.topk.dev/and are intentionally outsideart.megatron.Validation
Local on this branch:
uv run --no-sync prek run --all-files: passed.uv run python dev/trainer_rank_fast_check.py:67 passed, 8 skippedlocally.4x H200 SkyPilot (
codex-trainer-rank-h200) on this branch:uv run python dev/trainer_rank_fast_check.py:85 passed.1 passed.world=1,tp=1,cp=1:mean_abs_pct=1.43e-7,max_abs_diff=1.91e-6world=2,tp=1,cp=1:mean_abs_pct=1.27e-7,max_abs_diff=1.91e-6world=2,tp=2,cp=1:mean_abs_pct=7.16e-8,max_abs_diff=1.91e-6world=2,tp=1,cp=2:mean_abs_pct=4.51e-8,max_abs_diff=1.91e-6world=4,tp=1,cp=4:mean_abs_pct=4.51e-8,max_abs_diff=1.91e-6Qwen/Qwen3.5-35B-A3B, all 40 layers, CP=4, EP=4, 4x H200, Austin-style 198k packed-token workload (30 x (5k prefix + 16 x 100 completion), 2.448M logical tokens), warmup=1, repeat=1:labels=train step:23.5kpacked tok/s25.6kpacked tok/s58.2GB113.3GB119.3GBKnown caveats
Review focus
For this PR, I mostly want review on the API shape, adaptive microbatch semantics, slot routing semantics, and whether the implementation is sufficiently small and maintainable given the behavior it supports.