|
| 1 | +# SenseNova-U1.5 (NEO-unify) architecture |
| 2 | + |
| 3 | +`sensenova/SenseNova-U1.5-8B-MoT` (`model_type: neo_chat`, architecture |
| 4 | +`NEOChatModel`) is a **native unified any-to-any** model: one backbone |
| 5 | +performs multimodal understanding, text-to-image generation, and image |
| 6 | +editing. This document records what was verified against the released |
| 7 | +checkpoint and the upstream reference implementation, so the Mobius |
| 8 | +export can be reviewed against facts rather than names. |
| 9 | + |
| 10 | +## Source-of-truth and a Hub packaging gap |
| 11 | + |
| 12 | +The HF repository declares remote code it does not ship: |
| 13 | + |
| 14 | +```json |
| 15 | +"auto_map": { |
| 16 | + "AutoConfig": "configuration_neo_chat.NEOChatConfig", |
| 17 | + "AutoModel": "modeling_neo_chat.NEOChatModel", |
| 18 | + "AutoModelForCausalLM": "modeling_neo_chat.NEOChatModel" |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +At revision `1f6ec60423d29939dde4202fd82ae340b144e280` (and at `main`), |
| 23 | +`configuration_neo_chat.py` and `modeling_neo_chat.py` both return **HTTP |
| 24 | +404**. `trust_remote_code=True` therefore cannot work against the Hub |
| 25 | +repo alone. The model card resolves this: the reference implementation |
| 26 | +lives in the **`sensenova_u1` Python package** at |
| 27 | +<https://github.com/OpenSenseNova/SenseNova-U1> (branch `feat/u1.5`), |
| 28 | +under `src/sensenova_u1/models/neo_unify/`. That package is the |
| 29 | +authoritative source used here. |
| 30 | + |
| 31 | +Two further packaging notes, both verified and both benign: |
| 32 | + |
| 33 | +* The shard sequence has gaps — `model-000{02,03,04}-of-00016.safetensors` |
| 34 | + are absent. `model.safetensors.index.json` references **no** tensor in |
| 35 | + those shards, so all 1116 tensors resolve and the checkpoint is |
| 36 | + complete. This is numbering slack, not missing weights. |
| 37 | +* There is no `preprocessor_config.json` and no `tokenizer.json`. Image |
| 38 | + preprocessing is defined only in code, and the tokenizer must be built |
| 39 | + from `vocab.json` + `merges.txt`. |
| 40 | + |
| 41 | +## Parameter budget |
| 42 | + |
| 43 | +17,532,854,464 parameters (≈50.2 GB on disk) despite the `8B` in the |
| 44 | +name — the second transformer branch is not counted by the marketing |
| 45 | +name. |
| 46 | + |
| 47 | +| Group | Params | Bytes | Stored dtype | |
| 48 | +|---|---|---|---| |
| 49 | +| Understanding branch (+ embed / lm_head) | 9.348 B | 18.70 GB | BF16 | |
| 50 | +| Generation branch (`_mot_gen`) | 8.121 B | 31.33 GB | mostly F32 | |
| 51 | +| `fm_modules` (embedders + pixel head) | 0.046 B | 0.16 GB | mixed | |
| 52 | +| Vision tower | 0.018 B | 0.04 GB | BF16 | |
| 53 | + |
| 54 | +## Mixture of Transformers |
| 55 | + |
| 56 | +Every one of the 42 Qwen3 decoder layers carries **two complete, |
| 57 | +disjoint weight sets**: |
| 58 | + |
| 59 | +``` |
| 60 | +self_attn.{q,k,v,o}_proj self_attn.{q,k,v,o}_proj_mot_gen |
| 61 | +self_attn.{q,k}_norm[_hw] self_attn.{q,k}_norm[_hw]_mot_gen |
| 62 | +mlp.{gate,up,down}_proj mlp_mot_gen.{gate,up,down}_proj |
| 63 | +input_layernorm input_layernorm_mot_gen |
| 64 | +post_attention_layernorm post_attention_layernorm_mot_gen |
| 65 | +model.norm model.norm_mot_gen |
| 66 | +``` |
| 67 | + |
| 68 | +There is no `lm_head_mot_gen`: the generation branch's output goes to |
| 69 | +the flow-matching head instead of the vocabulary. |
| 70 | + |
| 71 | +Routing is **per forward call**, not per token. `Qwen3Model.forward` |
| 72 | +reduces `image_gen_indicators` once and dispatches the whole call to |
| 73 | +either `forward_und` or `forward_gen`; the mixed path raises |
| 74 | +`NotImplementedError` at both the attention and decoder-layer level |
| 75 | +(upstream issue #207). Production therefore always splits the sequence |
| 76 | +at token-type boundaries: |
| 77 | + |
| 78 | +1. **Understanding pass** — text (and reference images) run through the |
| 79 | + understanding weights and write a KV cache. |
| 80 | +2. **Generation pass** — repeated once per flow-matching step, the noisy |
| 81 | + image runs through the `_mot_gen` weights with `update_cache=False`, |
| 82 | + attending over the frozen understanding prefix. |
| 83 | + |
| 84 | +Attention is shared in the sense that the generation pass *reads* the |
| 85 | +keys/values the understanding pass wrote. That is the entire conditioning |
| 86 | +mechanism. Because the split is intrinsic to the upstream design, the |
| 87 | +Mobius export mirrors it with two separate decoder graphs rather than |
| 88 | +one graph with runtime branching. |
| 89 | + |
| 90 | +## Three rotary axes |
| 91 | + |
| 92 | +`head_dim` is 128 and is partitioned per head: |
| 93 | + |
| 94 | +| Slice | Axis | Rotary base | Position source | |
| 95 | +|---|---|---|---| |
| 96 | +| `[0:64)` | temporal / text | `rope_theta` = 5e6 | `indexes[0]` | |
| 97 | +| `[64:96)` | image height | `rope_theta_hw` = 1e4 | `indexes[1]` | |
| 98 | +| `[96:128)` | image width | `rope_theta_hw` = 1e4 | `indexes[2]` | |
| 99 | + |
| 100 | +QK-norm is applied to *halves*, before the height/width split: |
| 101 | +`q_norm` normalises the 64 temporal dims and `q_norm_hw` the 64 spatial |
| 102 | +dims. This is why the checkpoint's `q_norm` / `k_norm` tensors have |
| 103 | +shape `[64]` rather than `[128]`. |
| 104 | + |
| 105 | +All image tokens of a single image share **one** temporal index (the |
| 106 | +text length), while their height/width indices tile the token grid. |
| 107 | + |
| 108 | +## Block-causal attention |
| 109 | + |
| 110 | +```python |
| 111 | +mask = (idx_j == idx_i) | (arange[None, :] <= arange[:, None]) |
| 112 | +``` |
| 113 | + |
| 114 | +Tokens sharing a temporal index attend to each other **bidirectionally**; |
| 115 | +ordinary causality holds across differing temporal indices. For a |
| 116 | +pure-text prompt every index is distinct, so this degenerates to a plain |
| 117 | +causal mask — which is why text-only parity passes even with a naive |
| 118 | +causal implementation, and why image parity does not. |
| 119 | + |
| 120 | +## Vision tower — no transformer blocks |
| 121 | + |
| 122 | +`NEOVisionModel` contains only: |
| 123 | + |
| 124 | +``` |
| 125 | +Conv2d(3, 1024, kernel=16, stride=16) # patchify |
| 126 | +GELU |
| 127 | +interleaved 2-D RoPE (theta 1e4) # first 512 ch <- x, last 512 <- y |
| 128 | +Conv2d(1024, 4096, kernel=2, stride=2) # 2x2 merge into the LLM width |
| 129 | +``` |
| 130 | + |
| 131 | +One LLM token therefore covers a **32x32 pixel** tile. The rotation is |
| 132 | +*interleaved* — pairs `(0,1), (2,3), …` share an angle — unlike the |
| 133 | +half-split convention used by the language backbone. |
| 134 | + |
| 135 | +The module is instantiated twice with independent weights: |
| 136 | +`vision_model` embeds reference images into the understanding branch, and |
| 137 | +`fm_modules.vision_model_mot_gen` embeds the noisy latent into the |
| 138 | +generation branch. |
| 139 | + |
| 140 | +## Flow matching without a VAE |
| 141 | + |
| 142 | +`use_pixel_head: true`, so `fm_modules.fm_head` is a `ConvDecoder` |
| 143 | +operating directly in pixel space: |
| 144 | + |
| 145 | +``` |
| 146 | +(B, 4096, H/32, W/32) |
| 147 | + PixelShuffle(2) -> Conv2d(1024, 1024, k3) -> GELU |
| 148 | + PixelShuffle(2) -> Conv2d(256, 192, k3) |
| 149 | + PixelShuffle(8) |
| 150 | +(B, 3, H, W) |
| 151 | +``` |
| 152 | + |
| 153 | +`PixelShuffle` corresponds exactly to ONNX `DepthToSpace` with |
| 154 | +`mode="CRD"`. The total 32x upsample equals `patch_size * merge_size`; |
| 155 | +the 192 output channels of `conv2` are `3 * 8 * 8`. |
| 156 | + |
| 157 | +The head predicts **x0** (the clean image), not the velocity. The |
| 158 | +sampler converts it: |
| 159 | + |
| 160 | +```python |
| 161 | +v = (x0 - z) / max(1 - t, t_eps) |
| 162 | +z = z + (t_next - t) * v |
| 163 | +``` |
| 164 | + |
| 165 | +Because `patchify` is a pure permutation, this arithmetic is identical |
| 166 | +whether performed on patches (as upstream does) or on the pixel grid, so |
| 167 | +the exported denoiser returns pixels directly. |
| 168 | + |
| 169 | +### Timestep and noise-scale conditioning |
| 170 | + |
| 171 | +Both embedders are `TimestepEmbedder(4096)` with a 256-wide sinusoidal |
| 172 | +basis, concatenated as `[cos, sin]` (note: diffusers uses `[sin, cos]`). |
| 173 | +The noise scale is resolution-dependent: |
| 174 | + |
| 175 | +```python |
| 176 | +noise_scale = min(sqrt(grid_h * grid_w / merge**2 / 64) * noise_scale, 16.0) |
| 177 | +``` |
| 178 | + |
| 179 | +and is fed to its embedder normalised by `noise_scale_max_value`. The |
| 180 | +two embeddings are summed and added to every image-token embedding. |
| 181 | + |
| 182 | +### Timestep schedule |
| 183 | + |
| 184 | +Only the `"standard"` branch of `_apply_time_schedule` is reachable — |
| 185 | +upstream unconditionally assigns `self.time_schedule = "standard"` on |
| 186 | +entry, making `time_shift_type`, `base_shift`, `max_shift`, |
| 187 | +`base_image_seq_len` and `max_image_seq_len` dead for inference: |
| 188 | + |
| 189 | +```python |
| 190 | +sigma = 1 - t |
| 191 | +sigma = shift * sigma / (1 + (shift - 1) * sigma) |
| 192 | +t = 1 - sigma |
| 193 | +``` |
| 194 | + |
| 195 | +## Exported package |
| 196 | + |
| 197 | +| Component | Role | Contents | |
| 198 | +|---|---|---| |
| 199 | +| `embedding` | token lookup | `embed_tokens` + reference-image scatter | |
| 200 | +| `vision_encoder` | reference images | understanding-branch patchify tower | |
| 201 | +| `decoder` | understanding decoder | 42 MoT layers + `norm` + `lm_head` | |
| 202 | +| `image_gen_embedding` | generation input | `vision_model_mot_gen` + timestep / noise-scale embedders | |
| 203 | +| `image_gen_denoiser` | generation decoder | 42 `_mot_gen` layers + `norm_mot_gen` + pixel head | |
| 204 | + |
| 205 | +`decoder` and `image_gen_denoiser` share the KV-cache layout, which is |
| 206 | +what lets the denoiser consume the prefill cache. |
| 207 | + |
| 208 | +### Numeric precision |
| 209 | + |
| 210 | +The two branches are stored in different dtypes upstream and behave |
| 211 | +differently under conversion: |
| 212 | + |
| 213 | +* The understanding branch is BF16 in the checkpoint and exports cleanly |
| 214 | + to **float16**. |
| 215 | +* The generation branch is stored **F32** and its activations exceed the |
| 216 | + fp16 range. Exported at float16 the flow-matching loop accumulates |
| 217 | + overflow and produces `NaN` part-way through sampling (observed at step |
| 218 | + 15 of 20 at 512x512). It must be exported at **float32** (or a |
| 219 | + wide-exponent format such as bf16 where the runtime supports it). |
| 220 | + |
| 221 | +Mixing the two is supported end to end: the sampler casts the fp16 KV |
| 222 | +cache to the generation branch's dtype once, after prefill. |
| 223 | + |
| 224 | +### GQA fusion does not apply |
| 225 | + |
| 226 | +Both decoder graphs keep plain opset-24 `Attention` nodes after |
| 227 | +CUDA/fp16 optimization, and Mobius emits its "GQA fusion expected" |
| 228 | +warning for each. That is expected here, not a defect — three |
| 229 | +independent guards each decline for a correct reason: |
| 230 | + |
| 231 | +* `decoder`'s attention bias is block-causal, so it contains an `Or`. |
| 232 | + `local_window_from_attention_bias` treats any `Or` in the bias walk as |
| 233 | + unrecognized and `AttentionToGQA` bails. |
| 234 | +* `image_gen_denoiser` has no `attention_mask` graph input at all (the |
| 235 | + generation pass is unmasked), and `AttentionToGQA` needs one to |
| 236 | + synthesize `seqlens_k`. |
| 237 | +* RoPE here is three independent axes with different bases, hand-built |
| 238 | + from Slice/Mul/Add rather than `op.RotaryEmbedding`, so |
| 239 | + `RotaryAttentionToGQA` cannot match either. |
| 240 | + |
| 241 | +Closing this would need `local_window_from_attention_bias` to learn the |
| 242 | +block-causal `Or` pattern and the denoiser to gain an explicit mask |
| 243 | +input; neither is required for correctness. |
| 244 | + |
| 245 | +## Runtime / metadata status |
| 246 | + |
| 247 | +Export and execution are complete — all five graphs build, load, and run |
| 248 | +on CPU and CUDA. Mobius now emits canonical hashless metadata for all five |
| 249 | +components plus the exact synthesized processor asset: RGB decode, pixel-area |
| 250 | +resize aligned to 32 in the 512²–2048² range, `1/255` rescaling, and ImageNet |
| 251 | +normalization. |
| 252 | + |
| 253 | +The generic workflow writes conditional and unconditional understanding KV |
| 254 | +once, casts the fp16 prefixes to fp32, and lets both CFG generation branches |
| 255 | +read the frozen state. The loop describes per-step image embedding, x0 |
| 256 | +prediction, `v = (x0 - z) / max(1 - t, t_eps)`, and Euler integration. This is |
| 257 | +an architecture-neutral shared-state pattern; no model-family dispatch exists |
| 258 | +in the runtime. |
| 259 | + |
| 260 | +PR CI uses deterministic tiny graphs to execute text-only, text-to-image, and |
| 261 | +reference-image-edit paths, including mixed precision, shared KV, CFG, and a |
| 262 | +two-step loop. Production evidence remains the pinned H200 run from PR #533: |
| 263 | +revision `1f6ec60423d29939dde4202fd82ae340b144e280`, stage-by-stage L4 parity, |
| 264 | +and L5 text/image/edit outputs. It is intentionally not repeated in ordinary CI |
| 265 | +because the checkpoint is about 50 GB. Before a release, rerun the same pinned |
| 266 | +export on an H200 with `mobius.build(..., revision=<revision>, |
| 267 | +load_weights=True)`, fp16 understanding and fp32 generation components, then |
| 268 | +repeat the shared-latent stage comparison and the three L5 output checks |
| 269 | +recorded in PR #533. |
| 270 | + |
| 271 | + |
| 272 | +## Dead or misleading upstream details |
| 273 | + |
| 274 | +Recorded so future readers do not port them by mistake: |
| 275 | + |
| 276 | +* `fm_head_dim` (1536), `fm_head_layers` (2) and `fm_head_mlp_ratio` |
| 277 | + describe the `SimpleMLPAdaLN` head, which is only constructed when |
| 278 | + `fm_head_layers > 2`. The released model uses the pixel head, and no |
| 279 | + `SimpleMLPAdaLN` tensors exist in the checkpoint. |
| 280 | +* `concat_time_token_num` is only ever read in an `== 0` assertion. |
| 281 | +* `_euler_step` is defined but never called; the generate methods inline |
| 282 | + the same expression. |
| 283 | +* `t_eps` is `0.05` in `config.json` but the shipped example CLIs never |
| 284 | + override the `0.02` function default, so real inference uses `0.02`. |
| 285 | +* `NEOVisionConfig` assigns `llm_hidden_size` and `downsample_ratio` with |
| 286 | + a trailing comma, making them one-element tuples; consuming code |
| 287 | + indexes `[0]`. The Mobius extractor unwraps this explicitly. |
| 288 | +* `PatchDecoder_postps`, `PatchDecoder_preps`, `ProgressiveConvDecoder`, |
| 289 | + `PostConvSmoother`, `NerfEmbedder` and `PositionEmbedding` are all |
| 290 | + unused by the released configuration. |
0 commit comments