ClipProj v0.1.1: attention-sink vector added to every matrix, plus 8B and int8_convrot
Browse files- README.md +33 -17
- h3_control_identity.pt +2 -2
- h3_control_zero.pt +2 -2
- h3_qwen3vl_4b_int8convrot_tap24.pt +3 -0
- h3_qwen3vl_4b_tap24.pt +2 -2
- h3_qwen3vl_4b_tap24_200prompts.pt +2 -2
- h3_qwen3vl_8b_tap24.pt +3 -0
README.md
CHANGED
|
@@ -23,27 +23,41 @@ library_name: comfyui
|
|
| 23 |
These files are useless on their own. They require the custom node:
|
| 24 |
**[github.com/nicolab28/ComfyUI-ClipProj](https://github.com/nicolab28/ComfyUI-ClipProj)**
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
## What this is
|
| 27 |
|
| 28 |
-
MiniMax H3 conditions on a Qwen3-VL-32B truncated to 50 layers β 15.7 GB in NVFP4 β solely to turn a prompt into a `[seq, 5120]` tensor. This repository provides a learned linear map that lets
|
| 29 |
|
| 30 |
```
|
| 31 |
cond = ((h - mean_in) / std_in) @ W * std_out + mean_out
|
| 32 |
```
|
| 33 |
|
| 34 |
-
It works because
|
| 35 |
|
| 36 |
## Files
|
| 37 |
|
| 38 |
-
| File | Size | Description |
|
| 39 |
-
|---|---|---|
|
| 40 |
-
| `h3_qwen3vl_4b_tap24.pt` | 50 MB | **The learned matrix.** Calibrated on 2 000 prompts / 288 608 tokens, tap 24 of 36 |
|
| 41 |
-
| `h3_qwen3vl_4b_tap24_200prompts.pt` | 50 MB | Same, calibrated on 200 prompts only β kept for comparison |
|
| 42 |
-
| `h3_control_identity.pt` | 50 MB | **Control**: raw copy of the 2560 dims, no learning |
|
| 43 |
-
| `h3_control_zero.pt` | 50 MB | **Control**: `W = 0`, carries no prompt information |
|
| 44 |
-
|
| 45 |
Put them in `ComfyUI/models/clip_projections/`.
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
## Measured results
|
| 48 |
|
| 49 |
| Corpus | Tokens | Cross-prompt CKA | Test cosine | Test RΒ² |
|
|
@@ -53,9 +67,9 @@ Put them in `ComfyUI/models/clip_projections/`.
|
|
| 53 |
|
| 54 |
Eight times the data buys 1.8 % of cosine: the linear projection is **at its ceiling**, not starved of data. Going further needs an MLP, not more prompts.
|
| 55 |
|
| 56 |
-
A cosine of 0.71 sounds poor and is not β the DiT tolerates far more than the metric suggests. What holds up in actual generation: simple prompts, structured multi-shot prompts (four distinct cuts with no bleed between them),
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
## Run the controls first
|
| 61 |
|
|
@@ -73,21 +87,23 @@ The two control matrices exist to prove the learned matrix is doing the work rat
|
|
| 73 |
|
| 74 |
## Known limitations
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
-
- image references work in **fl2va**, but the matrix was calibrated on text positions only, so vision positions are projected out of their training distribution
|
| 84 |
|
| 85 |
## Required models
|
| 86 |
|
| 87 |
| Role | Model |
|
| 88 |
|---|---|
|
| 89 |
| Diffusion model + VAEs | [Comfy-Org/MiniMax-H3](https://huggingface.co/Comfy-Org/MiniMax-H3) |
|
| 90 |
-
| Text encoder
|
|
|
|
| 91 |
|
| 92 |
The 32B text encoder is **no longer needed** β that is the entire point.
|
| 93 |
|
|
|
|
| 23 |
These files are useless on their own. They require the custom node:
|
| 24 |
**[github.com/nicolab28/ComfyUI-ClipProj](https://github.com/nicolab28/ComfyUI-ClipProj)**
|
| 25 |
|
| 26 |
+
## v0.1.1 β re-download if you got the first release
|
| 27 |
+
|
| 28 |
+
**The first release was missing the attention-sink vector, and short prompts suffered for it.** The first token of a sequence is an attention sink: its direction is constant from one prompt to the next (cosine 1.0000 measured over 1966 prompts) and it carries nothing from the text, yet its norm reaches 16 500 against 291 for a text token. Calibration excluded it, rightly β its extreme values would wreck the statistics β but the node projected it anyway, through a matrix that had never seen one, producing an arbitrary vector of enormous norm. Invisible on a 200-token prompt where it is 0.5 % of the positions, ruinous on a 7-token one where it is 14 %.
|
| 29 |
+
|
| 30 |
+
Every matrix here now carries the measured sink vector and substitutes it at inference. Since the vector is constant, this is not an approximation: it is the value the 32B would have produced.
|
| 31 |
+
|
| 32 |
+
Also new in this release: an **8B matrix**, an **int8_convrot matrix**, and **ref2va now works** β see below.
|
| 33 |
+
|
| 34 |
## What this is
|
| 35 |
|
| 36 |
+
MiniMax H3 conditions on a Qwen3-VL-32B truncated to 50 layers β 15.7 GB in NVFP4 β solely to turn a prompt into a `[seq, 5120]` tensor. This repository provides a learned linear map that lets a much smaller Qwen3-VL produce the same conditioning:
|
| 37 |
|
| 38 |
```
|
| 39 |
cond = ((h - mean_in) / std_in) @ W * std_out + mean_out
|
| 40 |
```
|
| 41 |
|
| 42 |
+
It works because every Qwen3-VL shares the **same tokenizer** (151936 tokens): a prompt yields the same tokens at the same positions in both models, so a position-by-position mapping between their hidden states can be learned. Calibration is plain **ridge regression** β no gradients, no epochs, no learning rate.
|
| 43 |
|
| 44 |
## Files
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
Put them in `ComfyUI/models/clip_projections/`.
|
| 47 |
|
| 48 |
+
| File | Encoder it was calibrated on | Corpus | Test cosine |
|
| 49 |
+
|---|---|---|---|
|
| 50 |
+
| `h3_qwen3vl_4b_tap24.pt` | `qwen3vl_4b_bf16` | 2 000 prompts | 0.712 |
|
| 51 |
+
| `h3_qwen3vl_4b_tap24_200prompts.pt` | `qwen3vl_4b_bf16` | 200 prompts | 0.699 |
|
| 52 |
+
| `h3_qwen3vl_4b_int8convrot_tap24.pt` | `qwen3vl_4b_int8_convrot` | 240 prompts | 0.697 |
|
| 53 |
+
| `h3_qwen3vl_8b_tap24.pt` | `qwen3vl_8b_nvfp4` | 203 prompts | 0.731 |
|
| 54 |
+
| `h3_control_identity.pt` | β | β | control |
|
| 55 |
+
| `h3_control_zero.pt` | β | β | control |
|
| 56 |
+
|
| 57 |
+
**Start with `h3_qwen3vl_4b_tap24.pt`.** It is calibrated on the largest corpus, and one matrix covers every Qwen3-VL-4B variant β the measured cosine gap between a bf16-calibrated matrix applied to an abliterated fp8 encoder is 0.0023. The two smaller-corpus matrices are provided for comparison, not because they are better.
|
| 58 |
+
|
| 59 |
+
The **8B matrix needs an 8B encoder** β different input width (4096 instead of 2560), so it is not interchangeable with the 4B ones. The node checks and refuses a mismatch.
|
| 60 |
+
|
| 61 |
## Measured results
|
| 62 |
|
| 63 |
| Corpus | Tokens | Cross-prompt CKA | Test cosine | Test RΒ² |
|
|
|
|
| 67 |
|
| 68 |
Eight times the data buys 1.8 % of cosine: the linear projection is **at its ceiling**, not starved of data. Going further needs an MLP, not more prompts.
|
| 69 |
|
| 70 |
+
A cosine of 0.71 sounds poor and is not β the DiT tolerates far more than the metric suggests. What holds up in actual generation: simple prompts, structured multi-shot prompts (four distinct cuts with no bleed between them), fl2va with first and last frame, and ref2va with a reference image.
|
| 71 |
|
| 72 |
+
Fidelity does **not** collapse on short prompts, contrary to what one might expect from a corpus of long ones: measured per-token cosine goes from 0.937 at 80 words down to 0.908 at 2 words, a 3 % decline, once the sink is handled.
|
| 73 |
|
| 74 |
## Run the controls first
|
| 75 |
|
|
|
|
| 87 |
|
| 88 |
## Known limitations
|
| 89 |
|
| 90 |
+
**Named references depend on the encoder, not on the projection.** This was measured rather than guessed: asking the encoder to describe a person in plain text β which bypasses the matrix entirely β shows where the knowledge actually stops. The 4B places Scarlett Johansson correctly as Black Widow but believes she has dark brown hair; the 8B describes her correctly as blonde with blue eyes. So when a proper noun renders as the wrong person, question the encoder first.
|
| 91 |
+
|
| 92 |
+
The practical workaround is to describe rather than name: *"the actress X as [role], blonde, ..."* recovers an identity that the bare name loses, on both the 4B and the 8B. A name is a fragile signal carried by two or three tokens; a description spreads it over a dozen redundant ones and the reconstruction error averages out instead of accumulating.
|
| 93 |
|
| 94 |
+
Note that this does not apply to **ref2va**: there the identity comes from the reference image, so the encoder's factual gaps stop mattering.
|
| 95 |
|
| 96 |
+
**Quantisation costs facts.** The same test on `int8_convrot` against `bf16` shows two factual errors appearing under quantisation. Fine for general use, worth knowing if your prompts lean on proper nouns.
|
| 97 |
|
| 98 |
+
**Speech in languages other than English degrades.** Reported and reproduced with French: the 32B pronounces it cleanly, a projected 4B or 8B does not. This is *not* a corpus problem β measured on identical English prompts differing only in the quoted line, French tokens reconstruct at 0.8974 against 0.8996 for English, which is noise. A cosine of 0.90 is ample for visual semantics and insufficient for phonetics; the DiT's audio branch is far more demanding than its image branch, and a language the model handles less confidently has less margin to absorb the error.
|
|
|
|
| 99 |
|
| 100 |
## Required models
|
| 101 |
|
| 102 |
| Role | Model |
|
| 103 |
|---|---|
|
| 104 |
| Diffusion model + VAEs | [Comfy-Org/MiniMax-H3](https://huggingface.co/Comfy-Org/MiniMax-H3) |
|
| 105 |
+
| Text encoder, 4B | [Comfy-Org/Krea-2](https://huggingface.co/Comfy-Org/Krea-2) β `text_encoders/qwen3vl_4b_fp8_scaled.safetensors` |
|
| 106 |
+
| Text encoder, 8B | any ComfyUI-format Qwen3-VL-8B (the 8B matrix expects 4096 input dims) |
|
| 107 |
|
| 108 |
The 32B text encoder is **no longer needed** β that is the entire point.
|
| 109 |
|
h3_control_identity.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:36119c56154dda6984317a35feee38577a4f8793ae87cd9db79a42aa2d676922
|
| 3 |
+
size 52514021
|
h3_control_zero.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ee3e85bf9851f0370b3a5ec328da34f0a4ba8b0845d230b89a00fb73a2491136
|
| 3 |
+
size 52513909
|
h3_qwen3vl_4b_int8convrot_tap24.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:11aa0b0f14c8dd5a2f0c2206d3a44dabebbe4167ffb13bee0c23817d2ceab587
|
| 3 |
+
size 52514229
|
h3_qwen3vl_4b_tap24.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:941b94675714985232346ffb9e06cf8a3dfb1c61cfa6e2fb24a733dabec60df1
|
| 3 |
+
size 52514021
|
h3_qwen3vl_4b_tap24_200prompts.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:74a78d637e3799bd380c772c016e7a8e577216699c191d703c331d9c541cda8b
|
| 3 |
+
size 52514089
|
h3_qwen3vl_8b_tap24.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:363d15189c5a5fdd67d831e613108e9e9babd88fd2d09e6a14727493f89b4f33
|
| 3 |
+
size 83983589
|