Repository navigation
fix: share server checkpoint workflows and preserve saved weights - #300
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Sampler deletion is not coordinated with the new save lock and can invalidate a successfully published checkpoint.
1 open finding
What changed in this PR
Addresses issue #298 by enabling safe-mode Transformers training, improving isolated Ray deployments, and retaining versioned sampler checkpoints.
Changes:
- Adds local processor execution and loopback-safe Ray initialization.
- Implements transactional named/unnamed sampler checkpoints and revision-aware vLLM reloads.
- Moves locks outside the working directory and expands regression coverage/documentation.
| File | Description |
|---|---|
tests/utils/test_isolated_runtime.py |
Tests isolated networking and locking. |
tests/server/utils/test_sampler_checkpoints.py |
Tests checkpoint transactions and rollback. |
tests/server/model/test_twinkle_async_inputs.py |
Tests Twinkle sampler saves. |
tests/server/model/test_tinker_handlers.py |
Updates Tinker save-handler tests. |
tests/server/integration/test_safe_mode_checkpoints_e2e.py |
Adds safe-mode checkpoint E2E coverage. |
tests/sampler/test_vllm_lora_loading.py |
Tests revision-based LoRA reloads. |
tests/model/test_safe_mode.py |
Tests local processor execution in safe mode. |
src/twinkle/utils/parallel.py |
Makes lock storage lazy and configurable. |
src/twinkle/utils/network.py |
Adds loopback IP fallback. |
src/twinkle/server/model/twinkle_handlers.py |
Uses transactional sampler saves. |
src/twinkle/server/model/tinker_handlers.py |
Shares transactional sampler saves. |
src/twinkle/server/launcher/env_propagation.py |
Propagates the lock-directory setting. |
src/twinkle/server/checkpoint/training_run_manager.py |
Writes run metadata atomically. |
src/twinkle/server/checkpoint/tinker.py |
Hides internal revision metadata. |
src/twinkle/server/checkpoint/checkpoint_manager.py |
Implements durable named sampler checkpoints. |
src/twinkle/sampler/vllm_sampler/vllm_engine.py |
Reloads changed cached LoRA weights. |
src/twinkle/protocol/types/model.py |
Updates sampler-save semantics. |
src/twinkle/processor/base.py |
Adds worker-local processor dispatch. |
src/twinkle/model/transformers/transformers.py |
Uses local processor execution. |
src/twinkle/infra/_ray/ray_helper.py |
Validates Ray master addresses. |
src/twinkle/infra/__init__.py |
Supports scoped local remote-function calls. |
pyproject.toml |
Adds the server file-lock dependency. |
docs/source_zh/使用指引/服务端和客户端/服务端.md |
Documents isolated deployment behavior. |
docs/source_zh/使用指引/服务端和客户端/Tinker兼容客户端.md |
Documents checkpoint lifetimes. |
docs/source_en/Usage Guide/Server and Client/Tinker-Compatible-Client.md |
Documents checkpoint lifetimes. |
docs/source_en/Usage Guide/Server and Client/Server.md |
Documents isolated deployment behavior. |
🧠 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 12, 2026
1 task done
loveleaves
pushed a commit
to loveleaves/twinkle
that referenced
this pull request
Oct 26, 2026
…delscope#300) * fix: keep worker-owned models off the safe-mode remote call path * fix: support loopback deployments and read-only working directories * fix: retain named sampler checkpoints and reload overwritten LoRA weights * fix: preserve processor hooks and checkpoint metadata on failures * test: consolidate checkpoint failure coverage * docs: revert documentation updates from issue 298 fixes * fix: scope sampler checkpoint repair to server storage * refactor: clarify sampler checkpoint save lifecycle * refactor: share checkpoint workflows across server protocols * refactor: simplify checkpoint path flows and contracts * test: focus checkpoint regressions on real storage behavior
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.

Named sampler saves previously replaced a single
latestdirectory, so savingycould invalidatex, failed saves could destroy the previous weights, and overwriting a name could reuse stale sampler cache entries. Twinkle training saves also recorded a checkpoint before the backend succeeded.Both Tinker and Twinkle handlers now share the existing checkpoint manager's training and sampler save workflows. Training metadata is recorded after a successful backend save. Sampler saves stage complete weights, publish a new physical version behind the stable URI, roll back publication failures, and preserve named checkpoints while retaining latest-only unnamed saves. Serialization reuses the project's
FileLockhelpers. Load, resume and upload reuse path resolution while keeping their backend argument shapes, optimizer options and protocol responses.The latest refactor flattens three path-resolution branches and clarifies storage ownership and commit boundaries, reducing the two shared manager files by 50 lines. Scope remains server code and server tests; there are no model, processor, vLLM, utility, dependency or user-documentation changes.
The latest test cleanup removes unused mock configuration and duplicate handler lifecycle checks. Tinker sampling tests now call the real manager and read materialized files, adapter mapping uses the real production method/property, and lock-wait cancellation observes actual contention. The shared filesystem failure matrix runs once, with both protocols retained for metadata/path compatibility. This cleanup changes only tests and reduces their total length by 23 lines.
Validation:
b2ee88d9; executable AST outside those three methods was unchanged.git diff --checkpassed.b2ee88d9. Real PPU evidence belongs toa958ca42(1 training/sampling E2E and 17 NAS failure tests); it is historical evidence, not a current-head device rerun.Training backend file writes retain their existing behavior; this does not add training overwrite rollback, crash recovery or in-flight sampler snapshot isolation. GPU/PPU optimizer recovery and actual Hub network operations were not rerun for this refactor.
Refs #298