lllyasviel / lllyasviel/ControlNet

Floating point exception when training with pytorch 2.0.0

Open
#309 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
34.1k
Forks
3k
PR merge metrics
No merged PRs in 30d

Description

Uncertain if this is limited to my specific cpu architecture or another dependency but the following code:

ldm/modules/diffusionmodules/util.py line 165:
`freqs = torch.exp(-math.log(max_period) * torch.arange(start=0, end=half, dtype=torch.float32) / half).to(device=timesteps.device)`

generates a floating point exception. This seems related to other cpu vectorized floating-point operations issues introduced in pytorch 2.0.0.
Ultimately the fix is simply to make the arange tensor in the gpu automatically.

`freqs = torch.exp(-math.log(max_period) * torch.arange(start=0, end=half, dtype=torch.float32, device=timesteps.device) / half).to(device=timesteps.device)`

I left the additional .to(device) statement, though I believe it's superfluous.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ldm/modules/diffusionmodules/util.py line 165 and reproduce the floating point exception with the reported training code on PyTorch 2.0.0. Verify that the frequency tensor is created on the timesteps device and that the reported exception no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.