Skip to content
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

More options of input/output types in coord_check #80

Open
francois-rozet opened this issue Oct 18, 2024 · 0 comments · May be fixed by #81
Open

More options of input/output types in coord_check #80

francois-rozet opened this issue Oct 18, 2024 · 0 comments · May be fixed by #81

Comments

@francois-rozet
Copy link

francois-rozet commented Oct 18, 2024

Hello 👋

I am having issues with using mup.get_coord_data because some of my modules return dataclass objects. Currently only, dict, list, tuple and tensors are supported. It would be great, and fairly easy, to also support dataclasses.

I think that the only code to modify would be

mup/mup/coord_check.py

Lines 129 to 148 in 1981497

def get_stat(d, x, fdict):
if isinstance(x, (tuple, list)):
for i, _x in enumerate(x):
_d = copy(d)
_d['module'] += f'[{i}]'
get_stat(_d, _x, fdict)
elif isinstance(x, dict):
for name, _x in x.items():
_d = copy(d)
_d['module'] += f'[{name}]'
get_stat(_d, _x, fdict)
elif isinstance(x, torch.Tensor):
_d = copy(d)
for fname, f in fdict.items():
_d[fname] = f(x).item()
records.append(_d)
elif x is None:
pass
else:
raise NotImplementedError(f'Unexpected output type: {type(x)}')

I can do a PR for that.

@francois-rozet francois-rozet linked a pull request Oct 18, 2024 that will close this issue
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 a pull request may close this issue.

1 participant