Skip to content

Avoid graph break due to unsupported frozenset#7105

Merged
loadams merged 3 commits intodeepspeedai:masterfrom
deepcharm:use-set-to-avoid-graph-break
Mar 4, 2025
Merged

Avoid graph break due to unsupported frozenset#7105
loadams merged 3 commits intodeepspeedai:masterfrom
deepcharm:use-set-to-avoid-graph-break

Conversation

@deepcharm
Copy link
Copy Markdown
Contributor

This PR is a continuation of the efforts to improve Deepspeed performance when using PyTorch compile.

The fetch_sub_module() routine makes use of the frozenset which is problematic because:

  1. iter_params returns an iterable over model parameters
  2. frozenset wraps this iterable, making it unmodifiable
  3. PyTorch’s compilation process cannot infer how frozenset interacts with tensors, leading to a graph break.

If we replace the frozenset with a modifiable set, then there is no longer such graph break.

This PR is a continuation of the efforts to improve Deepspeed performance when using PyTorch compile.

The fetch_sub_module routine makes use of the frozenset which is problematic because:
1) iter_params() returns an iterable over model parameters
2) frozenset() wraps this iterable, making it unmodifiable
3) PyTorch’s compilation process cannot infer how frozenset() interacts with tensors,
   leading to a graph break.

If we replace the frozenset with a modifiable set, there is no longer graph break.

Signed-off-by: Max Kovalenko <mkovalenko@habana.ai>
@loadams loadams enabled auto-merge March 3, 2025 20:19
@loadams loadams added this pull request to the merge queue Mar 4, 2025
Merged via the queue into deepspeedai:master with commit 17c6595 Mar 4, 2025
@deepcharm deepcharm deleted the use-set-to-avoid-graph-break branch March 5, 2025 13:30
saurabhkoshatwar pushed a commit to saurabhkoshatwar/DeepSpeed that referenced this pull request Mar 8, 2025
This PR is a continuation of the efforts to improve Deepspeed
performance when using PyTorch compile.

The `fetch_sub_module()` routine makes use of the `frozenset` which is
problematic because:

1. `iter_params` returns an iterable over model parameters
2. `frozenset` wraps this iterable, making it unmodifiable
3. PyTorch’s compilation process cannot infer how `frozenset` interacts
with tensors, leading to a graph break.

If we replace the `frozenset` with a modifiable `set`, then there is no
longer such graph break.

Signed-off-by: Max Kovalenko <mkovalenko@habana.ai>
Co-authored-by: Masahiro Tanaka <81312776+tohtana@users.noreply.github.com>
Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
Signed-off-by: Saurabh <saurabhkoshatwar1996@gmail.com>
mauryaavinash95 pushed a commit to DataStates/DeepSpeed that referenced this pull request Mar 20, 2025
This PR is a continuation of the efforts to improve Deepspeed
performance when using PyTorch compile.

The `fetch_sub_module()` routine makes use of the `frozenset` which is
problematic because:

1. `iter_params` returns an iterable over model parameters
2. `frozenset` wraps this iterable, making it unmodifiable
3. PyTorch’s compilation process cannot infer how `frozenset` interacts
with tensors, leading to a graph break.

If we replace the `frozenset` with a modifiable `set`, then there is no
longer such graph break.

Signed-off-by: Max Kovalenko <mkovalenko@habana.ai>
Co-authored-by: Masahiro Tanaka <81312776+tohtana@users.noreply.github.com>
Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
loadams pushed a commit that referenced this pull request Mar 25, 2025
This PR is a continuation of the efforts to improve Deepspeed
performance when using PyTorch compile.

The `fetch_sub_module()` routine makes use of the `frozenset` which is
problematic because:

1. `iter_params` returns an iterable over model parameters
2. `frozenset` wraps this iterable, making it unmodifiable
3. PyTorch’s compilation process cannot infer how `frozenset` interacts
with tensors, leading to a graph break.

If we replace the `frozenset` with a modifiable `set`, then there is no
longer such graph break.

Signed-off-by: Max Kovalenko <mkovalenko@habana.ai>
Co-authored-by: Masahiro Tanaka <81312776+tohtana@users.noreply.github.com>
Co-authored-by: Olatunji Ruwase <olruwase@microsoft.com>
Signed-off-by: Logan Adams <loadams@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants