Skip to content

[Experimental][rl][unified] Update infer.py example to work with vLLM nightly - #2226

Merged
tianyu-l merged 4 commits into
pytorch:mainfrom
Lucaskabela:lucaskabela/update_rl_unified
Jan 19, 2026
Merged

tianyu-l merged 4 commits into
pytorch:mainfrom
Lucaskabela:lucaskabela/update_rl_unified

Conversation

@Lucaskabela

@Lucaskabela Lucaskabela commented Jan 13, 2026 •

Copy link
Copy Markdown
Contributor

NOTE: This PR should be landed on top of #2219

Few changes seem to be needed to get working; namely:

  1. Update to use spawn method for CUDA fork
  2. Modify attention import to be correct after refactor
  3. Modify attention dimensions to be correct after refactor

Test Plan

Follow steps in the readme then run

python torchtitan/experiments/rl/unified/infer.py --model-ckpt-path torchtitan/experiments/rl/example_checkpoint/Qwen3-0.6B

Output

[2026-01-13 15:20:58] INFO infer.py:113: Generation complete

Prompt: Hello, my name is
Generated text: " Josh and I'm in the middle of a project to develop a hybrid mobile app. I'm looking for guidance on how to go about using modular frameworks. I want to use React and Vue. I need to decide on the framework to use. Can you help me choose the right framework and suggest some best practices for using them?\n\nAdditionally, I want to know what are the best practices for using a modular framework in the context of a web application? Also, what are the best practices for using a"

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 13, 2026
@Lucaskabela

Copy link
Copy Markdown
Contributor Author

cc @wwwjn @acisseJZhong for review :)

@acisseJZhong

acisseJZhong commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

LGTM! thanks for the fix. Curious why vllm's Attention requires batch and seq_len dim flattened? Is attention input shape (batch, seq_len, num_heads, head_dim) no longer working?

@Lucaskabela
Lucaskabela marked this pull request as ready for review January 14, 2026 00:15
@Lucaskabela

Copy link
Copy Markdown
Contributor Author

LGTM! thanks for the fix. Curious why vllm's Attention requires batch and seq_len dim flattened? Is attention input shape (batch, seq_len, num_heads, head_dim) no longer working?

Yes I got this particular error:

File "/home/lucaskabela/torchtitan/torchtitan/experiments/rl/unified/models/attention.py", line 88, in forward
(EngineCore_DP0 pid=3139209) ERROR 01-13 15:17:35 [core.py:936]     output = output_varlen.view(batch_size, seq_len, num_heads, head_dim)
(EngineCore_DP0 pid=3139209) ERROR 01-13 15:17:35 [core.py:936]              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(EngineCore_DP0 pid=3139209) ERROR 01-13 15:17:35 [core.py:936] RuntimeError: shape '[1, 16384, 16, 128]' is invalid for input of size 2048

Let me see if I can link the actual pr doing the attention change on vLLM side

@Lucaskabela

Copy link
Copy Markdown
Contributor Author

Ah sorry - that actually seems like just an output issue, probably doesn't need the input reshape let me see if I can refactor it simpler

@Lucaskabela

Copy link
Copy Markdown
Contributor Author

I took a look, and seems that this refactor (vllm-project/vllm#31596) caused the 4d input to not be handled correctly - only 2d and 3d input is handled so this change seems necessary

cc @acisseJZhong

@acisseJZhong

Copy link
Copy Markdown
Contributor

I took a look, and seems that this refactor (vllm-project/vllm#31596) caused the 4d input to not be handled correctly - only 2d and 3d input is handled so this change seems necessary

cc @acisseJZhong

looks like there's an ongoing fix for 4d input vllm-project/vllm#32274

@Lucaskabela
Lucaskabela force-pushed the lucaskabela/update_rl_unified branch from 812a781 to 11a8810 Compare January 15, 2026 17:20
@Lucaskabela Lucaskabela changed the title [Experimental][rl][unified] Update infer.py example to work with vLLM nightly [Not4Review][Experimental][rl][unified] Update infer.py example to work with vLLM nightly Jan 15, 2026
@Lucaskabela
Lucaskabela force-pushed the lucaskabela/update_rl_unified branch from 11a8810 to 7204c09 Compare January 16, 2026 19:28
@pytorch-bot pytorch-bot Bot removed the ciflow/8gpu label Jan 16, 2026
@Lucaskabela Lucaskabela changed the title [Not4Review][Experimental][rl][unified] Update infer.py example to work with vLLM nightly [Experimental][rl][unified] Update infer.py example to work with vLLM nightly Jan 16, 2026
@Lucaskabela

Lucaskabela commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for patience - the lintrunner signal seems preexisting :) ready for re-review

@tianyu-l tianyu-l 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.

Thanks!

@tianyu-l
tianyu-l merged commit a085b0e into pytorch:main Jan 19, 2026
wwwjn pushed a commit to wwwjn/torchtitan that referenced this pull request Jan 30, 2026
… nightly (pytorch#2226)

NOTE: This PR should be landed on top of
pytorch#2219

Few changes seem to be needed to get working; namely:

1) Update to use `spawn` method for CUDA fork
2) Modify attention import to be correct after refactor
3) Modify attention dimensions to be correct after refactor

Follow steps in the readme then run
```
python torchtitan/experiments/rl/unified/infer.py --model-ckpt-path torchtitan/experiments/rl/example_checkpoint/Qwen3-0.6B
```

```
[2026-01-13 15:20:58] INFO infer.py:113: Generation complete

Prompt: Hello, my name is
Generated text: " Josh and I'm in the middle of a project to develop a hybrid mobile app. I'm looking for guidance on how to go about using modular frameworks. I want to use React and Vue. I need to decide on the framework to use. Can you help me choose the right framework and suggest some best practices for using them?\n\nAdditionally, I want to know what are the best practices for using a modular framework in the context of a web application? Also, what are the best practices for using a"
```
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
… nightly (pytorch#2226)

NOTE: This PR should be landed on top of
pytorch#2219

Few changes seem to be needed to get working; namely:

1) Update to use `spawn` method for CUDA fork
2) Modify attention import to be correct after refactor
3) Modify attention dimensions to be correct after refactor

### Test Plan
Follow steps in the readme then run
```
python torchtitan/experiments/rl/unified/infer.py --model-ckpt-path torchtitan/experiments/rl/example_checkpoint/Qwen3-0.6B
```

### Output

```
[2026-01-13 15:20:58] INFO infer.py:113: Generation complete

Prompt: Hello, my name is
Generated text: " Josh and I'm in the middle of a project to develop a hybrid mobile app. I'm looking for guidance on how to go about using modular frameworks. I want to use React and Vue. I need to decide on the framework to use. Can you help me choose the right framework and suggest some best practices for using them?\n\nAdditionally, I want to know what are the best practices for using a modular framework in the context of a web application? Also, what are the best practices for using a"
```
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
… nightly (pytorch#2226)

NOTE: This PR should be landed on top of
pytorch#2219

Few changes seem to be needed to get working; namely:

1) Update to use `spawn` method for CUDA fork
2) Modify attention import to be correct after refactor
3) Modify attention dimensions to be correct after refactor

### Test Plan
Follow steps in the readme then run
```
python torchtitan/experiments/rl/unified/infer.py --model-ckpt-path torchtitan/experiments/rl/example_checkpoint/Qwen3-0.6B
```

### Output

```
[2026-01-13 15:20:58] INFO infer.py:113: Generation complete

Prompt: Hello, my name is
Generated text: " Josh and I'm in the middle of a project to develop a hybrid mobile app. I'm looking for guidance on how to go about using modular frameworks. I want to use React and Vue. I need to decide on the framework to use. Can you help me choose the right framework and suggest some best practices for using them?\n\nAdditionally, I want to know what are the best practices for using a modular framework in the context of a web application? Also, what are the best practices for using a"
```
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
… nightly (pytorch#2226)

NOTE: This PR should be landed on top of
pytorch#2219

Few changes seem to be needed to get working; namely:

1) Update to use `spawn` method for CUDA fork
2) Modify attention import to be correct after refactor
3) Modify attention dimensions to be correct after refactor

### Test Plan
Follow steps in the readme then run
```
python torchtitan/experiments/rl/unified/infer.py --model-ckpt-path torchtitan/experiments/rl/example_checkpoint/Qwen3-0.6B
```

### Output

```
[2026-01-13 15:20:58] INFO infer.py:113: Generation complete

Prompt: Hello, my name is
Generated text: " Josh and I'm in the middle of a project to develop a hybrid mobile app. I'm looking for guidance on how to go about using modular frameworks. I want to use React and Vue. I need to decide on the framework to use. Can you help me choose the right framework and suggest some best practices for using them?\n\nAdditionally, I want to know what are the best practices for using a modular framework in the context of a web application? Also, what are the best practices for using a"
```
@Lucaskabela
Lucaskabela deleted the lucaskabela/update_rl_unified branch May 6, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants