huggingface / huggingface/diffusers
[Bug] GlmImagePipeline silently corrupts weights on MPS accelerator
- Vorherrschende Sprache
- Python
- Sterne
- 34.5k
- Forks
- 7.3k
- Ø Merge
- 3 T. 3 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
### Describe the bug
When loading `zai-org/GLM-Image` with `device_map="mps"` in diffusers, some model parameters become silently corrupted during `GlmImagePipeline.from_pretrained` call.
The corruption:
```
Happens only when tensors are placed directly on MPS during loading
Is non-deterministic across dtypes
```
* float32 + MPS: weights corrupted, bias OK
* float16 + MPS: bias corrupted, weights OK
Does not occur when loading on CPU first and then moving to MPS
This results in extreme values (~1e37), LayerNorm overflow, and NaN / zero outputs (all-black images).
### Reproduction
# ❌ Corrupted
```python
from diffusers.pipelines.glm_image import GlmImagePipeline
import torch
pipe = GlmImagePipeline.from_pretrained(
"zai-org/GLM-Image",
torch_dtype=torch.float32,
device_map="mps",
)
```
# ✅ Correct workaround
```python
from diffusers.pipelines.glm_image import GlmImagePipeline
import torch
pipe = GlmImagePipeline.from_pretrained(
"zai-org/GLM-Image",
torch_dtype=torch.float32,
)
pipe.to("mps")
```
### Logs
```shell
Device: mps, dtype: torch.float32
Keyword arguments {'trust_remote_code': True} are not expected by GlmImagePipeline and will be ignored.
Loading pipeline components...: 0%| | 0/7 [00:00
Beitragsleitfaden
Rechercherichtung
Beginne in diffusers.pipelines.glm_image bei GlmImagePipeline.from_pretrained und reproduziere den Unterschied zwischen dem Laden mit device_map="mps" und dem Laden auf der CPU, gefolgt von pipe.to("mps"). Vergleiche die Parameterwerte in den Fällen float32 und float16 und überprüfe anschließend, dass das direkte Laden auf MPS keine extremen Gewichte, NaNs oder Schwarzbildausgaben mehr erzeugt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python, pytorch
- Bereich
- machine-learning, performance
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100