lllyasviel / lllyasviel/sd-forge-layerdiffuse
Fix for Apple Silicon
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.1k
- Forks
- 352
- PR merge metrics
- No merged PRs in 30d
Description
the following fix is required for apple silicon, note the additional .float(), else the forge script will give this error
```
File "/Applications/Data/Packages/Stable Diffusion WebUI Forge/extensions/sd-forge-layerdiffuse/lib_layerdiffusion/models.py", line 277, in estimate_augmented
median = torch.median(result.cpu(), dim=0).values
RuntimeError: "median_out" not implemented for 'Half'
```
in lib_layerdiffusion/models.py
```python
if self.load_device == torch.device("mps"):
'''
In case that apple silicon devices would crash when calling torch.median() on tensors
in gpu vram with dimensions higher than 4, we move it to cpu, call torch.median()
and then move the result back to gpu.
'''
result_cpu = result.cpu().float() # Convert to float32 on CPU
median = torch.median(result_cpu, dim=0).values
median = median.to(device=self.load_device, dtype=self.dtype)
else:
median = torch.median(result, dim=0).values
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open lib_layerdiffusion/models.py and inspect estimate_augmented around the torch.median call. Reproduce the reported Apple Silicon failure if possible, then verify the median operation works for the affected tensor type and that the result retains the expected device and dtype.
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
- 52/100