Repository navigation
Studio: build VAE tile blend weights on CPU so MPS tiled encode works - #12937
Conversation
axis_weights() in diffusion_vae_tiling built its float64 weights directly on the target device, so a tiled encode on Apple Silicon raised before the first step (MPS has no float64). Build them on CPU and move only the fp32 result, matching video_ltx2_vae_tiles.axis_weights. Fixes unslothai#12935 Signed-off-by: GokayAI <[email protected]>
|
Confirmed main still builds the float64 blend weights on the VAE device in diffusion_vae_tiling.py, which MPS rejects on every tiled encode, and moving only the fp32 result over looks right. Will get this reviewed, ideally with a run on a real Apple Silicon machine. |
|
@gokay-ai Thank you for the PR. I tested this on Apple Silicon and verified it works. |
|
Neither red check is from this PR. |
…ks float64 The tile blend weights were moved to an unconditional CPU build to keep float64 off MPS. Gate that on the device's float64 capability instead, the way the RoPE demotion already is: a device with float64 builds them in place exactly as before, and only MPS builds on CPU and receives the fp32 result. The regression test now watches every tensor the build produces rather than the constructor arguments, so a float64 tensor reaching the device through a later move or cast is caught too.
…E tiles The LTX-2 axis_weights was a copy of the image one that differed only in its default margin and ramp, and the image copy missed the MPS float64 handling the LTX-2 copy had. Delegate to the image implementation with the LTX-2 defaults so the float64 capability is decided in one place.
|
Pushed two commits on top of the original fix, plus a merge of the latest What changed
Validation
cd studio/backend
python -m pytest tests/test_diffusion_vae_tiling.py tests/test_video_ltx2_vae_tiles.py tests/test_diffusion_device.py tests/test_vae_tile_geometry.py -q
# 816 passed |
|
Review and CI status for head
|
Lyxot
left a comment
There was a problem hiding this comment.
Verified on Apple Silicon: tiled encode and decode run on MPS, and blend weights are bit-identical on CUDA and CPU. Codex found no issues; the one red CI check is the unrelated hub-token test failure already on main.
Fixes #12935
axis_weights()indiffusion_vae_tiling.pybuilt its float64 blend weights directly on the VAE's device. On Apple Silicon that raisesCannot convert a MPS Tensor to float64 dtypeas soon astiled_encoderuns, so every Qwen-Image-2.1 generation with an input image failed before the first step.The weights are now built on CPU in float64 and only the fp32 result is moved to the device, the same way
video_ltx2_vae_tiles.axis_weightsalready does it. The vectors are one per tile axis, so the extra copy is negligible. Results on CUDA/CPU are unchanged.Added
test_axis_weights_never_put_float64_on_the_device(same spy test as the LTX-2 one, on ametadevice). It fails onmainand passes with the fix.test_diffusion_vae_tiling.py,test_diffusion_vae_tiling_general.py,test_vae_tile_geometry.pyandtest_video_ltx2_vae_tiles.pypass locally (545 passed, 39 skipped, CPU torch). I don't have an Apple Silicon machine, so this isn't checked on real MPS.Thanks @iMonZ for the clear report and the suggested fix.