Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance degradation in `mps` after `einsum` replacement

See original GitHub issue

Before #445 was merged I was getting ~31s inference time in mps. After the change, time goes up to 42s. I verified again in main @ b2b3b1a, and time is again 31s.

I haven’t checked other platforms yet.

Any ideas, @patil-suraj?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

pcuencacommented, Oct 29, 2022

Addressed in #926.

patil-surajcommented, Sep 12, 2022

also, a different picture is generated. despite same seed each time.

how are you using the seeds ? diffusers pipelines uses the torch.Generator objects for seeds. To get reproducible results we need to reinit the torch.Generator with the same seed as using the same generator multiple times advances the rng state.

The correct way to check this would be running this same block multiple times.

with autocast("cuda"):
    images = pipe(prompt, generator=torch.Generator(device="cuda").manual_seed(1024)).images
Read more comments on GitHub >

github_iconTop Results From Across the Web

[MPS] einsum returns incorrect matmul result on first ... - GitHub
Performance degradation in mps after einsum replacement huggingface/diffusers#452. Closed. Textual Inversion Training on M1 (works!)
Read more >
MPSGraph adamUpdateWithLearningRa… - Apple Developer
I am running tensorflow-macos and tensorflow-metal version 2.6 on Monterey Beta (21A5543b) on an iMac 27" 2021 with an AMD Radeon GPU. I...
Read more >
torch.einsum — PyTorch 1.13 documentation
Einsum allows computing many common multi-dimensional linear algebraic array operations by representing them in a short-hand format based on the Einstein ...
Read more >
AutoHOOT: Automatic High-Order Optimization for Tensors
Moreover, two nodes in an Einsum graph may be trans- positions of each other. After detecting such conditions, we replace one of the...
Read more >
np.einsum performance of 4 matrix multiplications
Looks like you stumbled onto a case where the greedy path gives a non-optimal scaling. >>> path, desc = np.einsum_path('xyf,xtf,ytpf ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found