-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing _modules dict type in Pytorch 2.5 leads to failing collections test #2789
Comments
Hi! thanks for your contribution!, great first issue! |
I am happy to implement the proposed fix |
Hi @bfolie, we be happy to receive a fix from you :) |
@bfolie could you pls send a PR with this fix asap so we can rollout the compatibility check for PT 2.5 |
Hi @Borda , @SkafteNicki . I made the proposed change and confirmed locally that the test passes using both PT 2.4.1 and 2.5.0. But when I try to push my branch I get an error
Are there restrictions on who can create new branches? |
Yes only members of lightning organizations can push directly. You need to create a fork of the repository, and then push your changes to that. Then you should be able to create a PR from your fork against the main repo |
🐛 Bug
As of PyTorch 2.5, the
Module._modules
attribute has changed from anOrderedDict
to adict
. This was done to improve the performance of certain TorchDynamo guard mechanisms and is not expected to affect other behavior because, as of Python 3.7, dictionaries are ordered by default.This means that MetricCollection.keys returns type
dict_keys
whenkeep_base=True
but returnsodict_keys
whenkeep_base=False
because it uses _to_renamed_ordered_dict to construct a newOrderedDict
(MetricCollection.items has the same issue).As a result, test_metric_collection_prefix_postfix_args fails at line 200 because it calls
.keys()
withkeep_base
equal to both True and False and asserts that the resulting types are the same, which they are not.Proposed Fix
Change
_to_renamed_ordered_dict
so that it produces either adict
or anOrderedDict
, depending on the type of the existing_modules
dictionary. This will work for both older and newer version of PyTorch.Current:
Proposed:
To Reproduce
Run the unit tests with PyTorch 2.5
The text was updated successfully, but these errors were encountered: