Repository navigation
Use Miles native canonical LoRA for dense Qwen and Nemotron Nano - #312
Conversation
…nonical-lora # Conflicts: # CHANGELOG.md # reference_runs/README.md
Move Nano to native routed expert adapters and enable deterministic backward and collective kernels. FP32 expert combine makes forwards stable; the deterministic recipe also reproduces optimizer replay exactly at ranks 8 and 16. Keep larger Nemotron recipes on their existing settings.
Micah Yong (micahtyong)
left a comment
There was a problem hiding this comment.
lgtm w comments
There was a problem hiding this comment.
Why is this separate nano image needed? Is it possible to have a single miles image used for both Nemotron / Qwen model configs?
There was a problem hiding this comment.
Oh, I realize this is the case.
All migrated recipes, Qwen and Nano, pin miles-v0.2.0-e814245, so miles-v0.2.0-5e37a66 and miles_native_image.py look unused. Can we drop them, and rename miles_nano_image.py to miles_native_image.py since every native recipe uses it?
| if spec.trainer_image.startswith("miles-v0.2.0-"): | ||
| if config.megatron_to_hf_mode != "bridge": | ||
| raise ValueError("miles-v0.2.0 supports only megatron_to_hf_mode bridge") | ||
| if config.megatron_to_hf_mode == "raw" and config.lora_type != "canonical_lora": |
There was a problem hiding this comment.
This now accepts raw mode with canonical_lora on every miles-v0.2.0-* image, including miles-v0.2.0-15afe21, which rejected raw mode before this PR. Does 15afe21 support native canonical adapters, or only the new images? If only the new ones, could we allow raw mode just for those, so a custom config on 15afe21 fails here instead of at trainer start? Same question for Bridge with canonical_lora on v0.2.0: is that combination tested, or should it be rejected too?
| "miles_cfg.cli_options.deterministic_mode": True, | ||
| "miles_cfg.cli_options.cross_entropy_loss_fusion": False, | ||
| "miles_cfg.cli_options.tp_comm_overlap": False, | ||
| "trainer_env.MAMBA_DETERMINISTIC": "1", | ||
| "trainer_env.NCCL_ALGO": "Ring", | ||
| "trainer_env.NVTE_ALLOW_NONDETERMINISTIC_ALGO": "0", | ||
| "trainer_env.CUBLAS_WORKSPACE_CONFIG": ":4096:8", |
There was a problem hiding this comment.
What do these settings cost in step time compared with the current Nano recipe? Deterministic kernels, Ring-only NCCL and no TP comm overlap can slow training a lot, and every user of this recipe pays for it. Exact optimizer replay is good to have, but if the slowdown is large, could deterministic mode be an opt-in sibling recipe, with this one keeping only the FP32 expert reductions that fix forward drift?
There was a problem hiding this comment.
without these still has a good amt of nondeterminism to the point of getting 0.1+ logprob diff in replayed checkpoint state
will rename it to "deterministic" to give the emphasis that these settings are for exact replay
…nonical-lora # Conflicts: # CHANGELOG.md # docs/deployment-configs.md # src/spindle/configs/nemotron3_nano_30b_a3b_lora_64k.py # src/spindle/configs/qwen25_3b_lora_32k.py # src/spindle/configs/qwen25_7b_instruct_lora_32k.py # src/spindle/configs/qwen35_2b_lora_32k.py # src/spindle/configs/qwen35_4b_lora_32k.py # src/spindle/configs/qwen35_9b_instruct_lora_16k.py # src/spindle/configs/qwen35_9b_instruct_lora_16k_dp2.py # src/spindle/configs/qwen35_9b_instruct_lora_256k.py # src/spindle/configs/qwen35_9b_instruct_lora_32k.py # src/spindle/configs/qwen35_9b_lora_128k.py # src/spindle/configs/qwen35_9b_lora_16k.py # src/spindle/configs/qwen35_9b_lora_16k_single.py # src/spindle/configs/qwen35_9b_lora_2k.py # src/spindle/configs/qwen35_9b_lora_64k.py # src/spindle/configs/qwen38_27b_lora_128k.py # src/spindle/configs/qwen38_27b_lora_16k.py # src/spindle/configs/qwen38_27b_lora_16k_b200.py # src/spindle/configs/qwen38_27b_lora_32k.py # src/spindle/configs/qwen38_27b_lora_64k.py # src/spindle/configs/qwen3_4b_lora_32k.py # src/spindle/configs/qwen3_8b_lora_32k.py # src/spindle/providers/modal/deployment_apps.py
Summary
Move 20 single-node dense Qwen recipes and Nemotron-3 Nano to Miles native canonical multi-LoRA. Q/K/V and MLP gate/up projections have independent adapter factors; Nano includes routed expert adapters. Preserve each recipe's targets and parallel topology. GPT-OSS, larger Nemotron architectures and multi-node recipes retain their existing backend.
Expose
miles_cfg.lora_type, load Bridge provider patches only for Bridge workers, and record the adapter layout in checkpoints so incompatible layouts fail before changing a live slot. Legacy checkpoints require their original image and layout. Register the native trainer in the shared Miles v0.2.0 image builder and add the sampler image, preserving existing named images. Remove the unused intermediate image. Reject the unvalidated Bridge/canonical combination before trainer startup; dense native canonical mode remains allowed on the older v0.2.0 images. Fix malformed CLI field validation and fill the missing cookbook model-name renderer entries used by synmon.Pin every migrated recipe to Miles release head
e8142459617f8220825ddbacf054b8b17cabdd82, after Miles #49 merged. Its runtime tree matches the live-tested revision; the remaining difference from39ce4c2is the GPU regression test.Merged current main, including request-scoped OOM recovery and the reference-run catalog refactor. No generated validation outputs are added.
Testing
970dc0e, Miles5e37a66, SGLange003cf9, on isolated checkout deployments through the Miles command backend.39ce4c2, Spindle4261cfd: two concurrent stock SDK clients at ranks 8 and 16 accepted GRPO updates and published adapters for sampling. A separate full-model TP2/EP2 probe using the final deterministic settings passes at both ranks: repeated-forward, checkpoint restore and next-optimizer-update replay log-probability differences are all 0.0, and replayed gradient norms match exactly. The first drift came from BF16 atomic expert reductions; FP32 reduction fixes forward drift. Exact optimizer replay additionally requires deterministic backward/collective kernels, enabled only for the Nano recipe.3aa00f4after review fixes and merging the frozen-image refactor (Restore frozen Miles image names and name images by fork commit #343): 1,547 passed, 10 skipped. Full formatting, lint, type checks, TOML checks and wheel/sdist build pass. SDK compatibility CI covers minimum0.26.0, image pin and latest.These runs validate execution, adapter publication and checkpoint behavior. They do not establish numerical parity with the hosted Tinker service or learning convergence. Live runs cover one recipe per listed base model, not every context-length, hardware or topology variant. The final main merge is covered by the CPU suite; the nine-model GPU grid ran on the earlier commit stated above. The cost of Nano’s deterministic settings versus the previous Bridge recipe has not been benchmarked; the short numerical probes are not performance comparisons.