Skip to content

Add canonical metadata for SenseNova U1.5 - #540

Merged
justinchuby merged 5 commits into
mainfrom
copilot/sensenova-canonical-metadata
Aug 22, 2026
Merged

justinchuby merged 5 commits into
mainfrom
copilot/sensenova-canonical-metadata

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

This rebases the existing SenseNova U1.5 implementation from #533 onto current main and removes its canonical-metadata waiver.

  • structurally detect a generic five-component shared-state pixel-flow package
  • emit hashless canonical metadata for embedding, vision encoder, understanding decoder, generation embedding, and generation denoiser
  • synthesize the exact missing processor asset: DecodeImage/RGB, pixel-area resize aligned to 32 (512²–2048²), Lanczos, 1/255, ImageNet normalization
  • express conditional/unconditional frozen KV groups, fp16→fp32 boundaries, per-step embedding, CFG, x0 prediction, v=(x0-z)/max(1-t,t_eps), Euler update, and pixel output using generic workflow IR
  • add a deterministic no-network five-component conformance package and committed reviewable fixture
  • replace TestInferenceMetadataStatus negative coverage with positive hashless metadata and processor assertions

No model implementation, weight mapping, or existing L4/L5 evidence is changed. No model-family fields, hashes/fingerprints, IR version, or ONNX opsets are added to canonical metadata.

Validation split

Ordinary PR CI

  • tiny graph construction and producer tests
  • schema/admission validation
  • executable synthetic text-only path
  • executable two-step text-to-image CFG/flow loop
  • executable reference-image edit path
  • shared frozen KV and mixed fp16-understanding/fp32-generation boundaries

Pinned real H200 validation

The existing #533 evidence remains authoritative and is documented rather than downloaded in CI:

  • model revision 1f6ec60423d29939dde4202fd82ae340b144e280
  • 17.5B parameters / ~50 GB checkpoint
  • L4 stage parity for prefix KV, image embedding, step-0/step-7 x0, and final image
  • L5 coherent text, 512x512 text-to-image, and reference-image edit outputs

Local validation

  • PYTHONPATH=src python -m pytest src/mobius/models/sensenova_u1_test.py -q — 25 passed
  • generate + compare all ONNX GenAI workflow fixtures — pass
  • ONNX GenAI schema/admission of shared_state_pixel_flow — pass
  • ONNX GenAI executable conformance matrix — text, generation, edit all pass

Depends on justinchuby/onnx-genai#1700 for generic read_only state aliases and dynamic image-adapter dimensions.

justinchuby and others added 4 commits August 21, 2026 23:50
Adds full Mobius support for sensenova/SenseNova-U1.5-8B-MoT, a native
unified multimodal model (understanding + image generation + editing).

Architecture (root-caused from the upstream reference implementation at
github.com/OpenSenseNova/SenseNova-U1 @ feat/u1.5 — the HF repo declares
auto_map entries for configuration_neo_chat.py / modeling_neo_chat.py but
does not ship those files, so the GitHub package is the only source):

* Mixture of Transformers (MoT): all 42 Qwen3 decoder layers carry two
  complete, disjoint weight sets. The understanding branch handles text
  and reference images; every module suffixed `_mot_gen` handles the
  noisy image tokens of the flow-matching sampler. Attention is shared —
  the generation pass reads the KV cache written by the understanding
  pass, which is how text conditioning reaches image tokens. Upstream
  raises NotImplementedError for a mixed forward, so exporting the two
  branches as two graphs is the only faithful decomposition.
* Three rotary axes inside head_dim 128: temporal [0:64) at rope_theta,
  image height [64:96) and width [96:128) at rope_theta_hw. QK-norm is
  applied per half (q_norm over 64 temporal dims, q_norm_hw over 64
  spatial dims), matching the checkpoint's [64]-shaped norm tensors.
* Block-causal attention: allow[i][j] = (t[j] == t[i]) or (j <= i), so
  patches of one image attend bidirectionally.
* Vision tower has no transformer blocks — Conv2d patchify, GELU,
  interleaved 2-D RoPE, Conv2d 2x2 merge into the LLM width.
* No VAE: use_pixel_head drives a pixel-shuffle ConvDecoder that decodes
  generation hidden states straight to RGB.

Ships SenseNovaU1Config (lifts text fields from the nested llm_config),
a bare vision extractor hook, SenseNovaU1Model, SenseNovaU1Task building
five graphs (model / vision / embedding / image_gen_embedding /
image_gen_denoiser), and registry wiring for model_type `neo_chat`.

All 1116 checkpoint tensors map onto ONNX initializers with zero
unmapped keys and zero shape mismatches; the only initializers without a
checkpoint source are derived RoPE and timestep-frequency tables.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
Two defects surfaced only when running the real 17.5B checkpoint through
onnxruntime on CUDA; both are fixed here:

* `_TimestepEmbedder` built its sinusoidal basis in float32 but read the
  frequency table after `_cast_module_dtype` had demoted it to the model
  dtype, producing a `Mul` with mismatched operand types that made the
  `image_gen_embedding` graph unloadable in fp16. The table is now cast up
  explicitly, keeping the basis in float32 as upstream does.
* The denoiser graph dropped its `present_key`/`present_value` outputs.
  ORT's CUDA Attention kernel requires them whenever `past_key`/`past_value`
  are supplied, so every denoise step failed at layer 0. They are now
  registered; the sampler still discards them, which preserves upstream's
  `update_cache=False` semantics (the understanding prefix stays frozen
  across flow-matching steps).

`_ConvDecoder` also derives its upsample factor from `pixels_per_token`
instead of hardcoding 32x. That is exactly `patch_size * merge_size` for
the released checkpoint (so `conv2` keeps its 192 = 3*8*8 channels), but
it no longer silently produces wrongly-sized images for other geometries.

Adds docs/design/sensenova-u1-neo-unify.md recording what was verified
against the checkpoint and the reference implementation: the Hub
packaging gap (declared-but-absent remote code, shard-numbering slack),
the parameter budget, MoT routing, the three rotary axes, block-causal
masking, the transformer-free vision tower, the VAE-free pixel head, and
the upstream code paths that are dead for inference.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
Renames the package components from `model`/`vision` to `decoder`/
`vision_encoder`, matching VisionLanguageTask, VisionLanguage3ModelTask
and HunYuanVLMoTTask. Beyond consistency this makes the package
recognisable to `is_native_vlm_package`, so the metadata emitter now
reports a specific, actionable failure instead of the generic
"unrecognised multi-component package shape".

Records `neo_chat` in `_SPECIALIZED_TEST_MODEL_TYPES`: the co-located
test module covers it, and the generic VLM harness cannot -- the package
carries an image-generation branch the harness has no notion of.

Adds TestInferenceMetadataStatus, which pins the exact current blocker so
the documented status cannot drift from reality:

* Export and execution are complete for all five graphs.
* Metadata emission blocks in the image-processor contract: the NEO
  vision tower takes a plain (1, 3, H, W) image and the Hub repo ships no
  preprocessor_config.json, so no processor program binds and no
  image_mean/image_std are declared.
* No emitter shape describes a unified any-to-any package (a text decoder
  plus a flow-matching branch sharing one KV cache), and ORT GenAI has no
  runtime pipeline for one, so a contract alone would not be executable.

The design doc gains the runtime/metadata status section and the
precision finding that the `_mot_gen` branch -- stored F32 upstream --
overflows fp16 during sampling and must be exported at float32, while the
BF16 understanding branch exports cleanly to float16.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
* `preprocess_weights` now honours `tie_word_embeddings`. Only an
  explicit `language_model.lm_head.weight` populated `decoder.lm_head`
  before, so a tied `neo_chat` variant would leave that initializer
  unfilled. The released 8B checkpoint is untied, so this was latent, but
  the registry declares a family/variant pair that anticipates siblings.
  Mirrors the existing HunYuan VL-MoT handling. Covered by two new tests.

* Drops the `update_cache` parameter from `_MoTAttention`,
  `_MoTDecoderLayer` and `_SenseNovaU1DecoderBody`. It was declared,
  threaded through three modules, and never read: ONNX `Attention` always
  emits `present = concat(past, new)`. The understanding prefix stays
  frozen because the *caller* discards the denoiser's present outputs,
  which is documented at that contract boundary in the task. Keeping a
  flag that implied graph-level behaviour it did not have was a trap.

* Removes the unused expanded `mask` in the embedding model. `op.*` calls
  emit IR nodes, so `del mask` dropped only the Python name — the
  Unsqueeze/Expand survived until DCE. Also drops the vestigial
  `num_heads` argument from `_rotate_half_axis`.

* Documents why GQA fusion cannot fire for either decoder graph (the
  block-causal bias contains an `Or`, the denoiser has no attention_mask
  input, and the three-axis RoPE is not `op.RotaryEmbedding`), so the
  CUDA/fp16 export warning is not misdiagnosed later.

Verified graph-identical to the exported artifacts: all five components
match the on-disk node counts exactly, and the end-to-end image is
bit-identical to the pre-refactor run.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 21, 2026 23:54
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 8b5e7a3 → b6fb109

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 105 105 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 264 264 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 126 126 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 428 428 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 166 166 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

@justinchuby
justinchuby force-pushed the copilot/sensenova-canonical-metadata branch from 6e5987d to a3b8b11 Compare August 21, 2026 23:57
@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 8b5e7a3 → b6fb109

Model Sub-model Changes Status
bert (feature-extraction) model 0 ⚪
falcon model 0 ⚪
gemma2 model 0 ⚪
gemma4 (gemma4) decoder 0 ⚪
gemma4 (gemma4) embedding 0 ⚪
gemma4 (gemma4) vision_encoder 0 ⚪
gemma4_text model 0 ⚪
gpt2 model 0 ⚪
llama model 0 ⚪
llama (static-cache) model 0 ⚪
mamba (ssm-text-generation) model 0 ⚪
phi3 model 0 ⚪
phi3 (static-cache) model 0 ⚪
qwen model 0 ⚪
qwen (static-cache) model 0 ⚪
qwen2 model 0 ⚪
qwen2 (static-cache) model 0 ⚪
qwen2_moe model 0 ⚪
qwen2_moe (static-cache) model 0 ⚪
qwen3 model 0 ⚪
qwen3 (static-cache) model 0 ⚪
qwen3_5_moe (hybrid-text-generation) model 0 ⚪
qwen3_5_text (hybrid-text-generation) model 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) decoder 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) embedding 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0 ⚪
qwen3_moe model 0 ⚪
qwen3_moe (static-cache) model 0 ⚪
qwen3_next (hybrid-text-generation) model 0 ⚪
t5 (seq2seq) decoder 0 ⚪
t5 (seq2seq) encoder 0 ⚪
whisper (speech-to-text) decoder 0 ⚪
whisper (speech-to-text) encoder 0 ⚪

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@justinchuby
justinchuby force-pushed the copilot/sensenova-canonical-metadata branch from a3b8b11 to 0a94f9d Compare August 22, 2026 00:07
Copilot stopped reviewing on behalf of justinchuby due to an error August 22, 2026 00:15
Describe SenseNova U1.5 through a generic five-component workflow with exact image preprocessing, frozen shared KV, mixed-precision casts, CFG, x0 flow conversion, and loop execution. Add deterministic producer fixtures and positive metadata status coverage without changing the model implementation or real-weight evidence.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: justinchuby <[email protected]>
@justinchuby
justinchuby force-pushed the copilot/sensenova-canonical-metadata branch from 0a94f9d to b6fb109 Compare August 22, 2026 00:25
@justinchuby
justinchuby merged commit 0776f56 into main Aug 22, 2026
21 of 24 checks passed
@justinchuby
justinchuby deleted the copilot/sensenova-canonical-metadata branch August 22, 2026 01:50
justinchuby added a commit that referenced this pull request Aug 22, 2026
## Summary

Follow-up to merged #540 that incorporates findings from real
canonical-engine execution of the pinned SenseNova U1.5 package.

- derive deterministic image noise from generic `seed`/`width`/`height`
request roles; caller latent remains an optional override
- keep positive and negative CFG prefixes and their frozen KV sequence
symbols independent
- integrate the x0 flow from `t=0` to `t=1` using
`v=(x0-z)/max(1-t,t_eps)`
- clamp generic pixel output to the declared `[-1, 1]` range
- add reusable image-noise geometry and tensor-clamp policy components
- regenerate the hashless canonical fixture and document production H200
evidence

No SenseNova/NEO dispatch or family-specific metadata fields are added.

## Validation

- `python3 -m pytest src/mobius/models/sensenova_u1_test.py
src/mobius/generation/_policy_components_test.py -q --tb=short` — **78
passed**
- generated fixture exactly matches
`tests/fixtures/onnx_genai_workflows/shared_state_pixel_flow/inference_metadata.yaml`
- targeted Ruff format/check and `git diff --check` pass

## Real canonical runtime evidence

Executed by ONNX GenAI `Engine::from_pipeline_dir` on H200 using the
pinned 17.5B export (`1f6ec60423d29939dde4202fd82ae340b144e280`), not
custom orchestration:

- text understanding prefill: logits `[1, 28, 151936]`
- 512×512 text-to-image, 20 steps: **6.99 s**
- 512×512 reference-image edit, 20 steps: **16.68 s**
- peak observed VRAM: **91,256 MiB**
- final outputs finite and bounded exactly to `[-1, 1]`

Published package:
https://huggingface.co/justinchuby/sensenova-u1.5-8b-mot-onnx-canonical
Upload commit: `f3f2eaf79f4991febee107cdabd0b27f0161b06e`

A clean 24 MB selective download of metadata, policies, graph
descriptors, tokenizer, and processor assets passes canonical admission.

## Remaining runtime limitations

- text path currently validates understanding prefill, not full
autoregressive decode
- generic Images/A1111 bindings cannot yet select a path-specific image
chat template or construct reference-image placeholder masks for this
unified package
- portable counter RNG is deterministic but intentionally does not
reproduce PyTorch RNG, so final pixels are not directly comparable to
#533's controlled-latent reference

Runtime support and synthetic executable coverage are in
justinchuby/onnx-genai#1700.

---------

Signed-off-by: justinchuby <[email protected]>
Signed-off-by: justinchuby <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot <[email protected]>
justinchuby added a commit to justinchuby/onnx-genai that referenced this pull request Aug 22, 2026
## Summary

- add model-agnostic `read_only` state-port access so alternating
components consume frozen state without advancing or writable-aliasing
it
- preserve dynamic typed preprocessing dimensions
- add a canonical shared-prefix pixel-flow catalogue workflow with exact
RGB/pixel-area resize/rescale/normalize semantics
- use generic counter RNG plus image geometry to provide deterministic
seed-to-noise when no caller latent is supplied
- execute text prefill, text-to-image, and reference-image-edit paths
through the canonical metadata engine
- validate unequal CFG prefix lengths, independent frozen KV groups,
fp16→fp32 boundaries, x0 flow integration, and bounded output

## Design

There is no SenseNova/NEO dispatch. The reusable pattern is: one
understanding branch writes a shared state group; conditional and
unconditional generation branches expose independent read-only aliases;
ordinary workflow IR performs per-step embedding, denoiser calls, CFG
combine, `v=(x0-z)/max(1-t,t_eps)`, Euler update, and image emit.

Read-only aliases are excluded from stable-buffer aliasing,
execution-island writable bindings, and decoder transition pairing.

## Validation

- `cargo test -p onnx-genai-metadata --test catalogue --test
recurrent_state` — **5 passed**
- `cargo test -p onnx-genai-engine --no-default-features --test
onnx_genai_workflow_conformance -- mobius_shared_state_pixel_flow
--nocapture` — **2 passed**
  - text understanding and text-to-image generation
  - deterministic replay without caller latent
  - reference-image edit
  - unequal positive/negative prefix lengths
  - output range
- `cargo fmt --all -- --check`
- `git diff --check`

The Mobius producer checkout now uses `main` because producer PR
onnxruntime/mobius#540 has merged. Follow-up producer corrections are in
onnxruntime/mobius#545.

## Real H200 canonical-engine evidence

The pinned 17.5B package (`1f6ec60423d29939dde4202fd82ae340b144e280`)
was executed through `Engine::from_pipeline_dir`, not a custom component
runner:

- text understanding prefill: logits `[1, 28, 151936]`
- 512×512 text-to-image, 20 steps: **6.99 s**
- 512×512 reference-image edit, 20 steps: **16.68 s**
- peak observed H200 VRAM: **91,256 MiB**
- fp16 understanding and fp32 generation boundary: pass
- conditional/unconditional frozen KV sharing, CFG, forward flow loop,
and output clamp: pass

Package:
https://huggingface.co/justinchuby/sensenova-u1.5-8b-mot-onnx-canonical
Upload commit: `f3f2eaf79f4991febee107cdabd0b27f0161b06e`

A clean selective download of 24 MB (metadata, policies, graph
descriptors, tokenizer, and processor assets) passes canonical
admission. Full package size is approximately 49 GB.

## Comparison and limitations

Existing #533 controlled-latent evidence remains Pearson **0.998606**,
PSNR **36.42 dB**, T2I **7.75 steps/s**, edit **7.06 steps/s**. The
portable counter RNG is deterministic but does not reproduce PyTorch
RNG, so seeded final pixels cannot honestly be compared numerically with
that controlled latent.

Remaining limitations:

- text validates prefill logits, not a full autoregressive decode loop
- generic OpenAI Images/A1111 bindings cannot yet choose a path-specific
image chat template or automatically build reference placeholder masks
for this unified package
- fp16 generation overflows; the validated package intentionally uses
fp32 generation

---------

Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
@justinchuby justinchuby mentioned this pull request Aug 23, 2026
5 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants