Skip to content

Conversation

@anton-l
Copy link
Member

@anton-l anton-l commented Sep 14, 2022

Solving both the datasets caching and the GPU inconsistency issues

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 14, 2022

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

return unittest.skipUnless(_run_slow_tests, "test is slow")(test_case)


def load_image(image: Union[str, PIL.Image.Image]) -> PIL.Image.Image:
Copy link
Contributor

Choose a reason for hiding this comment

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

nice good idea for testing

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

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

Looks great!

output_image = ds["output"]["image"][0].resize((768, 512))
assert sampled_array.shape == (512, 512, 3)
# using the mean absolute error due to slightly inconsistent outputs across different GPUs
assert np.mean(np.abs(sampled_array - expected_array)) < 2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

2.0 seems to large to me here as discussed. Can we see how big the difference is for pure numpy arrays without any optimization?

Will run:

model_id = "CompVis/stable-diffusion-v1-4"
pipe = StableDiffusionPipeline.from_pretrained(
    model_id,
    use_auth_token=True,
)
pipe.to(torch_device)

prompt = "A fantasy landscape, trending on artstation"
generator = torch.Generator(device=torch_device).manual_seed(0)
output = pipe(prompt=prompt, guidance_scale=7.5, generator=generator, output_type="np")

from current master @anton-l could you do the same and then we compare numpy results across vorace, colab and brutasse

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that I just merged @patil-suraj improved attention slicing when disabled, so let's try to include this PR when running the tests

assert sampled_array.shape == (512, 768, 3)
assert np.max(np.abs(sampled_array - expected_array)) < 1e-4
# using the mean absolute error due to slightly inconsistent outputs across different GPUs
assert np.mean(np.abs(sampled_array - expected_array)) < 2.0
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed this can be updated now to much lower tolerance :-)

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.

LGTM! Same comments as Patrick's

@anton-l
Copy link
Member Author

anton-l commented Sep 16, 2022

Without autocast we've got much more consistent results now, even without using numpy arrays for the references. cc @patrickvonplaten

@anton-l anton-l merged commit c727a6a into main Sep 16, 2022
@patrickvonplaten
Copy link
Contributor

Thanks for fixing!

PhaneeshB pushed a commit to nod-ai/diffusers that referenced this pull request Mar 1, 2023
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* Finally fix the image-based SD tests

* Remove autocast

* Remove autocast in image tests
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