Skip to content

perf(bagel): pack FlowGRPO replay steps - #384

Draft
zzhuoxin1508 wants to merge 3 commits into
Tencent-Hunyuan:mainfrom
zzhuoxin1508:feat/bagel-replay-step-packing
Draft

perf(bagel): pack FlowGRPO replay steps#384
zzhuoxin1508 wants to merge 3 commits into
Tencent-Hunyuan:mainfrom
zzhuoxin1508:feat/bagel-replay-step-packing

Conversation

@zzhuoxin1508

@zzhuoxin1508 zzhuoxin1508 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add pipeline.batch_replay_steps as the Bagel replay-packing opt-in
  • when enabled, pack every runtime-resolved SDE target (K = len(target)) as isolated Navit varlen sequences in one forward
  • repeat the generation KV context for T2I/IT2I and vectorize the Flow SDE transition
  • preserve per-sequence projection/MLP reduction boundaries so packed BF16 replay keeps serial-equivalent gradients

Scope

  • Bagel FlowGRPO T2I/IT2I only
  • no CFG support (cfg_text_scale=cfg_img_scale=1 is required)
  • retain each recipe's existing rollout/replay anchor policy
  • no unified-model, shared algorithm, benchmark, or profiling changes

Validation

@github-actions github-actions Bot added the wip Draft / work in progress label Aug 20, 2026
@zzhuoxin1508
zzhuoxin1508 force-pushed the feat/bagel-replay-step-packing branch from f31f6e0 to a38099c Compare August 20, 2026 03:04
Pack no-CFG T2I/IT2I replay steps as isolated varlen sequences to reduce repeated FSDP forwards.
@zzhuoxin1508
zzhuoxin1508 force-pushed the feat/bagel-replay-step-packing branch from a38099c to b66085a Compare August 20, 2026 03:13
@zzhuoxin1508 zzhuoxin1508 changed the title feat(bagel): batch replay steps with packed varlen attention perf(bagel): pack FlowGRPO replay steps Aug 20, 2026
Use pipeline.batch_replay_steps as the only opt-in and pack all runtime-resolved SDE targets.
@zzhuoxin1508

Copy link
Copy Markdown
Collaborator Author

bagel test resultClipboard_Screenshot_1787284397
Clipboard_Screenshot_1787284460

@zzhuoxin1508

zzhuoxin1508 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

BAGEL IT2I packed replay — 300-rollout result

  • Setup: 8×H20, vLLM-Omni DP8, 10,732-sample real image-edit dataset, 14 diffusion steps, 3-step SDE window, 8 samples/prompt.
  • Correctness: completed 300/300 rollouts without reward collapse; final reward 1.523.
  • Gradient parity: full-LoRA packed-vs-serial relative error ~0.4%; log-prob relative error 6.5e-8.
  • Performance (matched rollouts 5–300):
    • train: 48.05 s packed vs 53.24 s main serial (10.8% faster)
    • end-to-end: 83.25 s packed vs 87.97 s main serial (5.7% faster)
    • throughput: 43.24 vs 40.92 rollouts/hour
  • Reward over final 50 rollouts: 1.393 packed vs 1.157 main serial.
  • W&B: packed · main serial
Clipboard_Screenshot_1787715000 Clipboard_Screenshot_1787715044

Keep one packed layer traversal while evaluating projection and MLP kernels per sequence, preventing BF16 reduction drift from corrupting replay gradients.
@zzhuoxin1508
zzhuoxin1508 force-pushed the feat/bagel-replay-step-packing branch from fe0555c to 2fbfdb3 Compare August 26, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip Draft / work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant