WeGen2-NVFP4 / README.md
HDiffusion's picture
Update README.md
196dcf6 verified
|
Raw History Blame Contribute Delete
2.75 kB
---
license: other
license_name: unspecified-upstream
base_model: GrayShine/WeGen2
base_model_relation: quantized
pipeline_tag: text-to-image
tags:
- nvfp4
- text-to-image
- image-editing
- pixel-space
- mixture-of-experts
---
# WeGen2 NVFP4
An conversion of [GrayShine/WeGen2](https://huggingface.co/GrayShine/WeGen2) (49 BF16 shards, 123 GB) into
one 39.6 GB safetensors file. The routed experts are quantized to NVFP4; everything else is the original BF16. The model,
its tokenizer and its pixel patchify and unpatchify are all in the one file.
> **Disclaimer.** This is a conversion solely for use with [comfyui-backend-but-rust](https://github.com/BetaDoggo/comfyui-backend-but-rust), nothing else is likely to support it. This conversion seems quite lossy, fp8 or something in between would probably be better, but the model is huge as it is, so I won't bother.
## License
The original repository states no license for the WeGen2 weights. This conversion is shared on the same terms as the
original; check with its authors before any use that needs a license. Model by WeChat Vision, Tencent, with SJTU and
MMLab @ SIAT (Shaobin Zhuang, Zhipeng Huang, Canmiao Fu et al.), [arXiv:2612.01618](https://arxiv.org/abs/2612.01618).
## What the file holds
| Tensors | Format |
|---|---|
| Routed experts, `language_model.model.layers.N.mlp_{und,gen}.experts.{gate_up_proj,down_proj}`, shipped as BF16 `[E, N, K]` | NVFP4, each expert scaled on its own: the tensor itself is U8 `[E, N, K/2]`, two E2M1 values a byte, element 2i in the low nibble; `<name>_scale` is F8_E4M3 `[E, N, K/16]`, row major, one scale per 16 columns; `<name>_scale_2` is F32 `[E]`, one per expert. A value is `e2m1 * f32(e4m3) * scale_2[e]`. Each 16-value block's scale is picked from 12 candidates at or below its absolute maximum, for the least squared error. `gate_up_proj` keeps the gate's rows first |
| Everything else: attention, shared experts, routers, norms, AttnRes projections, embeddings, `lm_head`, the patchify convolutions, `llm2pixel` and the time embedder | BF16 as shipped, under the original names |
| `tokenizer.json` | The text tokenizer's JSON file, as U8 bytes |
The `__metadata__` holds `wegen2` (the format, `wegen2-nvfp4-v1`) and `config` (the original `config.json`).
## Making it yourself
The conversion script downloads up to eight original shards at a time into RAM, converts each and drops it, so it needs
only the output's disk space. It needs Python with torch and a CUDA GPU. The two scripts are included here and live in
the engine's repository as `tools/wegen2_convert.py` and `tools/nemotron_image_convert.py` (whose download, NVFP4 and
writer code it shares):
```
python wegen2_convert.py WeGen2-nvfp4.safetensors
```