Skip to content

Use Miles native canonical LoRA for dense Qwen and Nemotron Nano - #312

Merged
Kailash Ranganathan (kailash109) merged 15 commits into
mainfrom
codex/miles-native-canonical-lora
Nov 18, 2026
Merged

Kailash Ranganathan (kailash109) merged 15 commits into
mainfrom
codex/miles-native-canonical-lora

Conversation

@kailash109

@kailash109 Kailash Ranganathan (kailash109) commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

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 from 39ce4c2 is 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

  • Nine-model stock Tinker 0.39.0 / cookbook 0.6.1 guess-number GRPO regression: all nine pass, 27 accepted updates. Three updates per model, rank 32, batch 8, group 4, 64 generated tokens. Covers Qwen2.5-3B/7B-Instruct, Qwen3-4B/8B, Qwen3.5-2B/4B/9B/9B-Base, and Qwen3.8-27B. Ran Spindle 970dc0e, Miles 5e37a66, SGLang e003cf9, on isolated checkout deployments through the Miles command backend.
  • Nano on Miles 39ce4c2, Spindle 4261cfd: 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.
  • Miles native adapter suite: 243 tests pass. Real two-H200 TP2/EP2 expert regression passes in 74.3 seconds, covering gated/ungated adapters, independent/shared factors, recomputation, export, and cancellation-sensitive forward/backward reductions.
  • Final Spindle CPU suite on 3aa00f4 after 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 minimum 0.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.

@kailash109 Kailash Ranganathan (kailash109) changed the title Use Miles native canonical multi-LoRA for dense Qwen recipes Use Miles native canonical multi-LoRA for supported Qwen recipes Nov 17, 2026
…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.
@kailash109 Kailash Ranganathan (kailash109) changed the title Use Miles native canonical multi-LoRA for supported Qwen recipes Use Miles native canonical LoRA for dense Qwen and Nemotron Nano Nov 17, 2026

@micahtyong Micah Yong (micahtyong) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm w comments

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this separate nano image needed? Is it possible to have a single miles image used for both Nemotron / Qwen model configs?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment on lines +46 to +52
"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",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@kailash109
Kailash Ranganathan (kailash109) merged commit 2666027 into main Nov 18, 2026
3 checks passed
@kailash109
Kailash Ranganathan (kailash109) deleted the codex/miles-native-canonical-lora branch November 18, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants