Skip to content

[rl] Fix the RL load weights bug: fused qkv load hooks are bypassed - #3794

Merged
wwwjn merged 4 commits into
mainfrom
fix-qwen3-fused-qkv-hf-load
Jun 25, 2026
Merged

wwwjn merged 4 commits into
mainfrom
fix-qwen3-fused-qkv-hf-load

Conversation

@wwwjn

@wwwjn wwwjn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@wwwjn
wwwjn requested review from tianyu-l and removed request for tianyu-l June 25, 2026 21:49
@wwwjn
wwwjn requested a review from felipemello1 June 25, 2026 21:49
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 25, 2026

@felipemello1 felipemello1 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this a workaround or the right way of doing it (calling load_state_dict twice)?

# state_dict() returns hook-produced copies for fused modules (e.g.
# FusedQKVLinear's wqkv -> wq/wk/wv), so the in-place fill above never
# reaches the real param. Re-apply via load_state_dict to run the merge hook.
self._get_model().model.load_state_dict(model_sd, strict=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

stamping to unblock, but ideally we should avoid extra GPU copies of entire model because of the state_dict hooks.

Add a TODO / issue and follow up with @meetv18

I'm a bit worried about if it makes 235B single-node inference impossible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes this copy is full model weights now, not only fused qkv (maybe I could reduce the amount of copy for just "wqkv")

Let me add this change to 235B singlenode inference test,

@wwwjn
wwwjn merged commit baa6a64 into main Jun 25, 2026
12 of 15 checks passed
felipemello1 pushed a commit to felipemello1/torchtitan that referenced this pull request Jun 26, 2026
…-qkv workaround

- trainer.py -> controller.py; batcher.py -> components/batcher.py;
  components/metrics_utils.py -> controller_metrics.py; update all imports.
- Drop _force_non_fused_qkv workaround (real fix pytorch#3794 arrives via the main re-merge).
- Carry minor work_buffer / controller (_pad_id inline) cleanups.
felipemello1 pushed a commit to felipemello1/torchtitan that referenced this pull request Jun 26, 2026
…orch#3794 fuse-qkv fix)

Reconcile our async-loop generator (min/max policy version) onto main's
RequestDispatcher (pytorch#3765: routes to highest DP rank + result fan-in):
- rank 0 stamps min_policy_version on every future in the STEP decision (it owns
  all futures regardless of which DP rank serves the request).
- _build_completions sets min == max (finish version) as a placeholder; rank 0
  replaces min with the true admitted version in _rank0_resolve_futures.
- pytorch#3794 fused-qkv HF-load fix arrives via the merge; our workaround was removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants