Repository navigation
feat(models): add LiquidAI d1-omni (d1_omni) decision model - #3533
Conversation
Port mlx-vlm's d1_omni to the decision API: a bidirectional LFM2.5-Encoder trunk over a media prefix, the shared marker head, the reserved-delimiter prompt, LFM2-VL tiling with torchvision's uint8 resize over the SigLIP2 tower and projector, and the Nemotron-H Nano Omni front end and FastConformer with d1-omni's adapter and residual. The trunk reuses Lfm2Model through a new media-prefix forward (prefix-block attention mask, right conv tap gated at the last media position) in a child module, so no existing LFM2 path changes. The loader detects model_type d1_omni and mlxcel generate refuses it with the decision entry points. Adds the mlx-vlm fixture generator, its f32 CUDA fixture, the README speech clip and the published config. Refs #2368
The speech parity request answered 0.019 where mlx-vlm answers 0.9999. Two divergences of the shared Nemotron-H Nano Omni audio code from current upstream caused it: the extractor uses a periodic Hann window where mlx-audio's hanning(400, periodic=False) is symmetric (log-mel off by up to 0.15), and the subsampling convolutions never add their biases, which upstream's nn.Conv2d layers and both checkpoints carry. Both are opt-in so the Nemotron-H Nano Omni path keeps its current numbers: NemotronOmniFeatureExtractor::with_mlx_audio_stft (symmetric window, 1 + len / hop frames) and NemotronOmniAudioConfig::subsampling_conv_bias (default false). The subsampling linear now reads the encoder's quantization instead of a hardcoded 64/4, which is the same for the released 4-bit Nemotron export and correct for the d1-omni 8-bit one. With both, the speech prefix is within 3e-6 of upstream and the speech requests within 1e-9. Also ties the f32 parity tests to the loader arm and adds the d1-omni rows to the decision docs. Refs #2368
The speech answers are saturated near 0.9999, so reverting the symmetric Hann window still passed the speech parity test. The fixture now carries upstream's log-mel features at four frames of the speech clip and a unit test holds the front end to them (measured 1.2e-5; the periodic window is off by 0.15). Adds the d1-omni section to docs/decisions.md with the measured parity numbers, the shared-code opt-ins and the 8-bit over 4-bit recommendation, and updates the Used-by notes of the shared head modules. Refs #2368
A d1-omni request with images or audio and several questions ran the trunk over the whole media prefix once per question. An image prefix is up to about 2800 positions against an image text budget of 896, so a few questions about one large image multiplied the trunk work several times over. Upstream's `_run` encodes a shared prefix once (`Trunk.prefix_state`) and runs only the text of each batch against it (`Trunk.after`). The port now does the same: `Lfm2Model::media_prefix_state` runs the lone prefix and keeps each attention layer's rotated keys and values and each conv layer's tap input at the last media position; `forward_embeds_after_media_prefix` continues tiled copies of that state for a batch of text rows. A lone question still runs with its prefix, as upstream. Shared batches apply the twice-the-length rule to text lengths, as upstream's `shared` batches do. No existing LFM2 forward changed. Also: the d1-omni and Laya checkpoint parity tests take a shared lock, since two of them on concurrent threads abort the CUDA test binary (`cudaStreamEndCapture`, every run of `decision::d1_omni` on GB10); and `tests/fixtures/audio/README.md` records the LibriSpeech CC BY 4.0 attribution and hash of `speech.flac`. Cats image parity gap to mlx-vlm drops from 5.5e-6 to 1.5e-6 (upstream also shares that prefix). A new trunk test checks the shared path against the full forward (9.3e-10); with the conv's prefix tap dropped it moves by 3e-6 and fails, and the cats image and speech parity tests fail too. Refs #2368
Implementation Review SummaryIntent
Findings Addressed
Confirmed without change
Remaining Items
Verification
|
Request-controlled media could reach the d1-omni towers in shapes upstream never bounds. The LFM2-VL smart resize clamps a thumbnail's short side to 32 pixels past about 256:1, so a 1 x 400000 strip (a few hundred bytes as a PNG) still fit the 16384 positions while making one SigLIP2 crop of about 40000 patches, enough to exhaust the decision worker. Each image is now refused as a 400 when its thumbnail would exceed the trained 256 tokens per crop; every image within that range is unchanged. A NaN or infinite audio sample produced NaN answers that the shared result check could only return as a 500; a clip whose log-mel features are not finite is now InvalidInput. The request is planned (media positions, every row, the MAX_REQUEST_TOKENS cap) before the vision or audio tower runs, so an over-budget request costs no GPU work, and the tower output must match the planned prefix length. The 8-bit head triples now load through UnifiedLinear, which checks the stored shapes against the declared packing, so a malformed checkpoint fails at load naming the tensor instead of aborting inside MLX's dequantize. Tests: decision::d1_omni with the f32 and 8-bit checkpoints on CUDA (--test-threads=1), clippy, fmt and contract checks. Refs #2368
|
Security and performance review of the d1-omni scorer's request inputs ( Fixed:
Checked, no change needed: delimiter escaping (no input can produce a literal Remaining, outside this PR: a misshaped trunk, vision or audio tensor still aborts at the first forward, since Tests: |
…fault The d1-omni speech path opts into mlx-audio's symmetric Hann window through `with_mlx_audio_stft`, while Nemotron-H Nano Omni keeps the periodic one. Only the frame count had a unit test; the window itself was covered only by the checkpoint-gated log-mel parity test. The new test checks that the opt-in zeroes the last tap and uses denominator `win_length - 1`, and that the default window is unchanged. It runs on the CPU with no checkpoint. Validation: - cargo test --profile test-fast --features cuda --lib mlx_audio_stft: 1 passed - cargo clippy --lib --tests --features cuda -- -D warnings: clean - cargo fmt --all -- --check: clean Refs #2368
## Summary Rebuilds the WebUI shell and the shared primitives on the grammar of `docs/webui/design-system.md` (#3526). Screens keep their current layout inside the new shell until #3521 to #3524 move them. - **Shell.** A 200 px sidebar that collapses to a 64 px rail through ui-common `SideNav` `collapsible`, stored as `sidebarCollapsed` in the appearance preferences. A 52 px header that receives each route's title and actions from its `PageHeader`; actions that do not fit fold into one overflow menu. A 28 px status bar replaces the toolbar chips and `TOOLBAR_CHIP_LIMIT`. Below 1024 px the sidebar is the mobile navigation and the bar shows its one most important item, 44 px tall so it meets the hit-target floor. Chrome is glass in the `glass` family only. - **Status bar.** Running models, tokens per second and reachability, from the snapshot Activity already reads; no new endpoint. The server publishes no instantaneous rate (`decode_rate` is always unavailable), so the rate is the growth of its cumulative decode counters between two runtime samples. Without the metrics endpoint (`--metrics`) or the slots endpoint (on unless `--no-slots`) the bar shows reachability and running models only and says why on hover and focus. Each non-ready state (`partial`, `empty`, `loading`, `stale`, `offline`, `error`, `unauthorized`) has a recovery action and a `data-testid`. A model that starts is one status-bar item ("Preparing") plus one notification entry. - **Primitives.** Button and Field at the control height, neutral secondary pill, no hover lift, a feedback state (`useButtonFeedback`), one shared confirm hook (`useConfirm`), the fixed destructive and stop verbs (`ActionButton`). A sized `Dialog` with a pill-tab strip and body and footer slots. `NoticeBanner`, the inline error banner and a bottom-right toast stack (360 px, three at most). `CountBadge`, `StatSummary`, `StatCardRow`, `Timestamp`, `DataTable` row padding from the contract. One 64 px icon in the empty state, the 1.25 px icon stroke. Text fields change their border color on focus; every other control keeps the ring. - `Drawer` and `Inspector` stay exported from `primitives.tsx`. The gallery shows every primitive in its states. Strings are in English and Korean with the fixture. `data-testid` values keep their names; every spec that queried a renamed class is updated. ## Dialog decision `Dialog` stays on the native `<dialog>` and does not wrap ui-common `Modal`. Both were built behind the same props and run through the served-CSP check against a real `mlxcel-server --webui --api-key ...` on loopback (`default-src 'self'; script-src 'self'; style-src 'self'; ...`). | Check | Native `<dialog>` | ui-common `Modal` | |---|---|---| | `securitypolicyviolation` events, inserted `<style>` | none, 0 | none, 0 | | Element | `dialog`, `:modal`, top layer, no `style` attribute | `div[role="dialog"]`, not in the top layer | | `expectSafeLayout` | passes | fails: six elements carry library styles outside the allowlist, among them the scroll lock on `<html>` and `<body>` | | Opened beside the open, still-exported `Drawer` (390 px run; at 1440 px the `Modal` case left the Drawer unable to close, which ended that run) | paints above it, takes focus, traps Tab, one Escape closes only it | does not paint above it, focus stays in the Drawer, Tab never enters it | The policy permits both, since every style either one writes goes through CSSOM. `Modal` sits below the top layer, and two confirmations render beside the Drawer they open from (the Models library's beside the inspector Drawer, Chat's delete beside the conversation-list Drawer), so those would be hidden and unreachable until #3525 removes `Drawer`. The decision and this table are in `docs/webui/ui-common.md#dialog-decision`. ## JavaScript growth | | Baseline | This PR | Growth | Limit | |---|---|---|---|---| | Initial JS (gzip) | 306,208 | 315,471 | +9,263 bytes (9.0 KiB) | 393,216 | | All JS (gzip) | 456,569 | 470,813 | +14,244 bytes (13.9 KiB) | 716,800 | The initial growth is the header, the status bar, the sized Dialog and the Tooltip that carries the status bar's reason. The toast stack is its own chunk, fetched when the first notice is posted. ## Real-binary validation Release `mlxcel-server --webui --api-key ... -m <Qwen3 0.6B 4-bit checkpoint> --metrics --slots` on loopback, serving this branch's bundle (the served `index-*.js` and `index-*.css` names match `src/webui/assets/`), driven by headless Chromium. | Viewport | Cases (family x scheme x locale) | Header | Sidebar | Status bar | Page overflow | |---|---|---|---|---|---| | 390 x 844 | 8: `mlxcel` and `glass`, light and dark, English and Korean | 52 px | mobile navigation | 44 px, on the bottom edge | 0 px | | 1024 x 768 | 8, the same | 52 px | 200 px | 28 px, on the bottom edge | 0 px | | 1440 x 900 | 8, the same | 52 px | 200 px | 28 px, on the bottom edge | 0 px | Sizes are `getBoundingClientRect` of AppShell's banner, AppShell's side navigation and the status bar. All 24 cases measured the same per viewport. | Step | Status bar, as read from the page | |---|---| | Signed in | `1 running`, `qwen3-0.6b-4bit Ready`, `Server reachable`; state `partial` (no running model selected yet; the information control says so) | | Running model opened from the bar | adds `tokens/s not yet measured`; state `ready` | | After one generation in Chat | `216 tokens/s`; state `ready` | | Same session at 390 px | `1 running`, `qwen3-0.6b-4bit Ready` only | | Korean, after a generation | `1개 실행 중`, `qwen3-0.6b-4bit 준비됨`, `216 tokens/s`, `서버 응답 중` | | Server restarted without `--metrics` | no rate; state `partial`; the control's tooltip reads "Metrics are off. Restart the server with --metrics." | | Server restarted with `--metrics --no-slots` | no rate; state `partial`; the tooltip reads "Slots are off. Restart the server with --slots." | Computed styles on the same binary: icon `stroke-width` 1.25 px with `vector-effect: non-scaling-stroke`; h1 17.5 px at weight 600; buttons and text fields 31.5 px tall (2.25 rem on the 14 px root); field radius 5.25 px; a focused text field changes its border from `rgb(220, 220, 228)` to `rgb(139, 92, 246)` with no ring; a focused button draws the 2 px ring in that color. Screenshots of all 24 cases and of the live steps were captured locally. They are not embedded here because no image upload path is available from the CLI. ## Deviations and open items - The theme cross-fade and the rise-in stay marked as targets in the contract, although the shell could own them. Every layout case runs axe on the first frame and the theme specs read colors in the frame after a switch, so they need assertion helpers that wait for motion first. - Tokens per second appears once a running model is selected, because the provider observes only the selected model and the bar never selects one. A fresh session rests in `partial` until then, the reason still reads "no running model is selected" until that model's first sample, and the unit reads "tokens/s" in Korean too. #3523 owns the status bar content. - The header fold is all-or-nothing and holds buttons only: at 390 px the screens that have not moved yet keep New conversation and Add model behind More actions. Model pickers (Activity, Chat, Settings) are never folded; each is the first row of its route's content at every width. - Lifecycle copy (`models.status.*`) is unchanged; only the status bar's starting item reads "Preparing". - `expectSafeLayout` gained three entries for styles the newly adopted library components write through CSSOM (a Banner's action row, a toast's progress fill, the CountBadge offset). "No new inline style outside the allowlist" is measured against the list with those entries. ## Changes during review - Below 1024 px, route actions in the header and its overflow menu (and Activity's model picker trigger) were under the 44 px hit-target floor; a compact rule fixes them and `expectCompactToolbarHitTargets` now measures them. Toast dismiss buttons get the same 44 px compact target, with a spec for the stack's width, position, count and targets. - Tests for the tokens-per-second derivation: counters that fall after a reload, tokens with no elapsed time, no growth, and a server restart clearing the history. - The Banner entry in the `expectSafeLayout` allowlist is narrowed to the Banner's action row. - The "Preparing" notice is posted only when its content changes, so a loading model no longer re-renders the toast stack on every catalog update. The header overflow trigger drops `aria-haspopup` (its panel is a group, not a menu). The gallery's Dialog demo uses the footer slot. The status bar's `empty` state documents why it offers no action on the Models route. - The served-CSP spec was re-run against a fresh release build of the reviewed head: 2 passed, and the served assets matched `src/webui/assets/` by SHA-256. - The shell runs AppShell in fill mode: the main landmark is the only scroll container, between the header and the fixed status bar, so content never passes under the chrome (this fixed axe `target-size` failures on Linux at 390 px where a content control sat under a header control). The overflow assertions now measure the document, the shell box and main, and the shell-floor helper measures after two animation frames, because the header fold settles one frame after a route mounts. - Activity's model picker moved out of the header into the first row of its content, so it stays directly reachable at compact widths (the installed-artifact Activity performance script drives it at 700 px). Settings help buttons are 44 px below 1024 px. - Settings keeps its target selector mounted while signed in when the connection briefly leaves the live phase; only the sections that read the live server are replaced by the unavailable banner. A unit test covers it. ## Values chosen where the contract gave none Dialog widths 28, 40 and 60 rem; field radius `md` (0.375 rem); the header title as heading 3; the compact status bar at 44 px; six iterations of the lifecycle pulse; 1.6 s of button feedback; 6 s for the "is running" notice. All are written into `docs/webui/design-system.md` and need the owner's confirmation. ## Test plan - [x] `webui/`: `typecheck`, `lint`, `check:theme-selectors`, `check:themes`, `check:agents`, `unit` (811 tests), `browser` (136), `browser:all` (21) - [x] `python3 scripts/webui/build_bundle.py --verify`, `make verify-webui-contract`, `make verify-webui-rust`, `make verify-webui-integration-fake` (the router harness) - [x] Served-CSP spec (`playwright.csp.config.ts`) against the release binary above: 2 passed - [x] Re-run on the final head: served-CSP spec 2 passed against a fresh release build (served `index.html` matches `src/webui/assets/`), `make verify-webui-rust`, `make verify-webui-integration-fake` - [x] CI green except `binary assets`, which fails on `main` too since #3533 (an undeclared audio fixture), independent of this PR Closes #3520
Advance the reproducible MLX pin from fc344c98 to 5a48f9cc, the head of upstream main on 2026-11-28 (87 commits, past v0.32.5). Review record: docs/mlxcelverse/mlx-pin-2026-11-28.md. - The CPU quantized-matmul overlay (#2248) is retired: upstream now accumulates the fp qmm loops in float (ml-explore/mlx#4879), and cpu_qmm_accum_tests guard the upstream loops. - 24 Metal and CUDA overlays are rebased onto the pin. SDPA threads upstream's window_size through the deterministic and bucketed plan paths. The CUDA grouped_gemm.h overlay includes <cstdint>, and device/unary_ops.cuh (added on main by #3540 at the old pin) carries upstream's new SignBit functor. - The #637 sm_120/121 qmm tile cap is dropped for upstream's #4851 rule (large_tiles ? 128 : 64). A GB10 A/B on llama-3.1-8b-4bit and qwen2.5-7b-4bit showed no prefill gain from the cap at 2048 or 8192 tokens and byte-identical greedy output; the 512-token qwen gain (about 10%) is recorded in the pin doc. TILE_M_CAP_BLACKWELL is 64. - ROCm overlay retargeted: the fork's fusion limits move to mlx/compile/fuse.cpp, the new allocator hooks are inert, GroupedMM and SignBit get NO_GPU stubs, and HIP sources compile as C++20 because the pin's scheduler.h uses std::atomic::notify_all (LOCAL_FIXES 77 to 80, after main's 76). - The MiniCPM5 and Qwen3 DSpark exactness gates require MLXCEL_SDPA_DETERMINISTIC=1 on CUDA, where decode attention otherwise takes cuDNN stream-K and its engine choice depends on what ran earlier in the process. - A clippy needless_range_loop in the router WebUI harness test from #3552 is fixed; main's clippy job had not run on that change. Validation: on M3 Ultra, make verify-test (17374 passed). On GB10 (spark-102), make verify-test-cuda-qmm-determinism (5 passed) and make verify-test-cuda (17741 passed, 3 failed, none from this change: a DeepSeek-OCR CLIP parity failure identical on main, and two port or timing flakes that pass alone), check_nvrtc_headers.py with NVRTC against the new-pin build tree, make verify-rocm-overlay, and both real-checkpoint DSpark gates. CI passes except binary assets, which fails on main for the undeclared tests/fixtures/audio/speech.flac from #3533. No ROCm host was available: the HIP C++20 change is covered by the Windows compile-only job only.
#3533 committed tests/fixtures/audio/speech.flac (183,318 bytes, the LibriSpeech CC BY 4.0 clip from the d1-omni README) without a DECLARED rule in scripts/ci/check_binary_assets.py, so the binary assets job failed on main and on every pull request. The clip now has its own rule with a 192 KiB ceiling, and TOTAL_BUDGET_BYTES grows by exactly its size (42,781,163 to 42,964,481), since declaring it alone exceeds the total ceiling. check_binary_assets.py (113 declared files) and check_binary_assets_test.sh pass.
Summary
Adds LiquidAI d1-omni-600M (
model_type: d1_omni) as a decision model over text, images or audio, served bymlxcel decideandPOST /v1/decisions(--decision-model). Port of mlx-vlm 0.8.1mlx_vlm/models/d1_omni/.decision_typesis[Choice, Score, Bool],decision_mediais[Image, Audio];mlxcel generaterefuses the checkpoint with the decision entry points.Lfm2Model, through a newforward_embeds_media_prefixedin a child module (src/models/lfm2_media_prefix.rs): caller mask with the prefix block, explicit 3-tap conv with the right tap gated atprefix - 1. A media request with several questions runs the prefix once and each batch only its text, as upstream'sprefix_state/after(media_prefix_state,forward_embeds_after_media_prefix). No existing LFM2 function changed (lfm2.rsgains amodand auseline), so the logit trace was not run.marker_head/head_layersreused unchanged (DecisionHead,MarkerScorer,MarkerBatch,add_type_embedding,sanitize_marker_head,option_bucket), over the text slice of the trunk output. Not inherited from Laya: unclamped temperatures, argmaxconfidence, no calibration for media rows. The 8-bit export quantizeshead.head.*, which is dequantized at load.Lfm2VlVisionTowerandLfm2VlConnector; preprocessing ported (torchvision uint8 filter taps, CPython tile-ratio order), asLfm2VlProcessorresizes differently.Adapter/Residual. Two shared-code divergences from current upstream broke speech parity (0.019 vs 0.9999): a periodic Hann window (mlx-audio's is symmetric) and subsampling conv biases never added. Both are opt-ins, off for Nemotron (with_mlx_audio_stft,subsampling_conv_bias). The subsampling linear now reads the encoder's quantization instead of a hardcoded 64/4 (same for Nemotron's 4-bit export).MAX_REQUEST_TOKENSare checked before any tower runs; the 8-bit head triples are shape-checked at load throughUnifiedLinear.Upstream differs from the issue body in two places, followed here: the batch budget is 16384 positions with no row padded past twice its length (not 65536), and PIL images are not EXIF-turned.
Verification (CUDA, GB10; Metal not run)
mlx-vlm 0.8.1 on CUDA with
MLX_ENABLE_TF32=0, mlxcel test binaries likewise. Fixture:tests/fixtures/decision/d1_omni_parity.jsonfromgenerate_d1_omni_fixture.py.LiquidAI/d1-omni-600M, max abs gap of unrounded probabilities: README text 9.2e-7, mixed text 2.1e-6, cats image 1.5e-6, speech 7.0e-10 (1.7e-10 null state); usage and labels exact, bound 1e-4. Speech log-mel 1.2e-5.refundtrue 0.9985, catstwowithsofatrue, speechfood0.9999), the same image and audio bodies return 200 onPOST /v1/decisions, and images plus audio give 400 witha request carries images or audio, not bothon both. WithMLX_ENABLE_TF32=0the CLI reproduces the fixture's cats answers exactly (two0.5323); with CUDA's default TF32 GEMMs it gives 0.5284, a 4e-3 shift that is the runtime's GEMM precision, not this port.decision::,models::lfm2(incl. LFM2.5 embedding checkpoint), Nemotron audio, detection andmodernbert: 332 pass on the final branch with--test-threads=1; clippy, fmt and contract checks clean. The d1-omni and Laya checkpoint tests share a lock, since two on parallel threads abort the CUDA binary (cudaStreamEndCapture); wider parallel selections can still hit it from other GPU tests.tests/fixtures/audio/README.mdrecordsspeech.flac's LibriSpeech CC BY 4.0 attribution.Not verified:
-MLX-fp16, Metal. Follow-up worth its own issue: mlxcel's default Nemotron-H Nano Omni audio path keeps the periodic window and drops the subsampling biases, which current mlx-vlm and the Nemotron checkpoint both have; this PR leaves that default unchanged.Closes #2368