r/StableDiffusion • • 6d ago

Resource - Update INT8 LoRA Quantizer + Loader for ComfyUI (about 50–75% less disk space)

It's a custom node pack for ComfyUI that stores LoRA and LoKr files in INT8. Decodes them in memory when loaded and applies to models normally, targets primarily savings in storage.

Roughly 75% savings from a FP32 LoRA and 50% for BF16/FP16.

For example, it took a 8-step MOSS LoRA from 1134 MiB down to 284 MiB, so it's mostly useful for large LoRAs of a few hundred MB or more.

Heads up: it's a disk saving, not a memory one. The INT8 loader expands the LoRA in RAM, so it uses more RAM than the normal LoRA loader. For my fp32 LoRA that was about 1.1 GB more. There's a dtype option, default is bf16, which brings it down to roughly 0.5-0.7 GB more for fp32 LoRAs. I haven't measured VRAM.

Has these nodes for now

  • Quantize LoRA to INT8 - for one file
  • Quantize LoRA Folder to INT8 - for processing a subfolder under loras folder
  • Load INT8 LoRA - for loading a LoRA (Model only/Model + CLIP), there's also a node for stacking three loras
  • LoRA Switch (INT8 / Original) - to switch between the INT8 lora, the original and no lora at all, so you can compare them with the same seed

You can chain em with normal lora loaders as well, quantized files get saved in models/loras_int8

Installation

Install it from ComfyUI Manager, it's listed as LoRA INT8 Quantizer & Loader (registry name int8-lora).

Or clone it into your ComfyUI/custom_nodes folder and restart:

git clone https://github.com/bakapotatolord/ComfyUI-INT8-LoRA

Repo - https://github.com/bakapotatolord/ComfyUI-INT8-LoRA

MOSS 8 Step LoRA comparison

Same prompt and seed with the original fp32 LoRA, INT8 restored as fp32 and INT8 restored as bf16.

MOSS Lighting LoRA, without and with

Same thing but with a lighting LoRA at -1, mode none on the left so you can see the effect.

Repeated image generations mostly yielded highly similar outputs with some cases where minor details can change slightly due to numerical changes. Quality seems to hold from my testing. A very detailed prompt keeps the outputs closer.

Quantize report of MOSS 8 Step LoRA

Quantization Method

By default it uses the 'auto' method which basically quantizes the file using INT8 and INT8 ConvRot (with rotation) and whichever has the overall lower error gets saved.

Ensure to refresh the models (press R) after quantizing so it shows up in the INT8 LoRA Loader

Limitations

  • Saves storage, not RAM/VRAM (see the heads up above)
  • I tested only MOSS and Anima LoRAs/LoKrs so other adapter formats might not work yet

Disclaimer

I used AI assistance heavily for this while I mostly just decided the direction and stuff. I did spend quite a while trying to understand the code and then testing it so hope it works well if you decide to try it out.

Hoping to get some feedback on this.

4 Upvotes

7 comments sorted by

3

u/purelawan 6d ago

Nice, the H3 and MOSS loras are getting huge so this is useful. Two questions: are the scales per row or one per tensor? With fp32 loras that were trained with a few outlier weights, per-tensor int8 can flatten the small ones. And did you run the switch node with a fixed seed on a video model and diff the frames? On image models a small change rarely shows, but on video it sometimes turns into a slow drift over the clip, so that would be the test I'd trust.

1

u/BakaPotatoLord 6d ago edited 6d ago

Scales are on a per row basis, one per tensor would be way too lossy. If a row has too many outliers, convrot should help greatly. Although right now the entirety of the LoRA is either INT8 or INT8 ConvRot, I need to include the option of mixing em.

And I haven't tried it with video models unfortunately. My GTX 1660 Super and 32 GB is not sufficient for that so I'm restricted to mainly image models.

Would appreciate it a lot if you could test it.

2

u/BakaPotatoLord 5d ago

I really would like to know why this is getting downvoted. Did my node fall short of any expectation or? I really would appreciate feedback so I can work on improving it.

2

u/VrFrog 5d ago

Great job! I would love it if the native lora loader could handle this directly. I don't mind the custom lora for the conversion but I try to keep my workflows as native as possible. Did you try opening a PR for the official lora-loader?

As for the downvotes, this sub has a lot of childs and people that cares only about gooning.
If you want upvotes, sadly, you need to post with a sugestive image or a cringe big breasted clown...

Personaly it's posts like yours (with new ideas/techniques) that keep me coming back.

2

u/BakaPotatoLord 5d ago

Thanks!

I don't really like including suggestive images in any of my quants or these nodes and experiments, I know how clickbaity they are though I can understand why people do that.

And for making it an official lora-loader, I really didn't think about it. Thanks for the idea! It's definitely gonna involve a lot of comfy's internals which my pack tries to avoid like the plague but at least it will be a learning experience for me.

2

u/fondlingbreeze 4d ago

I haven't downvoted it, but the problem I see almost immediately is that if this program is required to handle it, then once it stops being supported and a ComfyUI update at some point breaks it (which it will), then you're just stuck with a bunch of int8 converted files that you can't do anything with. It would make more sense if it was built into ComfyUI directly. Now maybe a person could go back and convert them back if a problem with support occurs in the future, but that effectively means there really wasn't technically any space savings at all. So I would say if it isn't already in the program, have it also be able to convert the files back at least in case a person needs to go back to using normal lora files.

Also, to me, it seems like kind of an extra step in resource usage, since you have to convert from INT8 back to the format a lora uses anyways. If anything, most people would rather conserve the more precious memory over storage space. I suppose options like this program provides are potentially useful to some, and so they should exist, but I personally would never bother.

1

u/BakaPotatoLord 4d ago

Good points.

I avoided patching comfy's internals for that reason exactly, my nodes does all the work and then just calls comfy's load lora function. But yes, still doesn't make it completely future proof.

Oh yeah, the extra resource usage is a trade-off though it kind of works out in some specific cases. For example, the MOSS 8 step LoRA was 1.1 GB, INT8 would take about ~280 MB and RAM usage with dtype bf16 during dequant would use ~560 MB. Lower than original but yes, uses more RAM in majority of the cases where LoRAs are in BF16 or FP16.

In my case, I am starving for storage space than RAM so it's a worthwhile trade-off, but I can see how it would be useless for quite a few others.

Another peep pointed out the same thing, having it a part of comfy so I am looking into what can be done and if I can raise a PR for it.

Thanks for the feedback!