Skip to content

Conversation

@sayakpaul
Copy link
Member

What does this PR do?

So the following tests pass:

tests/models/unets/test_models_unet_2d.py::NCSNppModelTests::test_sharded_checkpoints
tests/models/autoencoders/test_models_vae.py::ConsistencyDecoderVAETests::test_sharded_checkpoints

Some comments in line.

@sayakpaul sayakpaul requested review from DN6 and SunMarc July 2, 2024 05:23
new_model = new_model.to(torch_device)

torch.manual_seed(0)
_, inputs_dict = self.prepare_init_args_and_inputs_for_common()
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise the generator (which is required as an input when using the ConsistencyDecoderVAE will be consumed and its states will change in-place. So, we need to re-initialize here.

@HuggingFaceDocBuilderDev

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.

Comment on lines +418 to +421
del self.weight
self.W = nn.Parameter(torch.randn(embedding_size) * scale, requires_grad=False)

self.weight = self.W
del self.W
Copy link
Member Author

Choose a reason for hiding this comment

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

Necessary to mitigate the "tied weight tensors" error from safetensors.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sayakpaul curious about codes here, may i ask for more details if possible? ;)

Comment on lines -365 to -366
if seed is not None:
generator.manual_seed(0)
Copy link
Member Author

Choose a reason for hiding this comment

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

This was likely a mistake because if a seed is provided you would want to use that to do: generator.manual_seed(seed) and not generator.manual_seed(0) using a fixed seed.

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks for fixing @sayakpaul !

@sayakpaul sayakpaul merged commit 31adeb4 into main Jul 4, 2024
@sayakpaul sayakpaul deleted the fix-sharding-tests branch July 4, 2024 03:21
sayakpaul added a commit that referenced this pull request Jul 4, 2024
sayakpaul added a commit that referenced this pull request Dec 23, 2024
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.

6 participants