Repository navigation
fix: preserve training state across checkpoints and shared adapters - #315
Merged
Merged
Conversation
Yunnglin
force-pushed
the
fix/training-state-restoration
branch
from
October 14, 2026 06:36
f6fab8a to
19d1849
Compare
Yunnglin
marked this pull request as ready for review
October 15, 2026 04:25
There was a problem hiding this comment.
🔵 Needs a closer look
An unresolved correctness issue and cross-backend distributed-state changes require human review, with hardware CI still cancelled.
1 open finding
What changed in this PR
Repairs checkpoint restoration and shared-adapter training across Transformers and Megatron, independently of #312’s resource lifecycle changes.
Changes:
- Restore weights, optimizer bindings, and tenant checkpoint context.
- Preserve native parallel-layer communication and Megatron optimizer master parameters.
- Add regression coverage and correct configuration imports.
| File | Description |
|---|---|
| tests/transformers/test_tied_weight_restore.py | Tests tied aliases and strict loading. |
| tests/transformers/test_native_fsdp_strategy.py | Tests tenant-specific optimizer rebinding. |
| tests/transformers/test_multi_lora_checkpoint_context.py | Tests checkpoint tenant activation. |
| tests/transformers/test_megatron_weight_only_resume.py | Tests master-parameter refresh. |
| tests/transformers/test_megatron_resume_response.py | Tests progress collection and Ray ownership. |
| tests/transformers/test_full_checkpoint_resume.py | Tests full-model checkpoint restoration. |
| tests/model/test_multi_lora_tensor_parallel.py | Tests parallel outputs and gradients. |
| src/twinkle/model/transformers/transformers.py | Wraps all optimizers and restores full weights. |
| src/twinkle/model/transformers/strategy/weight_state.py | Expands genuine tied-weight aliases. |
| src/twinkle/model/transformers/strategy/sequence_parallel/__init__.py | Supports multiple optimizer returns. |
| src/twinkle/model/transformers/strategy/native_fsdp.py | Preserves optimizer bindings and tied aliases. |
| src/twinkle/model/transformers/strategy/accelerate.py | Expands aliases before distributed loading. |
| src/twinkle/model/transformers/multi_lora_transformers.py | Activates checkpoint target tenants. |
| src/twinkle/model/multi_lora.py | Preserves native parallel-layer execution. |
| src/twinkle/model/megatron/strategy/megatron.py | Corrects configuration imports and annotations. |
| src/twinkle/model/megatron/multi_lora_megatron.py | Refreshes target optimizer master parameters. |
| src/twinkle/model/megatron/megatron.py | Refreshes master parameters and collects resume progress. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tastelikefeet
approved these changes
Oct 15, 2026
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
Fix checkpoint restoration and shared LoRA training in Transformers and Megatron. Independent of PR 312.
PretrainedConfigfor the configuration import.Validation
9e855f03, CPU: 23 focused regressions and 18 additional review checks passed, with no failures/errors/skips. The additional checks cover Ray dispatch with simulated restore workers, tied-weight alias rules, and PEFT tenant optimizer isolation using CPU strategies; they do not exercise device sharding.546d8d14, PPU: 17 scenarios on two ranks produced 34 JUnit passes, covering Native FSDP2 checkpoint continuation, Megatron TP2 with SP off/on, row/column layers, and Accelerate tied-weight loading with a tiny module. These were not rerun on the current head.Remaining issue
Full Qwen with Accelerate 1.14.0/FSDP2 still raises
KeyError: 0when exporting Adam state, observed on both the baseline and backend-fix commit.