Skip to content

Commit f385f55

Browse files
Separiusclaude
andauthored
[3/19] Add Bypass capture boundaries and validated configuration (#3676)
### What does this PR do? Type of change: new feature **Problem:** Bypass repair needs disjoint teacher/student boundaries and faithful replay of inputs, masks and boundary outputs before its runner can update native IQ fields. **Fix:** Provide the capture/replay adapter and validated training configuration as a standalone prerequisite to the streamed runner in #3456. `sequence_length` is a maximum (only longer batches are refused), the teacher forward receives `use_cache=False` by keyword only, and tied teacher weights are accepted because the teacher is read-only; one teacher module shared by two boundaries is still refused. This slice adds approximately 385 lines of source excluding comments, docstrings and blanks. ### Modules touched - `distill._bypass_capture`: owns boundary validation, bounded masked loss and teacher-input replay required by the runner. - `distill.config`: validates the shared batch, scheduling and boundary-selection contract; the public export is deferred to #3456. - `quantization.repair`: extends the existing physical ownership walk to whole capture boundaries, replacing a duplicate walk. ### Usage This internal prerequisite keeps `BypassConfig` out of the package exports. The validated configuration becomes public with its runner consumer in #3456. ### Testing Fresh local and hosted validation at signed/DCO head `606001b54b1df405cd5ce65ae0963279e0719c52` is pending. Since the previous head `8f6109cc0b4d332598c05447042b537e8b435d60`, this slice dropped positional `use_cache` handling, `output_selector`, the optimizer field and the linear scheduler; `layer_indices` moved to its first reader in #3457. At the previous head, standalone capture passed 25 cases (0.76 s), the rebased integration at 6a0fa76 passed all 466 selected CPU/Gloo cases (95.44 s), and exact runner a9869db passed all 52 public runner cases on four GPUs (Slurm 2524044, 95.16 s); those results qualify that revision only. Rebased onto `bypass/core-split/06-lifecycle` at `05d80ea0d3a22c7678c94203a817aefe7ad04825`. Fresh hosted checks and automated reviews are pending; earlier results qualify their stated revisions only. Stacked-PR required GPU/example/regression markers defer until the base targets main; on-demand workflows exercise the actual lanes meanwhile. Human approval remains separate. ### Before your PR is "*Ready for review*" Contributor and security guidance read; commits are signed and include DCO signoff. - Is this change backward compatible?: ✅ - External copied code or new PIP dependencies?: N/A - Necessary tests?: ✅ Existing capture/config checks accompany their implementation. - Changelog?: N/A Internal prerequisite; the public feature entry is in #3456. - Claude approval?: Pending; requested below. Human review remains separate. ### Additional Information Design choice: `LayerwiseDistillationModel.modify()` unfreezes selected student layers and replaces LM heads. Bypass keeps the physical weights frozen while `IQRepairPolicy` owns scale prepare/project/finalize. The synchronous capture callback lets its consumer select training or validation gradient mode; `_BypassRunner._measure()` already does so. The masked MSE returns both sum and valid-element count for global-batch normalization and bounds FP32 work while retaining narrow saved activations. Those contracts belong to the internal Bypass path rather than the existing scalar KD loss/conversion lifecycle. Merge order: #3678 → #3599 → #3591 → #3592 → #3593 → **this PR** → #3456 → #3457 → #3458 → #3679 (native physical fields) → #3680 (TP field/geometry helpers) → #3459 → #3460 → #3461 → #3462 → #3463 → #3464 → #3465 → #3466 → #3467 → #3468 → #3469. Core support PRs retain their own numbering; the Bypass feature series expands from 16 to 19 slices after the two native prerequisites are added. No merge is requested by this update. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added PyTorch bypass distillation options for training steps, learning-rate scheduling, batch and sequence limits, and module selection. * Added teacher-output capture and replay at selected module boundaries, with masked loss calculations and microbatch processing. * **Validation** * Added checks for batch and sequence limits, module selection, and incompatible or overlapping module boundaries. * Improved validation of module ownership, including quantization and offload-related state. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Native continuation: #3457 → #3458 → #3679 (physical fields) → #3680 (TP/geometry) → #3459 → #3460 → #3461. The decoder-aware Transformers adapter in #3457 intersects exact module and logical-layer selectors; the ordinary-Torch adapter accepts `modules` only and refuses `layer_indices`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Sepehr Sameni <ssameni@nvidia.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8667e5d commit f385f55

4 files changed

Lines changed: 711 additions & 9 deletions

File tree

0 commit comments

Comments
 (0)