Repository navigation
perf(distillation): defer teacher top-k Ray payloads - #3943
yuchenwang3 wants to merge 1 commit into
Conversation
|
@nvidia-nemo/rl_reviewers_algo @nvidia-nemo/rl_reviewers_infra — final validation is complete on head |
20cfa59 to
5db71aa
Compare
|
/ok to test 5db71aa |
|
@zpqiu, this PR addresses the teacher-result transfer bottleneck you reported in #1877 by deferring compatible DP-local top-k payloads through Ray object references. The PR documents controlled transfer measurements and fallback coverage; those measurements are not an end-to-end training speedup claim. Could you take a look at the approach or help identify the appropriate distillation reviewer? Maintainer CI authorization is also still needed. Thanks. |
|
Synced with current main and resolved the policy-worker conflict, retaining both deferred top-k transfer and the new pre-refit synchronization hook. No change to the transfer algorithm. Changed-file Ruff/format checks pass. Local isolated CPU checks confirm the deferred methods are unchanged and the upstream refit hook is preserved. The earlier Ray/GPU measurements remain results for the previously documented revision; I have not rerun that benchmark on this merge. Upstream runner validation still needs maintainer authorization. |
850a892 to
eff2617
Compare
|
@ananthsub Rebased at |
|
Thank you for this contribution! Could we evaluate reusing the existing data-plane/TQ path for teacher top-k payloads? |
|
Thanks @zpqiu, I traced the TQ path and agree it looks suitable for top-k too. The existing The remaining wiring would be:
I'd favor reusing those components over maintaining another transport. Would you prefer that I migrate distillation's step lifecycle to TQ in this PR and remove the deferred-Ray path? @ZhiyuLi-Nvidia @zyzhou5, guidance on that scope would help before I rework the driver. |
|
@zpqiu @ZhiyuLi-Nvidia Could you confirm whether the TQ change should include the distillation driver lifecycle in this PR, or start with top-k field and worker support as a prerequisite? The codec probe is complete; the remaining work is the TQ worker entrypoint and trainer setup/cleanup. I'd like to settle that scope before replacing the deferred-Ray implementation. |
eff2617 to
733659d
Compare
|
Rebased onto The current-head CPU suites now pass 63 tests: 33 policy/deferred and distillation-driver cases, plus 30 worker-group cases with real local Ray actors. One Nsight case is skipped because GPU worker/functional tests, the transfer benchmark, full type checking, and TQ integration remain open. The PR description separates these new checks from the earlier B200 results. The TQ lifecycle scope discussed above remains unresolved. |
|
@zpqiu Synced with main and fixed the conflict. Should this PR migrate distillation setup/train/cleanup to TQ, or should I add the top-k worker support first? |
Keep DP-local teacher outputs in the Ray object store and hand their references directly to matching student workers. Materialize only small worker wrappers in the driver so all-replica readiness and error propagation remain unchanged. Refs: NVIDIA-NeMo#1877 Signed-off-by: Yuchen Wang <93700456+yuchenwang3@users.noreply.github.com>
3487617 to
277f2dc
Compare
What does this PR do?
Keep DP-local teacher top-k payloads in the Ray object store and pass their references directly to matching student workers instead of materializing the large tensors in the driver.
The fast path is enabled only when teacher and student have compatible static DP layouts. Direct-packed SFT inputs, dynamic batching, mismatched DP sizes, incompatible sequence-packing layouts, and partial batches continue to use the existing materialized path.
Worker methods return a small wrapper containing the worker-local payload reference. The driver still materializes every wrapper, so failures from replicated workers propagate before representative payload references are selected. Ray sharding also preserves existing ObjectRefs rather than wrapping them in another object-store entry.
Issues
Closes #1877
Usage
No user-facing configuration change is required. Compatible distillation runs select the deferred transfer path automatically.
Validation
October 8 main sync
3487617a7b6a8512d9daa9afdda23088d631b099; main:fc4f3bcf57cebef3c453bc149be04231163420e1.nccl, which is unavailable in this macOS environment. The run includes policy/deferred, packed SFT, distillation-driver, collective, and real CPU Ray worker-group tests;--noconftestomits GPU-monitor fixtures. Python 3.13.14, PyTorch 2.13.0, Ray 2.58.0; the dedicated 8-CPU Ray cluster was shut down afterward.October 4 rebase
31b4c0295cff085e74f2724e2cf057e5b3e3ae04733659d1f600d2d0bd2c8782362e81241cbc8b6fnsysis unavailable.--noconftestto omit the repository autouse GPU-monitor fixtures. Policy/driver cases mock model loading and workers. The worker suite starts a dedicated local Ray cluster with 8 CPU resources and shuts it down afterward.git diff --checkpass. The recipe-minimization hook was skipped locally. A targeted Pyrefly attempt exited 137 without diagnostics; it is not a type-check pass.Earlier validation
The unit-test and B200 measurements below apply to patch
20cfa59cc405067629d1c99562f10687f396bfb3and its stated base, rather than the October 4 rebase.Exact source under test:
71a08314bc3257a15ef04b507309649e3d3f0f6820cfa59cc405067629d1c99562f10687f396bfb3036dd95966651201da0998d009f939dbec630815Focused tests:
tests/unit/models/policy/test_deferred_topk.py: 8 passed, 0 skippedtests/unit/distributed/test_worker_groups.py: 28 passed, 1 unrelated Nsight environment skiptests/unit/algorithms/test_distillation.py: 23 passed, 0 skippedControlled 8×B200 Ray transfer benchmark:
Every measured run used 8 actors, completed all repeats with exit 0, matched checksums, resolved ObjectRefs automatically, and reported zero object spilling. The final-patch harness models the production path: worker-local
ray.put, small wrapper materialization in the driver, then direct payload-reference handoff. A separate probe confirmed that an error from a non-representative worker still fails the driver.This is a controlled transfer benchmark for the bottleneck mechanism rather than a claim about full end-to-end training-step speedup.
Local checks also passed: Ruff lint, Ruff format check, Python compileall, and
git diff --check.Before your PR is "Ready for review"
Additional Information
The commit is signed off under DCO by Yuchen Wang.
Assisted-by: OpenAI Codex