Skip to content

feat: LoRA IPC weight sync for colocated diffusion GRPO#33

Merged
Rockdu merged 7 commits into
radixark:mainfrom
niehen6174:feat/lora-ipc-weight-sync
Jul 15, 2026
Merged

feat: LoRA IPC weight sync for colocated diffusion GRPO#33
Rockdu merged 7 commits into
radixark:mainfrom
niehen6174:feat/lora-ipc-weight-sync

Conversation

@niehen6174

Copy link
Copy Markdown
Collaborator

Motivation

Add an opt-in LoRA IPC weight sync path for colocated diffusion GRPO training. When --lora-ipc-weight-sync is enabled, miles pushes only lora_A / lora_B tensors to rollout via IPC with weight_update_mode=lora_merge, instead of all-gathering full base weights.
This reduces weight-sync cost from near-100% model parameters to ~1–5% LoRA parameters, while keeping rollout behavior equivalent for correctly mapped models.

Modifications

  • miles/utils/arguments.py
    • Add --lora-ipc-weight-sync
  • miles/backends/fsdp_utils/diffusion_update_weight_utils.py
    • Add PeftLoRAKeyMapper for PEFT → sglang-d LoRA key mapping
    • Add DiffusionUpdateWeightFromTensorLoRAIPC
    • Extend updater API to pass weight_update_mode, lora_alpha, and lora_rank
  • miles/backends/fsdp_utils/actor.py
    • Select DiffusionUpdateWeightFromTensorLoRAIPC when use_lora and lora_ipc_weight_sync
  • miles/backends/sglang_diffusion_utils/sglang_diffusion_engine.py
    • Forward weight_update_mode, lora_alpha, lora_rank in /update_weights_from_tensor
    • Pass lora_target_modules to rollout server args when LoRA IPC is enabled
  • Scripts
    • Enable --lora-ipc-weight-sync in:
      • scripts/run-diffusion-grpo-sd3-ocr-sglang.sh
      • scripts/run-diffusion-grpo-ocr-2gpu-flowgrpo-aligned.sh

Rollout-side LoRA IPC merge is implemented in sglang-d.

Performance

Benchmarks were run on 2-GPU colocate OCR GRPO with 5 rollout cycles, comparing merge baseline vs LoRA IPC.

Weight sync time (perf/update_weights_time)

Model Merge baseline LoRA IPC Speedup
SD3.5 medium ~4.2–5.4s ~1.3–1.6s ~3×
Qwen-Image ~24–28s 6–7s ~3–4×

Rollout-side verification:

  • Qwen IPC sync: 720 / 720 LoRA layers updated, 0 skipped
  • SD3.5 IPC sync: 191 / 191 LoRA layers updated, 0 skipped

Train/inference consistency on Qwen-Image

We compared LoRA IPC vs the existing merged-weight sync path on the same Qwen-Image OCR colocate setup (10 rollout steps). The plot below shows train/log_prob_mean_abs_diff over training steps:
merge_vs_lora_ipc_compare

Both paths remain on the same order of magnitude (~1e-5 to ~5e-5). Step 1 is bit-identical, and later steps stay numerically close. This suggests LoRA IPC does not materially affect train/rollout log-prob consistency on Qwen-Image.

Sync only lora_A/lora_B tensors to rollout via weight_update_mode=lora_merge,
avoiding full merged DiT weight gather and IPC transfer each step.
Select DiffusionUpdateWeightFromTensorLoRAIPC when enabled, and pass
lora_merge metadata plus target modules to rollout weight updates.
Comment thread miles/backends/fsdp_utils/diffusion_update_weight_utils.py
Comment thread miles/backends/sglang_diffusion_utils/sglang_diffusion_engine.py Outdated
Fill per-model LoRA target modules during arg validation so rollout IPC sync
does not re-resolve config at engine startup. Add CPU CI tests for
PeftLoRAKeyMapper and server-args wiring.
@Rockdu Rockdu merged commit 751c626 into radixark:main Jul 15, 2026
10 checks passed
@Rockdu

Rockdu commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Nice, merged!

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