Replace torch.jit.script with torch.compile (#7835)#7840
Merged
tohtana merged 10 commits intodeepspeedai:masterfrom Feb 12, 2026
Merged
Conversation
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>
…#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>
…ttps://github.com/tohtana/DeepSpeed into tohtana/fix-issue7835-torch-jit-script-deprecation
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>
hwchen2017
approved these changes
Feb 12, 2026
This was referenced Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.