Skip to content

fix: correct adapter state reuse and streaming completion - #341

Closed
Yunnglin wants to merge 2 commits into
mainfrom
fix/adapter-training-state
Closed

Yunnglin wants to merge 2 commits into
mainfrom
fix/adapter-training-state

Conversation

@Yunnglin

@Yunnglin Yunnglin commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Changes

  • Merge metric arguments once so forward kwargs cannot collide with the actual learning rate, step, gradient accumulation or gradient norm. Build optimizer parameter groups from the unwrapped model so later adapters use the same parameter names and can restore optimizer state.
  • Register every owned LoRA slot when wrapping DDP/FSDP, without unfreezing base parameters. Keep the distributed trainable set stable across adapter switches, use non-reentrant gradient checkpointing, and establish the synchronized reset basis before saving or loading checkpoints.
  • Reset Full-training optimizer groups, progress and template hooks when reload_initial_weights(reset_training_state=True) is requested, for both Transformers and Megatron. Preserve the existing reload behavior when the flag is omitted.
  • Re-enable Hybrid FFT wrappers when activating an FFT slot, and update Hybrid adapter contexts to use the shared slot-gradient helper.
  • Close the vLLM async generator and join its engine-loop task before the synchronous stream iterator finishes. Closing an HTTP-facing iterator must not release ownership while generation is still running.
  • Move the corresponding regressions into model/sampler tests, including real two-process CPU DDP switching and slot reuse, checkpoint restoration, Full-state reset and streaming completion.

Usage and integration

Experiment results

  • Revision: 4b100918655a0bfa4437c00768c2722222f859f1.
  • 76 focused CPU cases pass with zero failures, errors or skips: optimizer metrics/grouping, the complete Spectral Hybrid suite, checkpoint contexts, real two-process DDP switching/reuse, training-state reset and stream completion.
  • Before this expansion, the previous fix: correct adapter state reuse and streaming completion #341 head reproduced five additional failing cases covering missing slot registration, retained Full-training state and an iterator closing before its engine task exits. The original three metric/grouping/FFT failures were also reproduced before their fixes.
  • Source pre-commit hooks and git diff --check pass. A merge-tree check against current main is conflict-free.
  • CPU reset tests exercise the actual Megatron reset method without loading the optional Megatron stack; streaming tests exercise the actual iterator method and background event loop without loading a GPU engine. No fresh full-backend or PPU run is claimed for this PR.

Copilot AI balanced review requested due to automatic review settings October 26, 2026 03:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Yunnglin Yunnglin changed the title fix(model): stabilize metric kwargs, optimizer groups and FFT slots fix: correct adapter state reuse and streaming completion Oct 26, 2026
@Yunnglin Yunnglin closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants