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

Fix capturing hparams for loggers that don't support serializing non-primitives #1281

Merged
merged 4 commits into from
Apr 12, 2024

Conversation

awaelchli
Copy link
Contributor

In the previous version of LitGPT, I added this code to sanitize the hparams for logging:

hparams = {k: v for k, v in locals().items() if isinstance(v, (int, float, str)) and not k.startswith("_")}

But this code was removed in the new version, causing errors like:

TypeError: Object of type PosixPath is not JSON serializable

(e.g. with wandb)

I plan to improve this in Lightning's .log_hyperparameters() implementation, after which we can remove the function I added here again.

@awaelchli awaelchli changed the title Fix capturing hparams for loggers that don't support serialization non-primitives Fix capturing hparams for loggers that don't support serializing non-primitives Apr 12, 2024
@awaelchli awaelchli marked this pull request as ready for review April 12, 2024 15:07
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does finetuning also need it?

Also please apply the change to the extensions/thunder/pretrain.py copy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finetuning doesn't capture the hparams for the logger. It's only in the training script because it is my personal preference and so far I was the only user of this script that used wandb until today when Guangtao from TinyLlama noticed this bug.

@awaelchli awaelchli merged commit 3516bea into main Apr 12, 2024
8 of 9 checks passed
@awaelchli awaelchli deleted the bugfix/log-hparams branch April 12, 2024 15:35
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.

2 participants