Repository navigation
[release/2.11] fix PicklingError handling for Python 3.14 - #3584
Merged
Merged
Conversation
…ch#192811) ## Summary `test_gather_object` / `test_gather_object_subgroup` fail on Python 3.14. The test calls `all_gather_object` on a **local class** (unpicklable) and asserts an error. The exception type changed: **<=3.13** raised `AttributeError`, but **3.14** ([CPython pytorchgh-139806](python/cpython#139806)) raises `PicklingError` eagerly from `pickle.whichmodule()` for `'<locals>'` names. `PicklingError` is a `PickleError`, not an `AttributeError`, so the stale `assertRaises(AttributeError)` no longer matches. ## Fix Assert on the types raised across all supported versions (`python_min_version = 3.10`): ```python with self.assertRaises((AttributeError, pickle.PickleError)): dist.all_gather_object(...) ``` ## Test plan On Python 3.14.4, assertRaises(AttributeError) around pickle.Pickler().dump() of a local class ERRORS with PicklingError, while assertRaises((AttributeError, pickle.PickleError)) PASSES; on 3.10-3.13 the real AttributeError is also matched (issubclass). Full test needs a 4-GPU nccl world: `python -m pytest torch/testing/_internal/distributed/distributed_test.py -k test_gather_object -v` Pull Request resolved: pytorch#192811 Approved by: https://github.com/jeffdaily (cherry picked from commit 6b296c0)
albmalamd
force-pushed
the
cherry-pick-192811-onto-release-2.11
branch
from
August 19, 2026 16:44
1e62ed7 to
7daec36
Compare
Author
|
!cherry-pick --onto release/2.12 |
Author
|
!cherry-pick --onto release/2.13 |
rocm-repo-management-api-6 Bot
added a commit
that referenced
this pull request
Aug 19, 2026
Cherry-pick of #3584 Co-authored-by: albmalamd <[email protected]>
|
Created branch autogenerated/release/2.12_cherry-pick_pr-3584 and #3585 Comment processed by Build |
rocm-repo-management-api-6 Bot
added a commit
that referenced
this pull request
Aug 19, 2026
Cherry-pick of #3584 Co-authored-by: albmalamd <[email protected]>
|
Created branch autogenerated/release/2.13_cherry-pick_pr-3584 and #3586 Comment processed by Build |
pablo-garay
pushed a commit
that referenced
this pull request
Aug 24, 2026
Cherry-pick of #3584 Co-authored-by: albmalamd <[email protected]> (cherry picked from commit 6596a0d)
jithunnair-amd
pushed a commit
that referenced
this pull request
Aug 25, 2026
Cherry-pick of #3584 Co-authored-by: albmalamd <[email protected]> (cherry picked from commit 6596a0d)
jithunnair-amd
pushed a commit
that referenced
this pull request
Aug 27, 2026
Cherry-pick of #3584 Co-authored-by: albmalamd <[email protected]> (cherry picked from commit 6596a0d)
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.
Fix test_gather_object assertion for Python 3.14 PicklingError (pytorch#192811)
Summary:
The test all_gather_objects a local class (unpicklable) and asserts an
error. The exception type changed: <=3.13 raised AttributeError, but 3.14
(CPython pytorchgh-139806) raises PicklingError from pickle.whichmodule() for
'' names. PicklingError is a PickleError, not an AttributeError, so
the stale assertRaises(AttributeError) no longer matches.
Fix the assertion to (AttributeError, pickle.PickleError), correct across
all supported versions (python_min_version = 3.10) while staying tight. The
fix belongs in the test, not production: normalizing pickle's exception type
in _object_to_tensor would mask a legitimate CPython change.
Test plan:
Test Plan: on Python 3.14.4, assertRaises(AttributeError) around
pickle.Pickler().dump() of a local class ERRORS with PicklingError, while
assertRaises((AttributeError, pickle.PickleError)) PASSES; on 3.10-3.13 the
real AttributeError is also matched (issubclass). Full test needs a 4-GPU
nccl world:
pytest torch/testing/_internal/distributed/distributed_test.py -k test_gather_objectAuthored with the assistance of an AI coding assistant.
Cherry-pick upstream pytorch#192811
Cherry-picked to release/2.12 branch via #3585
Cherry-picked to release/2.13 branch via #3586