Replies: 24 comments 8 replies
-
Hi AshD Float16 should be supported as many are using f16 model now I tried to have a look at the TextEncoders model.config at the repo but is not there? I suspect it has a different tensor shape for the input, But I have no idea what it is looking for as all model.configs have been removed form the repo If I have time tonight I will try load up this model and see if I can figure out what it needs |
Beta Was this translation helpful? Give feedback.
-
i am using lcm dreamshaper v7 fp16, chilloutmix fp16 and even a quantized model with no problem, i do believe it is because of olive optimization, u should use fp16 none olive till Adam add support for olive models i guess, there are some models [including fp16 ones i just talked about] here: |
Beta Was this translation helpful? Give feedback.
-
Found the issue, Olive models use a struct type I will support this as I think its important as we are targeting .NET, olive support seems natural, This is one of those things that I'm glad we found now, as it would only get harder and harder to implement as new features are added to OnnxStack I will open a PR later so you can track how this is going, and link it to this issue so people are aware |
Beta Was this translation helpful? Give feedback.
-
Actually I can do this in 2 stages, first I can just convert the input output tensor types, I dont expect the performance hit to be that bad casting to float32. Then eventually fully support multiple value types for diffusers/schedulers Stage 1 I can most likey get done for Fridays release :) |
Beta Was this translation helpful? Give feedback.
-
Thanks Adam. I can post some Float16 code later that I had to add to make the translations. I wished the Half datatype on C# could be used directly. Feel free to use it, if it is helpful. Thank Amin. Let me try out the lcm dreamshaper v7 fp16 model and benchmark it. The Photon Olive optimized Float16 model creates an image in 2.7 seconds using Euler A with 15 steps using DirectML windows 11 on RTX 3090/intel Core 11 pc. |
Beta Was this translation helpful? Give feedback.
-
Feel free to use the code below, if it is helpful. It was useful for me to translate between float and Float16. Here is the Float16Extensions class
And here is the TensorHelper for Float16 operations
|
Beta Was this translation helpful? Give feedback.
-
Pushed a PR if you would like to test, not final implementation, but seems to be working with the Photon model |
Beta Was this translation helpful? Give feedback.
-
u r welcome Ashd, i just posted some of the models fp16 optimized olive from ur huggingface page in that topic so people can use when olive is supported here |
Beta Was this translation helpful? Give feedback.
-
Thanks Adam and Amin. I tested this with the other Olive models FP16, I created earlier and they all work :-) The Olive Models took about 4 to 5 GB of VRAM and using Euler - 30 steps, they took around 1.5 to 1.7 seconds to generate on my intel core 13/Rtx 4090 using DirectML. LCM-Dreamshaper-V7 with 5 steps took around 2.0 to 2.3 seconds and around 7GB VRAM. I am wondering if a Float16 Olive optimized version of LCM-Dreamshaper-V7 would be faster. Thanks, |
Beta Was this translation helpful? Give feedback.
-
u r welcome. that is great! thanks for the tests, |
Beta Was this translation helpful? Give feedback.
-
I was blown away how fast the Olive model were, so very happy this is all working now I can still optimize it a bit more too I think, But I will leave that for a bigger optimization update We should be able to support |
Beta Was this translation helpful? Give feedback.
-
So I ran the Olive toolchain on LCM-Dreamshaper-V7 and created the optimized model and used the cliptokenizer.onnx as the Tokenizer for it. I am getting an Error at Line 133 in File OnnxStack-OnnxNativeTypes\OnnxStack-OnnxNativeTypes\OnnxStack.StableDiffusion\Diffusers\LatentConsistency**\LatentConsistencyDiffuser.cs** Thanks, |
Beta Was this translation helpful? Give feedback.
-
LCM was s bit different to convert I think? @TheyCallMeHex managed to get an onnx conversion, but not sure if he has anything with Olive working yet I'll clone and test this one now see if I can see anything in the debugger |
Beta Was this translation helpful? Give feedback.
-
yeah looks like the converted model is missing an input parameter should be
|
Beta Was this translation helpful? Give feedback.
-
I really need to start adding some better exceptions now more people are using OnnxStack |
Beta Was this translation helpful? Give feedback.
-
Are olive models GPU only? seems to crash on load if using CPU provider |
Beta Was this translation helpful? Give feedback.
-
I have used them on a laptop that had only a CPU and no discrete GPU but I had used it like this
|
Beta Was this translation helpful? Give feedback.
-
I opened a feature request for this on the Olive Github Can someone point me to the python code used to create this model from the original pytorch model? Thanks, |
Beta Was this translation helpful? Give feedback.
-
The original model I converted this from was: https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7 To convert the model to ONNX I used Optimum: https://github.com/huggingface/optimum https://pypi.org/project/optimum/ To do the conversion the command I ran was: optimum-cli export onnx --model /the/path/of/the/model/directory --task stable-diffusion /the/path/of/the/output/directory |
Beta Was this translation helpful? Give feedback.
-
Thanks @TheyCallMeHex I made some progress adding the missing parameter based on the Optimum code but got stuck with another error RuntimeError: Dynamic shape axis should be no more than the shape dimension for batch_size More details here |
Beta Was this translation helpful? Give feedback.
-
maybe @dakenf can help |
Beta Was this translation helpful? Give feedback.
-
Moved this over to a discussion since the original issue is resolved :) |
Beta Was this translation helpful? Give feedback.
-
Jambay Kinley helped with the issue and I generated the new optimized model. With the Optimized version took about 1.8 seconds (8 steps) and 4GB VRAM for an image on a Core i9 13Gen/RTX 4090 Windows 11. One last question - Are there plans for SDXL? If so, I can work on creating some Olive Optimized models for it. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Closing this discussion as the original goal has been met. @saddam213 - I have uploaded a bunch of Olive optimized SDXL models here to test when the project has SDXL support. Thanks, |
Beta Was this translation helpful? Give feedback.
-
I was trying to use this with the Microsoft Olive optimized Float16 Stable diffusion models and it was throwing an exception.
Microsoft.ML.OnnxRuntime.OnnxRuntimeException: '[ErrorCode:Fail] D:\a\_work\1\s\onnxruntime\core\providers\dml\DmlExecutionProvider\src\ExecutionProvider.cpp(935)\onnxruntime.DLL!00007FFC53310120: (caller: 00007FFC5330BE42) Exception(1) tid(1e34) 80070057 The parameter is incorrect.
The model I used is here
https://huggingface.co/softwareweaver/photon
It was converted to ONNX using the Microsoft Olive toolchain
https://github.com/microsoft/Olive
Thanks,
Ash
Beta Was this translation helpful? Give feedback.
All reactions