IMPORTANT: This VAE requires reflection padding on conv layers. It should be added both in your trainer, and your webui.
You can do it with this function on VAE model:
for module in self.model.modules():
if isinstance(module, nn.Conv2d):
pad_h, pad_w = module.padding if isinstance(module.padding, tuple) else (module.padding, module.padding)
if pad_h > 0 or pad_w > 0:
module.padding_mode = "reflect"
If you have trained without this - don't worry, just add this modification and do a small tune to fix up artefacts on edges.
This implementation additionally utilizes some of fixes proposed in VIVAT paper, and custom in-house regularization techniques, as well as training implementation.
This is a finetuned SDXL VAE, adapted with new regularization, and other techniques. You can use this with your existing SDXL model, but image will be quite artefacting, particularly - oversharpening and ringing.
This VAE is supposed to be used for finetune, after that images will become normal. But be aware, compatibility with old VAEs, that are not EQ, will be lost(They will become blurry).
B2 is a direct continuation of base version, stats displayed are cumulative across multiple runs.
I took batch of 75k images, so samples seen never repeated.
B3 repeats B2 for another batch of data and further solidifies cleaner latents. Minor tweaks were done to training code for better regularization.
B4 changes mixture a bit, to concentrate more on reconstruction quality. Additionally, resolution was increased to 320. Wavelet loss was added at low values(but it's effect is yet to be studied).
Im using small test set i have on me, separated into anime(434) and photo(500) images. Additionally, im measuring noise in latents. Sorgy for no larger test sets.
Results on small benchmark of 500 photos
VAE SDXL
L1 ↓
L2 ↓
PSNR ↑
LPIPS ↓
MS-SSIM ↑
KL ↓
Consistency ↓
RFID ↓
sdxl_vae
6.282
10.534
29.278
0.063
0.947
31.216
0.0086
4.819
Kohaku EQ-VAE
6.423
10.428
29.140
0.082
0.945
43.236
n/a
6.202
Anzhc MS-LC-EQ-D-VR VAE
5.975
10.096
29.526
0.106
0.952
33.176
n/a
5.578
Anzhc MS-LC-EQ-D-VR VAE B2
6.082
10.214
29.432
0.103
0.951
33.535
n/a
5.509
Anzhc MS-LC-EQ-D-VR VAE B3
6.066
10.151
29.475
0.104
0.951
34.341
n/a
5.538
Anzhc MS-LC-EQ-D-VR VAE B4
5.839
9.818
29.788
0.112
0.9535
35.762
n/a
5.260
Anzhc MS-LC-EQ-D-VR VAE B5
5.8117
9.7627
29.8545
0.1112
0.9538
36.5573
0.0080
4.963894
Anzhc MS-LC-EQ-D-VR VAE B7
5.7046
9.5975
30.0106
0.0980
0.9553
39.4477
0.0071
4.017592
VAE FLUX
L1 ↓
L2 ↓
PSNR ↑
LPIPS ↓
MS-SSIM ↑
KL ↓
CONSISTENCY ↓
rFID ↓
FLUX VAE
4.1471
6.2940
33.3887
0.0209
0.9868
12.1461
0.0077
0.564150
MS-LC-EQ-D-VR VAE FLUX
3.799
6.077
33.807
0.032
0.986
10.992
—
1.692
Flux EQ v2 B1
3.4560
5.5851
34.6641
0.0281
0.9884
11.4340
0.0040
0.686061
Noise in latents
VAE SDXL
Noise ↓
sdxl_vae
27.508
Kohaku EQ-VAE
17.395
Anzhc MS-LC-EQ-D-VR VAE
15.527
Anzhc MS-LC-EQ-D-VR VAE B2
13.914
Anzhc MS-LC-EQ-D-VR VAE B3
13.124
Anzhc MS-LC-EQ-D-VR VAE B4
12.354
Anzhc MS-LC-EQ-D-VR VAE B5
11.846
Anzhc MS-LC-EQ-D-VR VAE B7
12.1471
VAE FLUX
Noise ↓
FLUX VAE
10.499
MS‑LC‑EQ‑D‑VR VAE FLUX
7.635
Flux EQ v2 B1
8.5019
Results on a small benchmark of 434 Illustrations from Boorus
VAE SDXL
L1 ↓
L2 ↓
PSNR ↑
LPIPS ↓
MS-SSIM ↑
KL ↓
Consistency ↓
RFID ↓
sdxl_vae
4.369
7.905
31.080
0.038
0.969
35.057
0.0079
5.088
Kohaku EQ-VAE
4.818
8.332
30.462
0.048
0.967
50.022
n/a
7.264
Anzhc MS-LC-EQ-D-VR VAE
4.351
7.902
30.956
0.062
0.970
36.724
n/a
6.239
Anzhc MS-LC-EQ-D-VR VAE B2
4.313
7.935
30.951
0.059
0.970
36.963
n/a
6.147
Anzhc MS-LC-EQ-D-VR VAE B3
4.323
7.910
30.977
0.058
0.970
37.809
n/a
6.075
Anzhc MS-LC-EQ-D-VR VAE B4
4.140
7.617
31.343
0.058
0.971
39.057
n/a
5.670
Anzhc MS-LC-EQ-D-VR VAE B5
4.0998
7.5481
31.4378
0.0569
0.9717
39.8600
0.0070
5.178428
Anzhc MS-LC-EQ-D-VR VAE B7
3.9949
7.3784
31.6544
0.0508
0.9731
42.8447
0.0063
4.216971
Anzhc B7 Decoer-only pass
3.9856
7.3349
31.6946
0.0505
0.9735
42.8447
0.0065
3.851861
Anzhc B7 decoderB2
3.9683
7.3165
31.7230
0.0492
0.9740
42.8447
0.006282
3.666439
VAE FLUX
L1 ↓
L2 ↓
PSNR ↑
LPIPS ↓
MS-SSIM ↑
KL ↓
CONSISTENCY ↓
rFID ↓
FLUX VAE
3.0600
4.7752
35.4400
0.0112
0.9905
12.4717
0.0079
0.669906
MS-LC-EQ-D-VR VAE FLUX
2.933
4.856
35.251
0.018
0.990
11.225
—
1.561
Flux EQ v2 B1
2.4825
4.2776
36.6027
0.0132
0.9916
11.6388
0.0039
0.744904
Noise in latents
VAE SDXL
Noise ↓
sdxl_vae
26.359
Kohaku EQ-VAE
17.314
Anzhc MS-LC-EQ-D-VR VAE
14.976
Anzhc MS-LC-EQ-D-VR VAE B2
13.649
Anzhc MS-LC-EQ-D-VR VAE B3
13.247
Anzhc MS-LC-EQ-D-VR VAE B4
12.652
Anzhc MS-LC-EQ-D-VR VAE B5
12.217
Anzhc MS-LC-EQ-D-VR VAE B7
12.3996
VAE FLUX
Noise ↓
FLUX VAE
9.913
MS‑LC‑EQ‑D‑VR VAE FLUX
7.723
Flux EQ v2 B1
8.4004
KL loss suggests that this VAE implementation is much closer to SDXL, and likely will be a better candidate for further finetune, but that is just a theory.
B2 further improves latent clarity, while maintaining same or better performance. Particularly improved very fine texture handling, which previously would be overcorrected into smooth surface. Performs better in such cases now.
B3 cleans them up ever more, but at that point visually they are +- same.
B4 Moar.
B5 MOAR. (also benchmarked with padding added, so results are overall a tiny bit more consistent due to fixed edges)
B6-7 Concentration on improving details. Previous runs were clearing latents up as much as possible, now target is to preserve and improve, while allowing model to still change latents to accommodate for new details in a clear way.
1@misc{anzhc_ms-lc-eq-d-vr_vae,
2 author = {Anzhc},
3 title = {MS-LC-EQ-D-VR VAE: another reproduction of EQ-VAE on variable VAEs and then some},
4 year = {2025},
5 howpublished = {Hugging Face model card},
6 url = {https://huggingface.co/Anzhc/MS-LC-EQ-D-VR_VAE},
7 note = {Finetuned SDXL-VAE with EQ regularization and more, for improved latent representation.}
8}