| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Prevents slow CPU initialization of model weights on load by using accelerate `init_empty_weights`. Completely compatible with from_pretrained since weights will always be overwritten by state_dict fixes VectorSpaceLab#72
|
@Rypo, thank you very much for your contribution!!! These are incredibly useful features. |
Sorry, something went wrong.
|
I find that removing non_blocking=True will result in a longer inference time. When using two images as input and offloading the model, the generation process will take 10 minutes. But if add non_blocking=True, this only takes 2.5 mins. |
Sorry, something went wrong.
|
@Rypo |
Sorry, something went wrong.
|
@staoxiao Absolutely, happy to lend a hand! I dug a little deeper into the torch.cuda.synchronize(self.prefetch_stream) statement and have determined that it is functionally equivalent to torch.cuda.synchronize(None). If synchronize isn't passed a str, int, or torch.device, torch will default to synchronizing all streams on the current device. I assume that isn't the behavior you're after here, but at worst it would probably just cause a small performance hit. Not exactly sure why self.prefetch_stream.synchronize() would cause errors on your end though. As for the non_blocking issue, that's fair. I'll separate #150 so it does not interfere with the other PRs. I will caution, however, that WSL users may not be able to use Omnigen in that case. I suspect that #90 and #117 are both instances of this. So I'd recommend leaving that PR open for the time being for visibility. You'll also need to take care to always synchronize before accessing any tensors moved via to("cpu", non_blocking=True). Unlike .to(cuda, non_blocking), there's no read time validation. If the data is accessed without explicit synchronization before the transfer completes, you may get garbage outputs. |
Sorry, something went wrong.
|
@Pevernow I uploaded the weights to the hub (4bit, 8bit). They will not work out of the box yet. I have a very rough prototype that I'm working on cleaning up. It should be ready in the coming days. Note: These links may change depending on the specifics of the final implementation. I'll update this message if so. Update: they work out of the box with this PR now. See updated "Usage" section above. |
Sorry, something went wrong.
Add a quantization utility for HFQuantizers. Modify pipelines to accept quantization_config. Sets ground work for allow bf16 vae. Update requirements to include bitsandbytes. closes VectorSpaceLab#45, closes VectorSpaceLab#64
|
Looking forward to integration of quantized weights. Thank you |
Sorry, something went wrong.
…ion for bnb quant dict
…ocessing, skip quant norm layers
…rom_pretrained Removes quantization_config from main pipeline. Instead, use Diffusers style syntax where the config is passed to the transformer (model) when is then passed to the pipeline.
|
Alright, I think it's in an acceptable state at this point. Barring any glaring issues I missed, I'm calling it a wrap on this PR. New Changes Recap
Final Remarks
If anyone finds an issue let me know, otherwise enjoy! Update: I failed to call it a wrap. Colab painfully slow -> painfully reasonably slow. See notes on float16 update below. |
Sorry, something went wrong.
|
Appreciate your efforts. |
Sorry, something went wrong.
Sorry, something went wrong.
Adds a small utility to scheduler to find the minimum clip bound to prevent NaNs from popping out of the decoder layers. Search over hardcoded buffer to discard as little information as possible. Phi3Transformer now raises OverflowError when NaNs encountered. Initialize model dtype based on actual weight value to avoid bad casts when quantized.
UpdateSome good news for the GPU poor! My most recent commit (d75af76) appears to have patched the float16 issue #108. Turns out the decoder layers were operating on values outside the bounds of what fp16 can handle causing numerical overflow. Luckily, clipping the values into an operable range doesn't seem to degrade the quality too much. Why does float16 matter?
The GoodsI uploaded fp16-compatible 4-bit weights to the hub: gryan/OmniGen-v1-fp16-bnb-4bit With these weights, you can comfortably run double 1024x1024 images on free-tier Colab, without model offloading. model = OmniGen.from_pretrained('gryan/OmniGen-v1-fp16-bnb-4bit', dtype=torch.float16)
pipe = OmniGenPipeline.from_pretrained("Shitao/OmniGen-v1", model = model)For maximum comfort
For maximum speed
It's still not fast, but it's a decent step up from the 25-60 min it took for a double 768x768 previously. Enjoy! |
Sorry, something went wrong.
Start search with minimal clipping value found through testing (2^16 - 3*32). This value was sufficient for all tested inputs. Further analysis still required to guarantee that it will always be sufficient in all cases.
|
Any plans to support v2. Thank you. :) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Changes
Usage
or to use pre-quantized weights:
Important
If you are using Google Colab free-tier or have an older GPU use the float16 weights. You'll go OOM or get errors using the default bfloat16 weights.
For use with app.py you can pass a cli arg --nbits or -b
Ideally, this would be a gradio radio button component or something, but that's a task for another day.
Results
Following a similar format to the Different inference settings table.
For 4bit-nf4 quantized model on RTX 3090 GPU(24G):
Testing setup
Image Comparisons
8-bit
I didn't spend much time testing 8-bit, but without cache offloading -> OOM. Here's a couple samples otherwise.
For bnb 8bit quantized model on RTX 3090 GPU(24G):
Images
Same prompts + settings as above, all with 8-bit quantization.
Additional Considerations
_This is the third of 3 PRs I'm issuing to improve performance/fix errors. I've tried to keep each incremental change as small in scope as possible. PRs: 1. #149, 2. #150, 3. This
Update (2024-12-02):
Update (2024-12-05):
Update (2024-12-12):