Repository navigation
feat: add on-demand models with shared LoRA and exclusive training - #312
Merged
Merged
Conversation
Yunnglin
marked this pull request as draft
October 14, 2026 00:40
Yunnglin
force-pushed
the
feat/on-demand-training
branch
from
October 14, 2026 06:38
7f1cbc1 to
4d8888b
Compare
Yunnglin
force-pushed
the
feat/on-demand-training
branch
from
October 14, 2026 06:57
4d8888b to
87fd772
Compare
Preserve legacy expiration semantics, isolate user initialization failures, and keep recovery nonblocking. Bound retry receipts and reconcile lost completion notifications.
Yunnglin
force-pushed
the
feat/on-demand-training
branch
from
October 15, 2026 02:43
87fd772 to
dd96d85
Compare
- Split runtime allocation from deployment so the controller persists ownership before any worker starts; the driver no longer writes records. - Make cleanup, close and failure transitions persist-before-mutate, track failed instances for sweep retries, fence admission, and exclude failed residents when rebuilding minimum replicas. - Never lose a worker wake-up when enqueue callbacks or queued-status writes fail; log background job failures with tracebacks. - Return 503/Server while the controller is not ready; drop unreleased reason codes; reset resident training state before model-id branching. - Move generic device allocation to server/resources, managed runtime to server/model, training records/store to server/state, TaskQueueConfig to server/config, and shared proxy/env propagation to the server root, with no compatibility re-exports. - Encapsulate ServerState backend access and batch heartbeat reads outside the controller lock. - Guard all server component dependencies with a strict grimp layer test. - Require ray[serve]>=2.55 for async deployment constructors. - Stop tracking local-only docs/design notes.
Fix optimizer metrics, wrapped parameter groups and safe Redis reconnects. Add lifecycle metrics, isolated Redis/GPU acceptance and stress coverage. Move shared probes into tests and untrack local tools.
Integrate 015732e while preserving controller-owned training creation and sequence ledgers. Adapt full-mode regression tests to the catalog/controller path. Verified 434 targeted tests and the complete pre-commit suite.
Yunnglin
marked this pull request as draft
October 23, 2026 08:49
Yunnglin
marked this pull request as ready for review
October 23, 2026 21:56
1 of 4 tasks
tastelikefeet
approved these changes
Oct 26, 2026
tastelikefeet
added a commit
that referenced
this pull request
Nov 28, 2026
main carried 17 commits (#311..#291) over merge-base 96dab68. v5 had already ported everything up to #312 (a4ddc3b) and moved server/client to twinkle_cs, so: - server/client (src/twinkle/server, twinkle_cs/*, tests/server, tests/twinkle_client): kept the v5 tree; the legacy src/twinkle/server path and the old ci_container_test.sh stay removed on v5. - loss: #291 detached DFT weights, #335 Liger CE contract (delegates micro_batch_scale / batch_normalizer to CrossEntropyLoss), #334 chunked CE comments, #336 InfoNCE tests. - model: #343 Torch.empty_cache (auto-merged), #385 fused_lm_rl ported onto the v5 task registry (processor/tasks.py + model/tasks.py FusedRL + transformers postprocess), #386 NPU fused CE fast path in selective_log_softmax. - twinkle_agentic: #345 check kinds (hidden_python / sql_query / answer_one_of / answer_number / web_receipt / lean) adapted to the episode-scoped Env interface; AgenticChallenger gains the _verify_check / _proposal_reward hooks. Known: cookbook/rsi and tests/cookbook/rsi (#345) are written against main's stateless Env / AgenticChallenger API and do not run on v5 yet.
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.
PR type
PR information
Changes
server/modelandserver/sampler, with nestedpool/packages for scheduling. Update configuration examples, user documentation and the related resource/state/SDK tests.Usage
Upgrade the server and Twinkle SDK together. Keep the existing
applicationsYAML format. In theargsof animport_path: modelapplication, configure:min_replicas: 0defers model loading until the first training request. Set a positive minimum to retain resident instances.max_replicaslimits training instances;max_loraslimits LoRA handles per instance. Keepdevice_groupanddevice_meshfor each instance's device count and parallelism. Megatron requires at least two devices per instance.idle_timeout_s. Heartbeats and result polling do not renew it; admitted queued/running operations remain protected. Existingadapter_config.adapter_timeoutandadapter_max_lifetimeindependently control heartbeat loss and absolute lifetime.train_mode: full, removemax_loras, and create the training withconfig=None. To expose LoRA and Full for the same weights, use separate model applications with different names and routes.Validate and launch the configuration:
Create and release training through the existing SDK methods; the SDK handles training IDs internally:
Tinker keeps its existing training-client creation and unload APIs. Save checkpoints regularly; after expiry or controller restart, create a new training handle and explicitly resume the checkpoint. Clients sharing a token also share
per_token_model_limit.To enable sampling scale-out and scale-in, set these fields in the sampler application's
args:This keeps two instances, scales up to four as demand grows, and removes extra instances after 600 idle seconds. Configure devices per instance separately; clients do not choose instance IDs. Reapply custom runtime settings such as templates after a service restart.
Start from the Transformers configuration or Megatron configuration. Auto-generated YAML retains its original application name, layout, environment location and adapter heartbeat configuration, with only the required on-demand fields and device-count validation added.
Dependency and review scope
main. fix: correct adapter state reuse and streaming completion #341 owns the generic model-state, distributed adapter, Hybrid and streaming-completion fixes; this PR adds on-demand resource management and its integration.main, the shared backend patches also appear in this PR's diff againstmain. Review and merge fix: correct adapter state reuse and streaming completion #341 first, then refresh this PR againstmain.Experiment results
7c741d84806cd572adcf0403670c3f7472e5e57a. The current runtime/config integration suite passes 65 CPU cases; fix: correct adapter state reuse and streaming completion #341 independently passes 76 backend CPU cases, including real two-process DDP. Both selected suites have zero failures, errors or skips. Changed source hooks and diff checks pass; GitHub checks must complete on the updated heads.a02b7595f78d597efb2bf2ccdf85b5f7c3266f52: 1068 distinct selected CPU cases, 17 real PPU pytest executions and a separate two-PPU FSDP slot probe pass. Both SDKs cover training/save/restore/continued optimizer updates on Transformers/Redis and Megatron/Memory; restored logprob differences are zero.18b9f910; this update changes PR ownership and test placement, adding two CPU reset-contract cases. Previous PPU results are retained for the unchanged execution/probe/config scope; no new hardware run is claimed.