Skip to content

[rl] Add CI for RL integration tests - #2300

Merged
wwwjn merged 58 commits into
mainfrom
gh/wwwjn/11/head
Mar 26, 2026
Merged

wwwjn merged 58 commits into
mainfrom
gh/wwwjn/11/head

Conversation

@wwwjn

@wwwjn wwwjn commented Jan 29, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Test cases:

  1. Integration tests:
    • multiple GPU (with TP), no compile + cudagraph
    • multiple GPU, with compile + cudagraph
    • This test runs on A10G (default CI GPU type), and uses FA2 for attention part as FA3 doesn't support A10G machine.
  2. Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.
    • test_weights_match: max_diff <= 1e-5 (exact weight loading)
    • test_attention_module: atol=1e-5 (TP=1)
    • test_end_to_end_logits: atol=1e-3 (TP=1)
    • We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed.
    • This test runs on H100, and runs FA3 kernel for attention.

Both tests are downloading from huggingface and run test on qwen3 0.6B.

wwwjn added 2 commits January 29, 2026 15:20
fix comments

remove tests

add enable_gqa flag

[ghstack-poisoned]
wwwjn added a commit that referenced this pull request Jan 29, 2026
ghstack-source-id: 8c6be25
Pull Request resolved: #2300
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 29, 2026
@wwwjn wwwjn changed the title Add numerics test against vllm native inference [rl] Add numerics test against vllm native inference Jan 29, 2026
wwwjn added a commit that referenced this pull request Jan 30, 2026
ghstack-source-id: 8b01174
Pull Request resolved: #2300
wwwjn added a commit that referenced this pull request Feb 2, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* #2300
* __->__ #2299

Following #2259

Context: Fix RL attention implementation, add numerics check scripts
comparing torchtitan Qwen3 model (with vllm wrapper) and vllm native
Qwen3 model

NOTE: I tried enabling CI for this work, but need more efforts install
vllm from source code (need to build vllm from scratch). Will enable CI
in later PRs
@wwwjn
wwwjn changed the base branch from gh/wwwjn/11/base to main February 2, 2026 21:58
wwwjn added a commit that referenced this pull request Feb 4, 2026
ghstack-source-id: 901fbce
Pull Request resolved: #2300
@wwwjn wwwjn closed this Feb 4, 2026
@wwwjn wwwjn reopened this Feb 17, 2026
[ghstack-poisoned]
@wwwjn
wwwjn requested review from fegin and wconstab as code owners February 17, 2026 22:59
wwwjn added a commit that referenced this pull request Feb 17, 2026
ghstack-source-id: be16fd9
Pull Request resolved: #2300
@wwwjn
wwwjn changed the base branch from main to gh/wwwjn/11/base February 17, 2026 23:00
[ghstack-poisoned]
[ghstack-poisoned]
wwwjn added a commit that referenced this pull request Feb 17, 2026
ghstack-source-id: 3aac54c
Pull Request resolved: #2300
[ghstack-poisoned]
wwwjn added 2 commits March 23, 2026 19:13
… native inference"


Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and uses FA2 for attention part.
2. Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed. 
    - This test runs on H100, and runs FA3 kernel for attention. 


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and uses FA2 for attention part.
2. Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed. 
    - This test runs on H100, and runs FA3 kernel for attention. 


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
wwwjn added a commit that referenced this pull request Mar 24, 2026
ghstack-source-id: 0574338
Pull Request resolved: #2300
wwwjn added 2 commits March 24, 2026 11:42
… native inference"


Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed. 
    - This test runs on H100, and runs FA3 kernel for attention. 


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed. 
    - This test runs on H100, and runs FA3 kernel for attention. 


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
wwwjn added a commit that referenced this pull request Mar 24, 2026
ghstack-source-id: af3023c
Pull Request resolved: #2300
wwwjn added 2 commits March 24, 2026 14:30
… native inference"


Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.~
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - ~We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.~
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - ~We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
wwwjn added a commit that referenced this pull request Mar 24, 2026
ghstack-source-id: 2d954cc
Pull Request resolved: #2300
@wwwjn wwwjn changed the title [rl] Add CI for numerics test against vllm native inference [rl] Add CI for RL integration tests Mar 24, 2026
@wwwjn

wwwjn commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Update: remove numerics test in this PR.

Will adding more rigorous numerics test along with deterministic mode in next PRs. Discussed with @tianyu-l offline, we should aim for adding the numerics using the same pattern with pre-training side CI:

  1. Locally check our model numerics matches vllm.
  2. Enable deterministic mode. Run with specific task and getting training metrics , eg reward , loss. Record these metrics in a file.
  3. Run CI to compare against the loss in the file.

@wwwjn
wwwjn requested a review from tianyu-l March 24, 2026 23:33
# the varlen attention API to work with paged attention (KV cache in block
# layout) because vLLM uses default page size 16 but FA2 only supports
# page_size=256. Error out if FA3 is not available in the current environment.
if current_flash_attention_impl() != "FA3":

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.

why deleting this line? I'm not sure if there's a cost associated with this line. cc @liangel-02 @zhxchen17

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.

Previously the check is saying if current attention is not FA3, then we should activate FA3. However on A20G machine, this should not be true as we want to use FA2 instead of FA3.

So I changed the check to be if the machine has SM 9.0+, then activate FA3

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.

Oh that's not what I was asking. I'm asking why don't we do

if has_cuda_capability(9, 0):
  if current_flash_attention_impl() != "FA3":
    activate_flash_attention_impl("FA3")

why do we omit if current_flash_attention_impl() != "FA3": now? If it is not helping, why we have it before?

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.

You are right, it will just activate FA3 once, not every layer's attention. Changed

wwwjn added 2 commits March 25, 2026 08:20
Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.~
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - ~We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.~
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - ~We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
wwwjn added a commit that referenced this pull request Mar 25, 2026
ghstack-source-id: cfcf452
Pull Request resolved: #2300
# the varlen attention API to work with paged attention (KV cache in block
# layout) because vLLM uses default page size 16 but FA2 only supports
# page_size=256. Error out if FA3 is not available in the current environment.
if current_flash_attention_impl() != "FA3":

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.

Oh that's not what I was asking. I'm asking why don't we do

if has_cuda_capability(9, 0):
  if current_flash_attention_impl() != "FA3":
    activate_flash_attention_impl("FA3")

why do we omit if current_flash_attention_impl() != "FA3": now? If it is not helping, why we have it before?

wwwjn added 2 commits March 25, 2026 17:31
Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.~
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - ~We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
   - This test runs on A10G (default CI GPU type),  and **uses FA2 for attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan wrapper.~
    - test_weights_match:          max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
    - ~We would need to run numerics test for only TP=1. This is because we are assuming both torchtitan and vllm will make sure their multi-GPU implementation is on par with single GPU. And we can add more numerics test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.

[ghstack-poisoned]
wwwjn added a commit that referenced this pull request Mar 26, 2026
ghstack-source-id: b9e3f79
Pull Request resolved: #2300
@wwwjn
wwwjn merged commit 0fb79c5 into main Mar 26, 2026
23 of 32 checks passed
@tianyu-l
tianyu-l deleted the gh/wwwjn/11/head branch March 26, 2026 00:46
pytorch-bot Bot pushed a commit that referenced this pull request Mar 27, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ #2300

Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
- This test runs on A10G (default CI GPU type), and **uses FA2 for
attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan
wrapper.~
- test_weights_match: max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
- ~We would need to run numerics test for only TP=1. This is because we
are assuming both torchtitan and vllm will make sure their multi-GPU
implementation is on par with single GPU. And we can add more numerics
test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.
acisseJZhong pushed a commit that referenced this pull request Mar 31, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ #2300

Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
- This test runs on A10G (default CI GPU type), and **uses FA2 for
attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan
wrapper.~
- test_weights_match: max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
- ~We would need to run numerics test for only TP=1. This is because we
are assuming both torchtitan and vllm will make sure their multi-GPU
implementation is on par with single GPU. And we can add more numerics
test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* pytorch#2300
* __->__ pytorch#2299

Following pytorch#2259

Context: Fix RL attention implementation, add numerics check scripts
comparing torchtitan Qwen3 model (with vllm wrapper) and vllm native
Qwen3 model

NOTE: I tried enabling CI for this work, but need more efforts install
vllm from source code (need to build vllm from scratch). Will enable CI
in later PRs
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ pytorch#2300

Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
- This test runs on A10G (default CI GPU type), and **uses FA2 for
attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan
wrapper.~
- test_weights_match: max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
- ~We would need to run numerics test for only TP=1. This is because we
are assuming both torchtitan and vllm will make sure their multi-GPU
implementation is on par with single GPU. And we can add more numerics
test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* pytorch#2300
* __->__ pytorch#2299

Following pytorch#2259

Context: Fix RL attention implementation, add numerics check scripts
comparing torchtitan Qwen3 model (with vllm wrapper) and vllm native
Qwen3 model

NOTE: I tried enabling CI for this work, but need more efforts install
vllm from source code (need to build vllm from scratch). Will enable CI
in later PRs
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ pytorch#2300

Test cases:
1. Integration tests: 
   - multiple GPU (with TP),  no compile + cudagraph
   - multiple GPU, with compile + cudagraph
- This test runs on A10G (default CI GPU type), and **uses FA2 for
attention part as FA3 doesn't support A10G machine.**
2. ~Numerics parity test: vLLM native model vs vLLM + TorchTitan
wrapper.~
- test_weights_match: max_diff <= 1e-5 (exact weight loading)
    - test_attention_module:       atol=1e-5 (TP=1)
    - test_end_to_end_logits:      atol=1e-3 (TP=1)
- ~We would need to run numerics test for only TP=1. This is because we
are assuming both torchtitan and vllm will make sure their multi-GPU
implementation is on par with single GPU. And we can add more numerics
test under parallelism if needed.~
    - ~This test runs on H100, and runs FA3 kernel for attention.~


Both tests are downloading from huggingface and run test on qwen3 0.6B.
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.

5 participants