Repository navigation
Commit a479991
[megatron] Convert fused-MoE expert LoRA to vLLM layout on adapter sync (#1857)
Closes #1852 @erictang000
Megatron-Bridge exports fused-MoE expert LoRA as 3D
(num_experts-leading) tensors keyed `...mlp.experts.gate_up_proj` /
`...mlp.experts.down_proj`, but vLLM's fused-MoE LoRA loader
(FusedMoE3DWithLoRA / _stack_moe_lora_weights) expects the flat PEFT
layout keyed `...mlp.experts.base_layer` (w13) and `...mlp.experts`
(w2). Without the rewrite, merge_lora=False on-policy sync is rejected
because load_lora_adapter cannot resolve `experts.down_proj`.
Add `_convert_moe_experts_lora_to_vllm` to megatron_utils and apply it
in MegatronPolicyWorkerBase._save_lora_adapters_and_sync before
inferring target modules (dropping the synthetic `base_layer` module).
---------
Co-authored-by: Eric Tang <erictang000@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent bd8b9ea commit a479991
3 files changed
Lines changed: 50 additions & 12 deletions
File tree
- skyrl/backends/skyrl_train
- distributed/megatron
- workers/megatron
- tests/train/generators
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
165 | 197 | | |
166 | 198 | | |
167 | 199 | | |
| |||
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
1033 | 1034 | | |
1034 | 1035 | | |
1035 | 1036 | | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1042 | 1041 | | |
1043 | 1042 | | |
1044 | 1043 | | |
| |||
1242 | 1241 | | |
1243 | 1242 | | |
1244 | 1243 | | |
1245 | | - | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
1246 | 1253 | | |
1247 | 1254 | | |
1248 | 1255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
370 | 369 | | |
371 | 370 | | |
372 | 371 | | |
| |||
0 commit comments