Skip to content

Conversation

@patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Jan 5, 2023

Last PR of the series after #1906.

In this PR, I'll update all tests to use CPU generators for better determinism and also add a reproducible doc page.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jan 5, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@patil-suraj patil-suraj left a comment

Choose a reason for hiding this comment

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

Great PR! It must have taken a lot of time to change all these tests! I mostly left some nits.

ddim.to("cuda")

# create a generator for reproducibility
generator = torch.manual_seed(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we still use a torch.Generator here? Using manual_seed will set the global seed, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think torch.Generator does that as well

return True


def print_tensor_test(tensor, filename="test_corrections.txt", expected_tensor_name="expected_slice"):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW @pcuenca @patil-suraj @yiyixuxu @williamberman

I added some functionality that helps to automatically correct slice-comparison tests.
All you need to do here is to add:

print_tensor_test(image_slice)

and it'll write the correct tensor to a file: filename with the name expected_tensor_name.

The utils file here: https://github.com/huggingface/diffusers/pull/1924/files#diff-bd9ba404f47129f2218fc94c5e528cc81bfd10cef1eff1d6d543f6ffa0143367 can then take this file and will automatically overwrite the test with the correct results. This should save quite some time going forward :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

That's very cool, thanks a lot !

@patrickvonplaten patrickvonplaten merged commit 6ba2231 into main Jan 25, 2023
@patrickvonplaten patrickvonplaten deleted the make_tests_deterministic branch January 25, 2023 12:44
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* make tests deterministic

* run slow tests

* prepare for testing

* finish

* refactor

* add print statements

* finish more

* correct some test failures

* more fixes

* set up to correct tests

* more corrections

* up

* fix more

* more prints

* add

* up

* up

* up

* uP

* uP

* more fixes

* uP

* up

* up

* up

* up

* fix more

* up

* up

* clean tests

* up

* up

* up

* more fixes

* Apply suggestions from code review

Co-authored-by: Suraj Patil <surajp815@gmail.com>

* make

* correct

* finish

* finish

Co-authored-by: Suraj Patil <surajp815@gmail.com>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* make tests deterministic

* run slow tests

* prepare for testing

* finish

* refactor

* add print statements

* finish more

* correct some test failures

* more fixes

* set up to correct tests

* more corrections

* up

* fix more

* more prints

* add

* up

* up

* up

* uP

* uP

* more fixes

* uP

* up

* up

* up

* up

* fix more

* up

* up

* clean tests

* up

* up

* up

* more fixes

* Apply suggestions from code review

Co-authored-by: Suraj Patil <surajp815@gmail.com>

* make

* correct

* finish

* finish

Co-authored-by: Suraj Patil <surajp815@gmail.com>
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.

4 participants