Skip to content

fix(server): gate webui-only helpers so --no-default-features builds clean - #1889

Merged
inureyes merged 1 commit into
mainfrom
fix/xla-no-default-features-unused-imports
Sep 14, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/xla-no-default-features-unused-imports

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

Restores the OpenXLA feature compile CI job, which has failed on main since 2026-09-12 16:12 and therefore fails on every open PR. No behavior changes on any feature set.

Cause

The job's second step is cargo check --no-default-features --features xla-diagnostics --all-targets under RUSTFLAGS="-D warnings". Because default = ["surgery", "webui"], that step builds with the WebUI off.

The last success on main was 9ead2b7d (2026-09-12 04:43) and the first failure 70386ac6 (2026-09-12 16:12). The only commits between them are the WebUI series: #1857, #1860, #1865, #1868, #1864. They registered their routes behind #[cfg(feature = "webui")] but left the handlers, validators, constants, request types and imports those routes use outside the gate. With webui off all of it is dead code, and -D warnings makes each an error.

I checked before writing this that it was not already fixed elsewhere: current origin/main still carries the imports and its latest CI run still fails the job, lablup/mlxcel-internal was last pushed on 2026-09-10 and predates the breakage, and no merged or open PR fixes it.

Change

Every orphaned item is gated on webui, matching the gate its only callers already carry.

  • src/server/router_server.rs: 35 handlers, validators, constants and types, plus the router_lifecycle, HeaderMap, Uri, AxumPath and RouterModelAction imports only they use.
  • src/server/app.rs: six axum imports.
  • src/models/mod.rs: six detection re-exports used only by server::webui. is_sequence_classification_architecture stays ungated because src/rerank/mod.rs uses it.
  • src/server/auth.rs: with_extra_key, called only from the WebUI security setup in startup.rs.
  • src/server/router_server_tests.rs: restore_env_var, used only by a webui-gated test.

Gating the first layer exposed a second layer of imports that only the gated items used, so this was iterated until the compiler reported nothing. The only deleted lines are import lists being split; no logic is touched.

Verification

Reproduced first on main: cargo check --no-default-features --features cuda --lib --tests reports 42 warnings in the mlxcel crate.

After the change, every cargo check below reports zero warnings and zero errors in workspace crates:

features targets
--no-default-features --features cuda --lib --tests
--features cuda (defaults on) --lib --tests
--no-default-features --features cuda,webui --lib --tests
--no-default-features --features cuda,surgery --lib --tests
--no-default-features --features cuda --all-targets
--features cuda (defaults on) --all-targets

The --all-targets rows cover bins, benches and examples, where a gated item used by another target would have been a hard compile error rather than a warning. cargo fmt --all -- --check is clean.

Not built locally: the xla-iree feature itself. The OpenXLA feature compile job on this PR is the check for it, and it is the job this PR exists to turn green.

Follow-up for open PRs

PR #1872 edits src/server/router_server.rs and carries the same imports, so it will need a rebase once this lands. A rebase request will be posted there.

…clean

The `OpenXLA feature compile` CI job has failed on main since 2026-09-12 16:12 (first failure `70386ac6`, last success `9ead2b7d`). Its second step runs `cargo check --no-default-features --features xla-diagnostics --all-targets` under `RUSTFLAGS="-D warnings"`, and `default = ["surgery", "webui"]`, so that step builds with the WebUI turned off.

The WebUI series between those commits (#1857, #1860, #1865, #1868, #1864) registered its routes behind `#[cfg(feature = "webui")]` but left the handlers, validators, constants, request types and imports those routes use outside the gate. With `webui` off they are all dead, and `-D warnings` turns each into an error. Reproduced locally with `cargo check --no-default-features --features cuda --lib --tests`: 42 warnings in the `mlxcel` crate.

This gates every one of them on `webui`, matching the gate their only callers already carry. No code path changes on any feature set. The items are in `src/server/router_server.rs` (35 handlers, validators, constants and types, plus the `router_lifecycle`, `HeaderMap`, `Uri`, `AxumPath` and `RouterModelAction` imports that only they used), `src/server/app.rs` (six axum imports), `src/models/mod.rs` (six detection re-exports used only by `server::webui`), `src/server/auth.rs` (`with_extra_key`, called only from the WebUI security setup in `startup.rs`), and `src/server/router_server_tests.rs` (`restore_env_var`, used only by a webui-gated test). `is_sequence_classification_architecture` stays ungated because `src/rerank/mod.rs` uses it.

Gating the first layer exposed a second layer of imports that only the gated items used, so the fix was iterated until the compiler reported nothing.

Verified with `cargo check`, all reporting zero warnings in workspace crates: `--no-default-features --features cuda --lib --tests`, `--features cuda --lib --tests`, `--no-default-features --features cuda,webui --lib --tests`, `--no-default-features --features cuda,surgery --lib --tests`, and `--all-targets` for both the no-default and default cuda sets, so bins, benches and examples are covered. `cargo fmt --all -- --check` is clean. The `xla-iree` feature itself was not built locally; the CI job on this PR is the check for that.
@inureyes inureyes added type:bug Bug fixes, error corrections, or issue resolutions priority:high High priority area:core mlxcel-core: MLX FFI, primitives, KV cache, layers status:review Under review status:done Completed and removed status:review Under review labels Sep 14, 2026
@inureyes
inureyes merged commit b395a9e into main Sep 14, 2026
16 checks passed
@inureyes
inureyes deleted the fix/xla-no-default-features-unused-imports branch September 14, 2026 11:58
inureyes added a commit that referenced this pull request Oct 19, 2026
## Summary

Ports four upstream numeric fixes in families mlxcel ships, as one PR per the issue.

- **Gemma 3n** (ml-explore/mlx-lm#1886): the RoPE offset is read once per forward from the first owner cache and threaded through `DecoderLayer` into `Gemma3nAttention::forward`, so KV-shared layers no longer rotate queries at their owner's already-advanced offset.
- **PhiMoE** (ml-explore/mlx-lm#1939, #1889, Neywa-Labs/mlx-vlm#2419): `sparsemixer` routing replaces softmax over the top-k logits; the `longrope` block goes through `phi3::SuRope` (new `pub(crate) SuRope::from_scaling`, rotary-prefix scale moved onto `SuRopeTable`), with `rope_table_regime` for the prompt cache. Null `rope_scaling` keeps plain RoPE; `num_experts_per_tok > num_local_experts` fails at load. The fused decode kernel (`run_fused_moe_two_kernel`) casts scores to f32 and multiplies; it does not renormalize (the normalizing code near `mlx_cxx_kernels.cpp:1491` is the DeepSeek `fused_moe_forward`, a different entry point). A test pins fused == graph with scores summing to 1.5025.
- **Gemma 4 audio** (Neywa-Labs/mlx-vlm#2385): `causal_valid_mask` builds the mask from `dist = q + max_past - c`; the old construction admitted `dist == max_past`.
- **Phi-3-small** (ml-explore/mlx-lm#1938): `output_suppressed_token_ids` returns the 91 padding ids below `vocab_size`; forward logits stay raw.
- `logit_trace` gains an audio arm (`MLXCEL_TRACE_AUDIO`, `MLXCEL_TRACE_AUDIO_PROMPT`); docs and CHANGELOG updated.

## Tests

New tests in `gemma3n_tests.rs` (new), `phimoe_tests.rs`, `encoder_tests.rs`, `phi3small_tests.rs`. The Gemma 3n chunking test and the mask predicate test fail on `main`; the old-mask helper is asserted to differ at `(12,13,0)`. Deviation from the issue: mlxcel's Gemma 3n MLP and AltUp input round to bf16, so the single 12-row pass differs from narrower passes by one bf16 ulp (2.7e-3 fixed, 2.7e-2 to 6.7e-2 reverted). Multi-pass splits are gated at 1e-3 (1e-6 fixed, at least 5.6e-3 reverted) and the single pass at 1e-2. Measured on CUDA only, with `MLX_ENABLE_TF32=0`.

## Real-checkpoint traces (GB10, fixed vs reverted, `--decided 2`)

| Checkpoint | Width | Context | Decided disagreement | PPL fixed / reverted |
|---|---|---|---|---|
| gemma3n-e2b-4bit | 1 | 512 | 0/151 | 26.44 / 26.20 |
| gemma3n-e2b-4bit | 5 | 512 | 3/177 (1.7%) | 28.48 / 27.36 |
| gemma3n-e2b-4bit | 32 | 512 | 14/334 (4.2%) | 31.75 / 33.09 |
| phi-3.5-moe-4bit | 5 | 512 | 2/141 (1.4%) | 7.91 / 9.62 |
| phi-3.5-moe-4bit | 1 | 512 | 1/48 (2.1%) | 15.65 / 19.50 |
| phi-3.5-moe-4bit | 5 | 4200 (long table) | 118/136 (86.8%) | 7.70 / 3008.7 |
| gemma-4-e2b-it-4bit + audio | prefill | 100 audio tokens | 0/78 | 1.657 / 1.657 |

Gemma 3n at width 1 shows no decided disagreement: shared layers write no KV, so the only error is a one-position query shift in 10 of 30 layers; the effect grows with width. The audio clip is a deterministic 4 s synthetic chirp/tone/noise WAV (`tests/fixtures/audio/tone.wav` is 0.25 s); the arms differ (max logit delta 0.875) but not at decided positions. A transformers float32 reference for Phi-3.5-MoE (42B) is not feasible on this host, and mlx-lm is not a valid short-regime oracle (long table only).

Other checks: `mlxcel generate` on Phi-3.5-MoE is fluent at 128 tokens. On `phi-3-small-8k-instruct-aq4_64` (substitute for mlx-community Phi-3-small-8k-instruct-4bit), 256 sampled tokens through the suppression bias emitted no listed id.

## Follow-ups (not in this PR)

- `mlxcel-xla` `gemma3n_emit_ops.rs` deliberately mirrors the old shared-layer query offset; MLX-vs-XLA Gemma 3n parity will now diverge. Not buildable here.
- `phimoe::ModelArgs` reads `layer_norm_eps` (default 1e-6); the checkpoint spells it `rms_norm_eps: 1e-5`.
- The #674 chunked-prefill opt-out on `Gemma3nModel` may be this bug; flipping it needs the parity battery.
- xla-diagnostics call sites in `gemma3n.rs` were updated by hand and not compiled.

Closes #2379
@inureyes inureyes added this to the 0.8 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core mlxcel-core: MLX FFI, primitives, KV cache, layers priority:high High priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant