Skip to content

[DeepCompile] Fix staticmethod handling on Python 3.9 - #8240

Open
baremetaldevx86 wants to merge 1 commit into
deepspeedai:masterfrom
baremetaldevx86:fix/7433-staticmethod-descriptor
Open

[DeepCompile] Fix staticmethod handling on Python 3.9#8240
baremetaldevx86 wants to merge 1 commit into
deepspeedai:masterfrom
baremetaldevx86:fix/7433-staticmethod-descriptor

Conversation

@baremetaldevx86

@baremetaldevx86 baremetaldevx86 commented Aug 9, 2026

Copy link
Copy Markdown

Description

DeepCompile retrieves PyTorch's compiled backward hooks directly from the class namespace. On Python 3.9, this returns a staticmethod descriptor that cannot be
called directly, resulting in:

TypeError: 'staticmethod' object is not callable

This change unwraps the underlying function before DeepSpeed invokes it.

The fix covers both supported implementations:

  • PyTorch 2.6: _backward_prologue
  • PyTorch 2.7+: _backward_impl

A regression test emulates Python 3.9's non-callable staticmethod behavior so the failure remains covered when CI runs on newer Python versions.

Testing

  • pytest -q tests/unit/compile/test_backend.py tests/unit/compile/test_zero3_grad_dtype.py
  • pre-commit run --files deepspeed/compile/patch_compiled_func.py tests/unit/compile/test_backend.py

Fixes #7433

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] TypeError: 'staticmethod' object is not callable, in deepcompile (patch_compiled_func.py)

1 participant