-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: IPAdapter, RuntimeError: Expected query, key, and value to have the same dtype, but got query.dtype: c10::Half key.dtype: float and value.dtype: float instead. #2208
Comments
same issue |
same issue too. env : m1 mac |
Same here. IP-Adapter been buggy and can't get it to work |
Same here. M1 Mac 8GB, Sonoma 14.1.1. Information that might be related: Sonoma has previously caused an fp16-related issue with NeuralNet on PyTorch 2.1.0, but that particular problem was solved by updating to 2.2.0.dev20231012. (Issue AUTOMATIC1111/stable-diffusion-webui#13419) Attempted solutions: |
Same here. M1 Max |
This works for me: Patching https://github.com/Mikubill/sd-webui-controlnet/blob/main/scripts/controlmodel_ipadapter.py#L430 to convert ip_k & ip_v from float to c10:Half by adding .half() for each. Although I'm not sure if this is the right thing to do, I'm able to generate images with SD 1.5 and SDXL with style transfer using ControlNet + IP Adapter. |
Anyone verify this solution on their Mac? I do not have an MacOS machine to verify this patch. I will merge this patch to main branch once it is verified. |
I can't compare the results to an Nvidia machine, so I'm going to post a detailed report with image samples just in case this fix caused some weirdness that I can't detect. My apologies if this response is a bit long; I'd rather be thorough than miss something that an Nvidia owner would notice. TL;DR:
Testing parameters: Processor: M1 8GB. OS: Sonoma 14.1.1. PyTorch version: 2.2.0.dev20231012 Webui arguments on launch: Resolutions: 512x512 and 512x768. IPAdapter settings: ip-adapter_clip -> ip-adapter-plus-face_sd15, Low VRAM, Control Weight 0.7, Steps 0.5-1.0. Attaching XY grids below to display the results. Model: Deliberate v2. Sampler: DPM++ 2M Karras, sampling steps: 20. Prompt: female nurse, black hair. Negative prompt: nsfw, disfigured, (deformed), ugly, saturated, doll, cgi, calligraphy, mismatched eyes, poorly drawn, b&w, blurry, missing, ((malformed)), ((out of frame)), model, letters, mangled, old, surreal, ((bad anatomy)), ((deformed legs)), ((deformed arms)). IPAdapter image:
|
@Osato28 So the fix works for you too, right? Do you spot anything weird in your generations? Your generations look pretty cool to me. I'm bad in tuning settings for nice outputs... If the output does work for Apple Silicon, my only concern is about the --upcast-sampling, --no-half settings, etc. I have a feeling they are related to the error. simply typecasting by .half() might break users not using Apple Silicon. I only have a M1 Max, so unable to test for other PC / GPU / CPU... By the way, My COMMANDLINE_ARGS is: "--skip-torch-cuda-test --upcast-sampling --opt-sub-quad-attention --medvram --use-cpu Interrogate --no-half-vae --disable-safe-unpickle --autolaunch", which I thought is optimized for Apple Silicon |
@beltonk I didn't spot anything weird and I can't test it on non-Apple Silicon. Hence the overly detailed test results: I'm hoping that if there is anything weird, it will be caught by someone with a more traditional GPU. Thank you for posting that fix, by the way. I couldn't make heads or tails of how IPAdapter worked, and I didn't have the courage to blindly typecast values until the error message went away. Offtopic:
But I'm afraid that both of those discussions are outside the scope of this issue. If you wish to initiate testing on several Apple Silicon machines to find an optimal set of COMMANDLINE_ARGS, I think it would be better to start a separate discussion issue in the main AUTOMATIC1111 repo. |
Thank you @beltonk -- your fix worked for me too! |
Thx @beltonk -- works for me as well! |
The fix of @beltonk worked for me on m2 mac mini |
Worked here! (Mac, M2 / 1111 v 1.7) |
which file should I change? Cant find controlmodel_ipadapter.py |
Thank you,@huchenlei |
Is there an existing issue for this?
What happened?
IPAdapter cannot run correctly.
Steps to reproduce the problem
What should have happened?
raise a RuntimeError
Commit where the problem happens
webui: 5ef669de080814067961f28357256e8fe27544f4
controlnet: 3011ff6
What browsers do you use to access the UI ?
No response
Command Line Arguments
List of enabled extensions
Console logs
Additional information
Also occurs in other ip-adapter models, e.g. ip-adapter-plus_sd15 [c817b455]
The text was updated successfully, but these errors were encountered: