Apple Silicon (MPS): float64 timestep sinusoid fails — working 3-line fix
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bản sửa lỗi đã được viết đầy đủ: thay thế phép tính sinusoide float64 trong MOSSImageTransformer.forward bên trong pipeline_moss_image.py bằng phiên bản được tính trên CPU như trong diff, và áp dụng thay đổi tương tự cho các bản sao trong transformer/ và scheduler/. Trước tiên, hãy xác minh trên CPU rằng các đầu ra không thay đổi, sau đó chạy sinh dữ liệu với thiết bị MPS nếu có. Hoàn thành khi cả ba bản sao đã được vá và việc sinh dữ liệu tạo ra hình ảnh chính xác trên cả CPU và MPS.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
On Apple Silicon (PyTorch MPS), generation fails on the first step:
TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't
support float64.
The cause is the float64 timestep sinusoid in MOSSImageTransformer.forward
(pipeline_moss_image.py). MPS has no float64.
Fix (verified)
Compute the sinusoid on the CPU in float64 (numerically identical to training) and move
the float32 result back to the device:
- freq = 10000 ** (-torch.arange(half, device=times.device, dtype=torch.float64) / half)
- phase = times.double()[:, None] * freq
- embedding = torch.cat((phase.cos(), phase.sin()), -1).float()
+ freq = 10000 ** (-torch.arange(half, device="cpu", dtype=torch.float64) / half)
+ phase = times.detach().cpu().double()[:, None] * freq
+ embedding = torch.cat((phase.cos(), phase.sin()), -1).float().to(times.device)
Important: use .cpu().double(), not .to("cpu", torch.float64). On MPS (torch 2.14.1),
torch.tensor([1000., 976., 24.], device="mps").to("cpu", torch.float64) silently returns
[0., 0., 0.]. Every timestep then becomes 0 and the output is pure noise, with no error.
Verification
- MacBook Pro, M5 Pro, 64 GB; macOS 27.0.1; torch 2.14.1; diffusers 0.42.0.dev0;
transformers 5.20.2;OpenMOSS-Team/MOSS-Image-SFT@f972bd4 - Same seed and prompt at 512×512, 10 steps, CFG 1: the MPS output matches the CPU
reference image (MPS 4 s vs CPU 701 s). - 1024×1024, 25 steps, CFG 2.5: 89 s on MPS, correct output.
- Every other component matched CPU on MPS in a layer-by-layer comparison: text
encoder, attention, RoPE, embedders, all 42 blocks.
Notes for Mac users
- Load with
torch_dtype={"default": torch.bfloat16, "vae": torch.float32}, then
pipe.to("mps"). causal_conv1dandflash-linear-attentionare CUDA-only, so the text encoder uses
transformers' reference kernels. That's slower but correct.torchvisionis required by the Qwen3-VL processor.
Please consider applying this in the repo (including the transformer/ and scheduler/
copies of the file) and listing Apple Silicon as supported.
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 114
- Merge trung bình
- 9 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenMOSS/MOSS-Image
-
Community project: hosted MOSS-Image studio with a visual JSON layout builder (no ComfyUI needed)Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 65/100
OpenMOSS/MOSS-Image#27 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
OpenMOSS/MOSS-Image#10 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
OpenMOSS/MOSS-Image#31 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Why is it qwen3.5-9b-instruct?Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 45/100
OpenMOSS/MOSS-Image#28 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
MOSS video?Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
OpenMOSS/MOSS-Image#24 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenMOSS/MOSS-Image
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
BCDA-APS/polar-bits#93 ·
-
infer_audio_type only recognises one MPEG Layer III frame header, so most MP3 files are rejectedCó thể đã có người làm @Steve-20-ai đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] - ssh_config `Match tagged` statement always appliesCó thể đã có người làm @AtharvRG đã nhận hôm nay. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
paramiko/paramiko#2715 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 9 ngày
-
auto-rejected intake mcp-intake needs-salvage priority:high type:feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Ikalus1988/MisakaNet#4221 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày