Repository navigation
[DO NOT MERGE] stacked multi-lora full PR - #2846
yueming-yuan wants to merge 383 commits into
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
deec6fc to
3aa1645
Compare
5e1130b to
1287821
Compare
56a39c1 to
7739862
Compare
1287821 to
40e81ab
Compare
# Conflicts: # miles/tinker/core/service.py
| trains_attn=bool(target_modules & {"q_proj", "k_proj", "v_proj", "o_proj"}), | ||
| trains_mlp=bool(target_modules & {"gate_proj", "up_proj", "down_proj"}), | ||
| trains_unembed="lm_head" in target_modules, | ||
| ) |
There was a problem hiding this comment.
max_tokens_per_datum should come from the trainer limit. the example runs with --max-tokens-per-gpu 8192, but this keeps the 32768 default. get_minimum_num_micro_batch_size() does not split or reject one oversized sequence, so an 8193–32768-token datum is admitted and placed alone in an over-budget microbatch. can we derive this from args.max_tokens_per_gpu and the model context limit, and add a boundary test?
| vocab_size=vocab_size, | ||
| lora_alpha=args.lora_alpha, | ||
| max_lora_rank=args.lora_rank, | ||
| trains_attn=bool(target_modules & {"q_proj", "k_proj", "v_proj", "o_proj"}), |
There was a problem hiding this comment.
these booleans collapse partial and model-specific target layouts into a contract tinker cannot represent. for example, --target-modules linear_qkv sets trains_attn=true even though o_proj is not trained, while an mla-only attention layout reports false. can we canonicalize the targets once and reject layouts that are not exactly representable by train_attn, train_mlp, and train_unembed, with tests for partial and mla layouts?
Combined view of the multi-LoRA v2 stack against
main. Do not merge this PR; land the component PRs in order.Tinker training runs through ordered per-model streams and per-slot optimizers.
lora/actor.pyextendsMegatronTrainRayActorwith the slot commands;lora/model.py:run_forward_backwardextends the shared model execution. The worker spec selects the subclass only for Megatron multi-LoRA actor workers.Saving sampler weights exports the current adapter into an immutable directory containing tensors, adapter config, and ownership/base-model metadata. Saving neither applies nor discards pending gradients. Engines load the same frozen HF base at startup and load adapter snapshots from disk on demand; sampler saves make no inference-engine calls.
training_utils/weight_update/snapshot_publisher.pyreuses the shared HF iterator and checkpoint directory transaction. The multi-LoRA actor initializes the publisher; the general actor initializes the ordinary updater for full-model and single-LoRA training. Checkpoint load/save/export execution errors, including filesystem errors, propagate through TrainerCell and stop the current single-cell service.load_staterejects sampler snapshots before reaching the Megatron checkpoint loader;weights_inforetains metadata support for both checkpoint kinds. Checkpoint names are relative symlinks to immutable version directories. The shared writer completes shards and metadata before atomically replacing the public link. A process crash leaves the old or new complete checkpoint reachable; older versions remain on disk for readers that already resolved them. Legacy directory checkpoints remain readable, but overwriting them is unsupported: save under a new name. Successful phases retain their collective barriers; execution errors still propagate to the trainer cell. A TODO records deferred IO failure isolation.A terminal training failure ends the affected model stream, including queued commands, while completed futures retain their results. Known request-local forward-only and sampling failures preserve healthy training resources; a failed sample leaves its snapshot usable. Futures, leases, deduplication, and unsaved accumulation remain process-local. Automatic training recovery and replay are not implemented.
The combined branch and #2849 have the same head:
5ccde8dcde766c2290b721545ce6f0758e51dae2. Checkpoint publication belongs to #2842, the FT harness correction to #2843, gateway validation and checkpoint path handling to #2844, and documentation/tests to #2849. The changes cascade through #2845 and downstream #3198.Request completion is centralized in
_finish_request; checkpoint utilities are stateless, validation remains in the service, and the dispatcher owns background-task shutdown. The final #3198 tree exactly matches reviewed commitde7a5565e82cb6c89e26174d5a2b26980648e086, including the existing single-LoRA checkpoint changes. All updated branches preserve their previous heads as ancestors.Validation:
pre-commit run --all-filesand incrementalgit diff --checkpassed on every updated component head. All previous heads remain ancestors; the final Unify HF snapshot and checkpoint writing #3198 tree exactly matches the reviewed implementation.tests/e2e/lora/test_slot_checkpoint_resume.py(Hopper, LoRA, 2-GPU stage). The tested final tree is Unify HF snapshot and checkpoint writing #3198fd63c7ec8c41c2e0a61d273f0cd5a3504275ada7, with Megatron73b54618f7e58e0f25f619bcfecbe2640765475a, Bridge40b930897717941cfe2bd9806f417e28bf1bfa65, PyTorch 2.13.0+cu130 and Transformer Engine 2.17.0. Checkpoints were on GPFS.pre-commit run --all-filespassed.run-ci-multi-lora; their first GPU validation is pending.ci-megatron-pr: 73b54618f7e58e0f25f619bcfecbe2640765475a
ci-sglang-pr: 02b5e123c490c988d21526d0dd7837fefdd0e1da
Router dependency: install the router wheel and standalone binary from the existing
cu130-torch213-x86_64/cu130-torch213-aarch64rolling releases inyueming-yuan/miles-wheels, using the normal/tmp/wheelsinstallation path. Both architectures were rebuilt on CPU devboxes fromradixark/sgl-router-for-miles@b6342a3515e259bbd1eb4db728035a4efbe4fdf9and verified to forwardreturn_indexer_topkandlora_backfill_paths. No commit-specific router release is required. The existingpr-2849Docker image has not been rebuilt by this change.Tinker GPU CI: add
tests/e2e/lora/test_tinker_multi_tenant_gateway.pyand enable the cookbook gateway test. Both carry themulti-loradomain, selected by the repository labelrun-ci-multi-lora, on 8 H200 GPUs. They share Qwen3-4B gateway setup (4 training GPUs, TP2/DP2; 4 sampling GPUs; rank-8 adapters). The multi-tenant client trains four distinct markers concurrently, exports each adapter, and checks loss decrease and its own sampled marker.Validation: the real CI selector selects exactly both enabled tests for
run-ci-multi-lora; mocked entrypoint checks confirm both client commands and launcher cleanup. Full pre-commit passed. GPU convergence, cookbook execution, and end-to-end tenant isolation have not yet been validated.