Skip to content

Fix DTensor double-backward patch for torch >= 2.13 - #447

Merged
luciaquirke merged 2 commits into
mainfrom
fix/dtensor-patch-torch-213
Sep 1, 2026
Merged

Fix DTensor double-backward patch for torch >= 2.13#447
luciaquirke merged 2 commits into
mainfrom
fix/dtensor-patch-torch-213

Conversation

@luciaquirke

@luciaquirke luciaquirke commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

apply_dtensor_patch replaces Redistribute.backward with a version that reads ctx.backward_dtype and ctx.original_dtype.

torch's Redistribute.forward stored those attributes up to 2.12. From 2.13 it routes dtypes through a _DtypeConfig and stores ctx.bwd_op_dtype / ctx.bwd_out_dtype instead, so the old names are absent and the first backward raises:

AttributeError: 'RedistributeBackward' object has no attribute 'backward_dtype'

This makes fsdp=True unusable for any model.

Fix

Read the dtypes through a small helper that accepts either spelling, so the patch keeps working on torch <= 2.12 and on >= 2.13. Reproduced on torch 2.13.0+cu126 (gpt2, nproc_per_node=2, fsdp: true); with the fix the same run trains normally. Not size- or architecture-specific.

Also: fix the release job

The release step fails on main with type object 'Actor' has no attribute 'name_email_regex': GitPython 3.1.60 removed Actor.name_email_regex, which the pinned python-semantic-release@v9.19.1 action still reads at config load (upstream #1476). The fix only landed in v10.6.2, so this bumps the action (and pins publish-action to match). All options whose defaults changed in v10 (allow_zero_version, mask_initial_release, parse_squash_commits, ignore_merge_commits) are already set explicitly in pyproject.toml, so behavior is unchanged. Verified semantic-release --noop version with 10.6.2 + GitPython 3.1.61 loads the config cleanly.

🤖 Generated with Claude Code

https://claude.ai/code/session_0167XKnE2yoCE162n3jHvxC1

luciaquirke and others added 2 commits September 1, 2026 03:10
apply_dtensor_patch replaces Redistribute.backward with a version that reads
ctx.backward_dtype and ctx.original_dtype. torch's Redistribute.forward stored
those up to 2.12; from 2.13 it routes dtypes through a _DtypeConfig and stores
ctx.bwd_op_dtype / ctx.bwd_out_dtype instead. The old names are therefore absent
and the first backward raises

    AttributeError: 'RedistributeBackward' object has no attribute 'backward_dtype'

which makes fsdp=True unusable for any model. Reproduced on torch 2.13.0+cu126
with gpt2 and nproc_per_node=2, so it is not size- or architecture-specific.

Read the dtypes through a helper that accepts either spelling, so the patch works
on both. With the fix the same gpt2 + FSDP run trains normally.
GitPython 3.1.60 removed Actor.name_email_regex, which the v9.19.1 action
still reads, so every release run fails at config load. The fix landed in
v10.6.2 only; pin the publish action to the same version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@luciaquirke
luciaquirke force-pushed the fix/dtensor-patch-torch-213 branch from da4fa7e to d8a77f9 Compare September 1, 2026 03:10
@luciaquirke
luciaquirke merged commit fe9e6a4 into main Sep 1, 2026
8 checks passed
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.

1 participant