SceneWorks commited on
Commit
35d6df7
Β·
verified Β·
1 Parent(s): ee74975

sc-5445: ship lean pre-quantized Q4 snapshot (Q4 DiT 32.8->8.9GB + quantization manifest; prune redundant raw pickles; refresh card)

Browse files
README.md CHANGED
@@ -21,7 +21,7 @@ base_model: zai-org/SCAIL-2
21
 
22
  ## What changed vs. upstream
23
  Every component is repackaged to the safetensors layout the SceneWorks Rust/MLX loaders consume β€” no PyTorch at runtime:
24
- - **DiT** (`model/1/fsdp2_rank_0000_checkpoint.pt`, an FSDP2/SAT checkpoint) was key-remapped to the `SCAIL2Model` parameter naming using the upstream `convert.py` contract (fused `query_key_value`β†’`q`/`k`/`v`, `key_value`β†’`k`/`v`, `clip_feature_key_value_list`β†’`k_img`/`v_img`) and cast **fp32 β†’ bf16** β†’ `dit.safetensors`. Bit-faithful (987 source keys β†’ 1307 model keys; exact key+shape match against `SCAIL2Model.from_config(config-14b.json)`).
25
  - **VAE** (`Wan2.1_VAE.pth`, the stock Wan2.1 z16 VAE) β†’ `vae.safetensors` (**f32**, channels-last conv transpose, keys unchanged β€” the `sanitize_wan_vae_weights` contract shared with Bernini/wan). Loaded by `mlx_gen_wan::WanVae`.
26
  - **Text encoder** (`umt5-xxl/models_t5_umt5-xxl-enc-bf16.pth`, stock UMT5-XXL) β†’ `t5_encoder.safetensors` (**bf16**, sole rename `.ffn.gate.0.`β†’`.ffn.gate_proj.`). Loaded by `mlx_gen_wan::Umt5Encoder` with `tokenizer.json`.
27
  - **Image encoder** (`models_clip_...onlyvisual.pth`, open-CLIP XLM-RoBERTa ViT-H/14) β†’ `clip.safetensors` (**f32**, de-prefixed `visual.*` keys). Loaded by `mlx_gen_scail2::ScailClip` (32-layer visual tower, `use_31_block` penultimate features).
@@ -31,21 +31,22 @@ The converted VAE/UMT5 are byte-size-identical (modulo safetensors header) to Be
31
  ## Contents (turnkey MLX snapshot)
32
  | file | source | loader | notes |
33
  |---|---|---|---|
34
- | `dit.safetensors` | converted | `Scail2Dit` | SCAIL-2 14B DiT, **bf16**, 1307 tensors (~31 GB) |
35
  | `vae.safetensors` | converted | `WanVae` | Wan2.1 z16 VAE, **f32**, stride (4,8,8) (~0.5 GB) |
36
  | `t5_encoder.safetensors` | converted | `Umt5Encoder` | UMT5-XXL encoder, **bf16** (~11 GB) |
37
  | `clip.safetensors` | converted | `ScailClip` | open-CLIP ViT-H/14 visual tower, **f32**, 1280-dim (~2.5 GB) |
38
  | `tokenizer.json` | upstream, stock | `load_tokenizer` | UMT5-XXL HF tokenizer (root copy) |
39
- | `config.json` | upstream `configs/config-14b.json` | `Scail2Config` | `model_type: i2v`, `dim 5120`, `ffn 13824`, `40` layers/heads, `in_dim 20`, `mask_dim 28`, `out_dim 16` |
40
- | `bias-aware-dpo-lora.pt` | upstream, stock | (sc-5451) | optional Bias-Aware DPO refinement LoRA |
41
 
42
- Quantization (Q4/Q8) is applied at **load time** by the SceneWorks worker (`mlx_gen` `.quantize()`); this snapshot ships the dense bf16/f32 weights.
43
-
44
- The raw upstream pickles (`Wan2.1_VAE.pth`, `umt5-xxl/models_t5_umt5-xxl-enc-bf16.pth`, `models_clip_...onlyvisual.pth`) remain in this repo for provenance; the Rust loaders use only the converted safetensors above, so a lean SceneWorks pull can skip them.
45
 
46
  ## Architecture (summary)
47
  Wan2.1-14B **I2V** dense DiT. Conditioning is a **token-axis packed** stream β€” reference + video + pose patch-embedded (three Conv3d stems) with additive 28-channel color-coded mask embeddings, concatenated into one self-attention sequence β€” plus a **per-source RoPE** with integer T/H/W shifts (the `replace_flag` flips the reference H-shift, toggling animation vs. replacement). The reference image is encoded by the CLIP visual tower and injected via Wan-I2V image cross-attention. Sampling is plain CFG (guide 5.0), flow-matching UniPC/DPM++.
48
 
 
 
 
49
  ## License & attribution
50
  This repackaging redistributes upstream weights under the license declared on the upstream model card (**MIT**); the upstream code repository is Apache-2.0. Please consult and cite the original:
51
  - Model: https://huggingface.co/zai-org/SCAIL-2
 
21
 
22
  ## What changed vs. upstream
23
  Every component is repackaged to the safetensors layout the SceneWorks Rust/MLX loaders consume β€” no PyTorch at runtime:
24
+ - **DiT** (`model/1/fsdp2_rank_0000_checkpoint.pt`, an FSDP2/SAT checkpoint) was key-remapped to the `SCAIL2Model` parameter naming using the upstream `convert.py` contract (fused `query_key_value`β†’`q`/`k`/`v`, `key_value`β†’`k`/`v`, `clip_feature_key_value_list`β†’`k_img`/`v_img`), cast **fp32 β†’ bf16**, then **pre-quantized to group-wise-affine Q4** on disk β†’ `dit.safetensors`. The attention (`q`/`k`/`v`/`o` + I2V `k_img`/`v_img`) and FFN (`ffn.0`/`ffn.2`) Linears are packed (`weight` u32 codes + `scales` + `biases` via MLX `quantize`, byte-equal to `nn.quantize`, group size 64); the patch/text/time/image embeddings, norms, and output head stay dense bf16. A `config.json` `quantization` block marks the snapshot so the loader builds the quantized Linears directly from the packs (no dense bf16 materialized at load). Bit-faithful key remap (987 source keys β†’ 1307 model keys; exact key+shape match against `SCAIL2Model.from_config(config-14b.json)`).
25
  - **VAE** (`Wan2.1_VAE.pth`, the stock Wan2.1 z16 VAE) β†’ `vae.safetensors` (**f32**, channels-last conv transpose, keys unchanged β€” the `sanitize_wan_vae_weights` contract shared with Bernini/wan). Loaded by `mlx_gen_wan::WanVae`.
26
  - **Text encoder** (`umt5-xxl/models_t5_umt5-xxl-enc-bf16.pth`, stock UMT5-XXL) β†’ `t5_encoder.safetensors` (**bf16**, sole rename `.ffn.gate.0.`β†’`.ffn.gate_proj.`). Loaded by `mlx_gen_wan::Umt5Encoder` with `tokenizer.json`.
27
  - **Image encoder** (`models_clip_...onlyvisual.pth`, open-CLIP XLM-RoBERTa ViT-H/14) β†’ `clip.safetensors` (**f32**, de-prefixed `visual.*` keys). Loaded by `mlx_gen_scail2::ScailClip` (32-layer visual tower, `use_31_block` penultimate features).
 
31
  ## Contents (turnkey MLX snapshot)
32
  | file | source | loader | notes |
33
  |---|---|---|---|
34
+ | `dit.safetensors` | converted | `Scail2Dit` | SCAIL-2 14B DiT, **Q4 packed** (attn + FFN) + dense bf16 (embeds/norms/head), ~8.9 GB |
35
  | `vae.safetensors` | converted | `WanVae` | Wan2.1 z16 VAE, **f32**, stride (4,8,8) (~0.5 GB) |
36
  | `t5_encoder.safetensors` | converted | `Umt5Encoder` | UMT5-XXL encoder, **bf16** (~11 GB) |
37
  | `clip.safetensors` | converted | `ScailClip` | open-CLIP ViT-H/14 visual tower, **f32**, 1280-dim (~2.5 GB) |
38
  | `tokenizer.json` | upstream, stock | `load_tokenizer` | UMT5-XXL HF tokenizer (root copy) |
39
+ | `config.json` | upstream `configs/config-14b.json` + `quantization` block | `Scail2Config` | `model_type: i2v`, `dim 5120`, `ffn 13824`, `40` layers/heads, `in_dim 20`, `mask_dim 28`, `out_dim 16`; `quantization: {bits 4, group_size 64}` |
40
+ | `bias-aware-dpo-lora.pt` | upstream, stock | `mlx_gen_scail2` (sc-5451) | optional Bias-Aware DPO refinement LoRA |
41
 
42
+ The DiT ships **pre-quantized to Q4 on disk** (the SceneWorks worker default), so the loader reads the packs directly β€” there is no dense-bf16 load transient. The VAE / UMT5 / CLIP ship dense (f32 / bf16). This repo ships **only** the loadable safetensors + tokenizer + the optional DPO LoRA; the redundant raw upstream pickles (`Wan2.1_VAE.pth`, `umt5-xxl/models_t5_...pth`, `models_clip_...onlyvisual.pth`) have been **pruned** β€” they are reproducible from the upstream release and the Rust loaders never used them.
 
 
43
 
44
  ## Architecture (summary)
45
  Wan2.1-14B **I2V** dense DiT. Conditioning is a **token-axis packed** stream β€” reference + video + pose patch-embedded (three Conv3d stems) with additive 28-channel color-coded mask embeddings, concatenated into one self-attention sequence β€” plus a **per-source RoPE** with integer T/H/W shifts (the `replace_flag` flips the reference H-shift, toggling animation vs. replacement). The reference image is encoded by the CLIP visual tower and injected via Wan-I2V image cross-attention. Sampling is plain CFG (guide 5.0), flow-matching UniPC/DPM++.
46
 
47
+ ## Runtime (Apple Silicon)
48
+ The production default β€” **832Γ—480 / 5 s** (one 81-frame driving segment) β€” runs the DiT in **f32 compute** (bf16 overflows to NaN at that packed-sequence length), with shared FFN/attention activation chunking and a temporal-tiled VAE decode, at a measured process footprint of **~70–76 GB**. SceneWorks gates SCAIL-2 to **96 GB**-class Macs. The Q4 DiT keeps the resident weights and the snapshot download lean (β‰ˆ 24 GB total).
49
+
50
  ## License & attribution
51
  This repackaging redistributes upstream weights under the license declared on the upstream model card (**MIT**); the upstream code repository is Apache-2.0. Please consult and cite the original:
52
  - Model: https://huggingface.co/zai-org/SCAIL-2
Wan2.1_VAE.pth DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:38071ab59bd94681c686fa51d75a1968f64e470262043be31f7a094e442fd981
3
- size 507609880
 
 
 
 
config.json CHANGED
@@ -2,14 +2,18 @@
2
  "_class_name": "WanSCAILModel",
3
  "_diffusers_version": "0.30.0",
4
  "dim": 5120,
5
- "eps": 1e-06,
6
  "ffn_dim": 13824,
7
  "freq_dim": 256,
8
  "in_dim": 20,
9
- "mask_dim": 28,
10
  "model_type": "i2v",
11
  "num_heads": 40,
12
  "num_layers": 40,
13
  "out_dim": 16,
 
 
 
 
14
  "text_len": 512
15
- }
 
2
  "_class_name": "WanSCAILModel",
3
  "_diffusers_version": "0.30.0",
4
  "dim": 5120,
5
+ "eps": 1e-6,
6
  "ffn_dim": 13824,
7
  "freq_dim": 256,
8
  "in_dim": 20,
9
+ "mask_dim": 28,
10
  "model_type": "i2v",
11
  "num_heads": 40,
12
  "num_layers": 40,
13
  "out_dim": 16,
14
+ "quantization": {
15
+ "bits": 4,
16
+ "group_size": 64
17
+ },
18
  "text_len": 512
19
+ }
dit.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:edb1d362c34ae98be657cd7aa4fbd6eaa9737eacf675823be0c04b64537088fd
3
- size 32791225720
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8aa6a80345bbeab2a42bdf09977d64ad63920a5846a3850a3fcc5b61cc5eddc1
3
+ size 9578472097
models_clip_open-clip-xlm-roberta-large-vit-huge-14-onlyvisual.pth DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:020daacf4c0ce94284df584d243cefb6ddfadefff8772226a8e85431df5de2da
3
- size 2528485611
 
 
 
 
umt5-xxl/models_t5_umt5-xxl-enc-bf16.pth DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:7cace0da2b446bbbbc57d031ab6cf163a3d59b366da94e5afe36745b746fd81d
3
- size 11361920418