Repository navigation
Fix from_pretrained on torch 2.7: require torch>=2.8 for distributed checkpointing - #49652
Conversation
|
Thank you for your contribution 🤗! CI Security Gate — waiting for maintainer approvalCI is approved automatically only for authors who already have a contribution merged in this repository. A maintainer will review this PR and approve CI to run on it. |
ArthurZucker
left a comment
There was a problem hiding this comment.
Ty, needs patching
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
Thanks for the review! For context on the red CI: the two failing shards look unrelated to this change. |
ducanhnguyen223
left a comment
There was a problem hiding this comment.
On head 8e76de6, I cannot find the regression test described in the PR body. GitHub lists only the three production files (checkpoint.py, mixin.py, and utils.py) in the diff, and tests/utils/test_distributed_checkpoint_guard.py is absent from both the base and head. Could you add the guard/import regression or update the PR description if it was dropped? This torch-version boundary caused a broad import regression, so a committed test would help prevent it recurring.
CI recapDashboard: View test results in Grafana |
…checkpointing (#49652) * Require torch>=2.8 for distributed checkpointing (hf_storage) * Update distributed checkpoint error messages to torch>=2.8 * Update FSDP2/DCP torch floor in mixin to 2.8 * Add regression test for #49651 * Delete tests/utils/test_distributed_checkpoint_guard.py Overkill! --------- Co-authored-by: Arthur <[email protected]> Co-authored-by: Anton Vlasjuk <[email protected]>
What does this PR do?
Fixes #49651
_check_distributed_checkpointing_available()returnedTrueontorch>=2.7, buttorch.distributed.checkpoint.hf_storage(whichtransformers/distributed/checkpoint.pyimports at module level under that guard) only ships from torch 2.8. Becausemodeling_utilsimportsdistributed.checkpointunconditionally, everyfrom_pretrainedfailed on torch 2.7.x withModuleNotFoundError: No module named 'torch.distributed.checkpoint.hf_storage'.Changes:
is_torch_greater_or_equal("2.8").torch>=2.7error messages and the FSDP2 checks (whose comment says they depend on DCP +HuggingFaceStorageWriter) to2.8, so the stated requirement matches the real one.tests/utils/test_distributed_checkpoint_guard.py: asserts that whenever the guard isTrue,hf_storageis importable; that the guard isFalsefor a simulated torch 2.7; and thattransformers.modeling_utilsimports cleanly.Not touched: the
setup.pyfloor (torch>=2.6) and theShard._local_shard_size_and_offset(2.8+) usage insharding_utils.pythe issue also mentions. Happy to follow up on either if you'd rather bump the minimum torch version instead.Before submitting
from_pretrainedfails in 5.20.0 (hf_storageimport behind atorch>=2.7guard) #49651.Who can review?
@michaelbenayoun @ArthurZucker (tagged in the issue)