fix(gguf): ensure dequantized tensors are on correct device for MPS#8713
Merged
lstein merged 6 commits intoinvoke-ai:mainfrom Jan 2, 2026
Merged
Conversation
When using GGUF-quantized models on MPS (Apple Silicon), the dequantized tensors could end up on a different device than the other operands in math operations, causing "Expected all tensors to be on the same device" errors. This fix ensures that after dequantization, tensors are moved to the same device as the other tensors in the operation.
Contributor
|
Note this issue doesn't occur with keep_ram_copy_of_weights enabled as it defaults on enabled you'll need in the invoke.yaml when testing It's basically the same issue as #7939 Oh, I believe it breaks on CUDA with the same settings, If you've got the VRAM to run it. |
Contributor
|
I've tested this PR on a M5 with 32gb RAM. It allows generations, with no errors, with |
lstein
approved these changes
Jan 2, 2026
Collaborator
lstein
left a comment
There was a problem hiding this comment.
Looks good. I'm going ahead with an approval to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using GGUF-quantized models on MPS (Apple Silicon), the dequantized tensors could end up on a different device than the other operands in math operations, causing "Expected all tensors to be on the same device" errors.
This fix ensures that after dequantization, tensors are moved to the same device as the other tensors in the operation.
Related Issues / Discussions
(https://discord.com/channels/1020123559063990373/1149506274971631688/1454480237311168654)
QA Instructions
Test with z_image_turbo-Q4_K.gguf, Qwen_3_4b-Q6_K.gguf on mac
Merge Plan
No big change.
Checklist
What's Newcopy (if doing a release after this PR)