Skip to content

Replace torch.jit.script with torch.compile (#7835)#7840

Merged
tohtana merged 10 commits intodeepspeedai:masterfrom
tohtana:tohtana/fix-issue7835-torch-jit-script-deprecation
Feb 12, 2026
Merged

Replace torch.jit.script with torch.compile (#7835)#7840
tohtana merged 10 commits intodeepspeedai:masterfrom
tohtana:tohtana/fix-issue7835-torch-jit-script-deprecation

Conversation

@tohtana
Copy link
Collaborator

@tohtana tohtana commented Feb 10, 2026

Fixes #7835.

On torch==2.10.0, importing DeepSpeed emitted deprecation warnings from import-time JIT-decorated helpers.
This change updates the compatibility path to align with PyTorch guidance while keeping import clean.

Introduce a jit_script_compat helper that wraps torch.jit.script with scoped deprecation-warning suppression and apply it to import-time scripted helpers in MoE, MiCS, and sequence FPDT codepaths.

Also suppress torch.jit script/script_method deprecation warnings around optional Muon optimizer import in ZeRO utils so importing DeepSpeed on torch 2.10 no longer emits these warnings.

Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
@tohtana tohtana requested a review from tjruwase as a code owner February 10, 2026 01:12
…#7835)

Use torch.compile for torch>=2.0 in jit_script_compat and keep a scripted
fallback for compatibility. Scope-filter JIT deprecation warnings around both
compile and script paths so importing DeepSpeed stays warning-free on torch
2.10.

Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Revert the temporary torch.compile path in jit_script_compat. While
compile is the recommended modern API, invoking it here still triggers
torch.jit.script_method deprecation warnings in torch 2.10 internals.

For this issue we keep the scoped warning-safe script wrapper to avoid
import-time warning regressions.

Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
@tohtana tohtana changed the title Suppress import-time torch.jit deprecation warnings (#7835) Replace torch.jit.script with torch.compile (#7835) Feb 10, 2026
tohtana and others added 4 commits February 9, 2026 21:07
Refactor jit_script_compat to use a single scoped warning configuration
for both compile and script paths. Keep compile-first behavior with script
fallback unchanged while reducing redundant filter blocks.

Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
…#7835)

Use a direct torch.compile replacement path in jit_script_compat for
torch>=2.0 and keep torch.jit.script only as the legacy fallback.
Remove warning-filter and try/except compatibility layers.

Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
Assume non-strict warning mode and simplify ZeRO optimizer registration by
importing MuonWithAuxAdam directly without scoped warning filters.

Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
@tohtana tohtana enabled auto-merge (squash) February 12, 2026 19:36
@tohtana tohtana merged commit d2ca6e7 into deepspeedai:master Feb 12, 2026
9 of 11 checks passed
@tohtana tohtana deleted the tohtana/fix-issue7835-torch-jit-script-deprecation branch February 12, 2026 21:12
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.

[BUG] DeprecationWarning from @torch.jit.script

2 participants