Skip to content

[GraphTrainer][AutoDev] Accept float inputs in CUDAGraphWrapper - #2876

Merged
SherlockNoMad merged 1 commit into
mainfrom
graph_trainer/cudagraph-float-inputs
Apr 7, 2026
Merged

SherlockNoMad merged 1 commit into
mainfrom
graph_trainer/cudagraph-float-inputs

Conversation

@SherlockNoMad

Copy link
Copy Markdown
Contributor

Summary

  • Add float to the supported input types in CUDAGraphWrapper._check_input_types
  • The aot_fx_trace joint graph can produce float-valued inputs (e.g. global_valid_tokens scaling factor), which previously caused a ValueError during CUDA graph recording
  • Float inputs are treated as static constants baked into the graph at recording time (they are not in _input_indices_to_copy, so they won't be updated on replay)

Context

Spun off from PR #2868 review feedback. The original error was:

ValueError: args must be tensor, integer (for dynamic shapes), Generator (for random number generator), or opaque object, but found <class 'float'> with value 65536.0 at index 117

Test plan

  • pre-commit run --all-files passes (all hooks green)
  • pytest torchtitan/experiments/graph_trainer/tests/test_passes.py -x — 12/12 passed
  • pytest torchtitan/experiments/graph_trainer/tests/test_precompile.py -x — 24/24 passed

…ypes

The aot_fx_trace joint graph can have float-valued inputs (e.g.
global_valid_tokens scaling factor). Add float to the supported input
types so that CUDAGraphWrapper does not reject these inputs during
recording.

Spun off from PR #2868 review feedback.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 7, 2026
@SherlockNoMad
SherlockNoMad marked this pull request as ready for review April 7, 2026 20:29
@SherlockNoMad

Copy link
Copy Markdown
Contributor Author

Valid fix, ready to land.

@SherlockNoMad
SherlockNoMad merged commit 762a24e into main Apr 7, 2026
18 of 26 checks passed
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
…rch#2876)

## Summary

- Add `float` to the supported input types in
`CUDAGraphWrapper._check_input_types`
- The aot_fx_trace joint graph can produce float-valued inputs (e.g.
`global_valid_tokens` scaling factor), which previously caused a
`ValueError` during CUDA graph recording
- Float inputs are treated as static constants baked into the graph at
recording time (they are not in `_input_indices_to_copy`, so they won't
be updated on replay)

## Context

Spun off from [PR
pytorch#2868](pytorch#2868) review feedback.
The original error was:
```
ValueError: args must be tensor, integer (for dynamic shapes), Generator (for random number generator), or opaque object, but found <class 'float'> with value 65536.0 at index 117
```

## Test plan

- [x] `pre-commit run --all-files` passes (all hooks green)
- [x] `pytest torchtitan/experiments/graph_trainer/tests/test_passes.py
-x` — 12/12 passed
- [x] `pytest
torchtitan/experiments/graph_trainer/tests/test_precompile.py -x` —
24/24 passed
jemitche1 pushed a commit to jemitche1/torchtitan that referenced this pull request Apr 14, 2026
…rch#2876)

## Summary

- Add `float` to the supported input types in
`CUDAGraphWrapper._check_input_types`
- The aot_fx_trace joint graph can produce float-valued inputs (e.g.
`global_valid_tokens` scaling factor), which previously caused a
`ValueError` during CUDA graph recording
- Float inputs are treated as static constants baked into the graph at
recording time (they are not in `_input_indices_to_copy`, so they won't
be updated on replay)

## Context

Spun off from [PR
pytorch#2868](pytorch#2868) review feedback.
The original error was:
```
ValueError: args must be tensor, integer (for dynamic shapes), Generator (for random number generator), or opaque object, but found <class 'float'> with value 65536.0 at index 117
```

## Test plan

- [x] `pre-commit run --all-files` passes (all hooks green)
- [x] `pytest torchtitan/experiments/graph_trainer/tests/test_passes.py
-x` — 12/12 passed
- [x] `pytest
torchtitan/experiments/graph_trainer/tests/test_precompile.py -x` —
24/24 passed
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
…rch#2876)

## Summary

- Add `float` to the supported input types in
`CUDAGraphWrapper._check_input_types`
- The aot_fx_trace joint graph can produce float-valued inputs (e.g.
`global_valid_tokens` scaling factor), which previously caused a
`ValueError` during CUDA graph recording
- Float inputs are treated as static constants baked into the graph at
recording time (they are not in `_input_indices_to_copy`, so they won't
be updated on replay)

## Context

Spun off from [PR
pytorch#2868](pytorch#2868) review feedback.
The original error was:
```
ValueError: args must be tensor, integer (for dynamic shapes), Generator (for random number generator), or opaque object, but found <class 'float'> with value 65536.0 at index 117
```

## Test plan

- [x] `pre-commit run --all-files` passes (all hooks green)
- [x] `pytest torchtitan/experiments/graph_trainer/tests/test_passes.py
-x` — 12/12 passed
- [x] `pytest
torchtitan/experiments/graph_trainer/tests/test_precompile.py -x` —
24/24 passed
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.

2 participants