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

Making train_parallel.py work on a single machine (non-distributed) #29

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

levinkhho
Copy link
Contributor

Small tweaks to train_parallel.py (and related changes to distributed.py and generate_batch.py) so that it works on a single machine. Mainly, it now only uses the nn.parallel.DistributedDataParallel model container if in a distributed environment.

@@ -274,12 +288,15 @@ def main(args):
"args": args,
} # save full config.
ema_model.save(vision_model_file, other_items=other_items)
diffusion_model.model.module.vision_model.save(
getattr(diffusion_model.model, "module", diffusion_model.model).vision_model.save(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need getattr here, does the diffusion_model.model sometimes not have a module? Or is this connected to the torch change?

Copy link
Contributor Author

@levinkhho levinkhho Nov 19, 2024

Choose a reason for hiding this comment

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

It seems that diffusion_model.model only has module when it's in the nn.parallel.DistributedDataParallel container, so this getattr accounts for when model = diffusion_model.model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there's a better way to account for this (e.g. just adding the module attribute to the model instance if it's missing), please let me know and I can make the change!

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