Skip to content

chore: clear the OpenXLA warning backlog and deny all warnings in CI - #1381

Merged
inureyes merged 3 commits into
mainfrom
chore/issue-1304-openxla-dead-code-backlog
Aug 22, 2026
Merged

inureyes merged 3 commits into
mainfrom
chore/issue-1304-openxla-dead-code-backlog

Conversation

@inureyes

@inureyes inureyes commented Aug 22, 2026 •

Copy link
Copy Markdown
Member

Summary

The xla-compile job denied unused_imports rather than warnings because the cuda,xla-iree and xla-diagnostics feature sets carried a dead-code and clippy backlog that would have made the job red the day it landed. This clears that backlog and widens the gate to -D warnings.

Resolution followed the criterion in the issue: cfg-gate to the feature set that has a real consumer where the gate needs no duplicate definition, otherwise allow with a comment naming the caller, and delete only when a search finds no consumer under any feature combination.

What changed

mlxcel-xla

  • src/lib/mlxcel-xla/src/iree.rs: IreeRaggedLlama::decode_ragged_logits is now #[cfg(feature = "diagnostics")]. Its only callers are LlavaReferenceDiagnosticEngine::capture and the Gemma3n diagnostic runners in batch.rs, all of which are already #[cfg(feature = "diagnostics")]; serving calls decode_ragged_logits_with_modes directly.
  • src/lib/mlxcel-xla/src/iree.rs: decode_ragged_mrope_logits is deleted. This is the one deletion in the PR. grep -rn "decode_ragged_mrope_logits" . --exclude-dir=.git --exclude-dir=target filtered of the _with_modes sibling and the xla_llama_ extern returns exactly two hits: the definition itself, and an error-message string inside decode_ragged_mrope_logits_with_modes that stays. There is no caller in any crate, test, bench, or example, under any feature combination.
  • src/lib/mlxcel-xla/src/iree.rs: a doc comment describing create_ctx had been stranded above a blank line when feat(xla): compile a set of context capacities and route requests between them #1302 inserted create_bucket_ctx and its own doc block between them, which is what clippy::empty_line_after_doc_comments was reporting. It is moved back onto create_ctx.
  • src/lib/mlxcel-xla/src/aux.rs: AuxiliaryWeightDType::Float16 and Uint32 are allowed under not(feature = "micro-oracle"). numeric_probe.rs, behind that feature, is their only construction site, while ffi_code and size_bytes have to keep mapping them for the FFI contract on every build. Gating the variants themselves would force a cfg onto each arm of those two matches, including the Float32 | Uint32 arm.
  • src/lib/mlxcel-xla/src/phi4_audio.rs: load_audio_module takes a scoped #[allow(clippy::too_many_arguments)]. A parameter struct would ripple into both call sites for a private single-file helper, so the allow was preferred per the issue's guidance.
  • src/lib/mlxcel-xla/src/aux_manifest.rs: the nested if let in cache_lock_is_stale collapses to an edition-2024 let chain.

mlxcel

  • src/server/batch/xla_audio_preprocess.rs: the test-only surface is allowed under not(test), following the #[cfg_attr(not(test), allow(dead_code))] pattern already used in src/model_metadata.rs and src/server/startup.rs. Each site names xla_audio_preprocess_tests.rs as the caller: AudioPreprocessStage::spawn (serving uses spawn_with_loader to keep MLX handles thread-confined), recv (serving must not block, so it drains with try_recv), metrics, is_healthy, the healthy field it reads, AudioPreprocessMetrics::snapshot, and AudioPreprocessMetricsSnapshot. The Cancelled(AudioPreprocessCheckpoint) payload keeps its field with the same allow: serving matches it as Cancelled(_), and the checkpoint distinction belongs in the type because Cancelled is constructed at several checkpoints in that file.
  • src/server/media.rs: validate_xla_raw_counts gains a not(test) arm alongside its existing not(feature = "xla-iree") one. media_tests.rs is its only caller; the XLA admission path calls validate_xla_raw_counts_with_audio directly because it knows whether the loaded family supports audio.
  • src/server/batch/xla_worker_admission.rs: drain_preprocessed takes #[allow(clippy::while_let_loop)]. The suggested while let Some(stage) = self.image_preprocessor.as_ref() head holds a shared borrow of self across a body that calls &mut self methods and clears the field, so the match shape is load-bearing rather than stylistic.
  • src/loading/vlm.rs and src/models/sanitize.rs: the two needless_match sites take #[cfg_attr(not(feature = "surgery"), allow(clippy::needless_match))]. The match only collapses to match transform { Some(t) => Some(t), None => None } when the surgery arm is compiled out, which is why the lint fires under --no-default-features and not under the default feature set. Applying clippy's suggestion would delete active-pipeline resolution from the default build, so the lint is silenced only for the builds that see the collapsed shape.

CI

  • .github/workflows/ci.yml: xla-compile now sets RUSTFLAGS: "-D warnings", and the paragraph explaining the narrower -D unused_imports policy is replaced.
  • .github/workflows/ci.yml: the "Deliberately NOT covered" list records the gap that remains after this change. The job runs cargo check, so -D warnings denies rustc lints only. dead_code and unused_imports are gated now, but collapsible_if, needless_match, too_many_arguments, while_let_loop and the rest of clippy's own lints are still gated by nothing in CI under these feature sets, because the clippy job covers default features only. That half of the backlog can regrow silently; swapping this job's cargo check for cargo clippy was deliberately left out of scope.

No runtime behavior change

The diff is attribute additions, cfg additions, comments, one collapsed if, one doc-comment move, and the deletion of one function that has no caller. No executed code path changes.

Test plan

Run on the GB10 host with the IREE runtime provisioned (bash scripts/iree/setup-cuda.sh, eval "$(bash scripts/iree/setup-cuda.sh --env)", MLX_CUDA_ARCHITECTURES=121), and re-run on the final commit after the review follow-ups landed.

Acceptance criteria:

  • cargo clippy --features cuda,xla-iree --all-targets -- -D warnings: exit 0, no warnings.
  • cargo clippy --no-default-features --features xla-diagnostics --all-targets -- -D warnings: exit 0, no warnings.
  • Default-feature regression, cargo clippy -p mlxcel --lib --tests -- -D warnings: exit 0, no warnings.

The two commands the job itself runs, under the widened flag, because cargo clippy -- -D warnings applies the flag only to the primary package while RUSTFLAGS reaches every path-built unit including mlxcel-core and mlxcel-surgery. Clippy passing is therefore not sufficient evidence that the job will be green:

  • RUSTFLAGS="-D warnings" cargo check --features cuda,xla-iree --all-targets: exit 0.
  • RUSTFLAGS="-D warnings" cargo check --no-default-features --features xla-diagnostics --all-targets: exit 0.

Scoped and mechanical checks:

  • cargo clippy -p mlxcel-xla --lib --features iree --all-targets -- -D warnings
  • cargo clippy -p mlxcel-xla --lib --features iree,diagnostics --all-targets -- -D warnings
  • cargo clippy -p mlxcel-xla --lib --features iree,micro-oracle --all-targets -- -D warnings, confirming the micro-oracle cfg arm on the AuxiliaryWeightDType variants is not narrowed wrongly
  • rustfmt --edition 2024 --check on every changed Rust file
  • .github/workflows/ci.yml parses as YAML

End to end, this PR's own CI exercises the change it makes: OpenXLA feature compile ran for 7m44s under the new RUSTFLAGS: "-D warnings" and passed, so the widened gate is green on arrival rather than red. OpenXLA feature link, added by #1305, also ran because src/lib/mlxcel-xla/** is in its path filter.

Not verified:

  • metal,accelerate. It cannot be built on this Linux host, so it is unverified by execution rather than confirmed. The static argument that it is unaffected: make verify-clippy runs --features metal,accelerate without --no-default-features, so surgery stays on and both needless_match attributes expand to nothing; mlxcel-xla builds with no features there, so iree.rs, aux.rs, aux_manifest.rs and phi4_audio.rs sit behind #[cfg(feature = "iree")] and never compile; and on the mlxcel side only media.rs and xla_audio_preprocess.rs compile, where every change is an allow attribute that cannot break a build.

Follow-ups this surfaced, out of scope here

  • mlxcel-xla's #[cfg(test)] modules are gated by no CI job at all. There is no default-members, so cargo check in this job resolves to -p mlxcel and --all-targets expands within that package only, while the clippy job builds default features where mlxcel-xla is default-off. Recorded in the workflow's exclusion list.
  • Clippy-only lints under these feature sets remain ungated, so that half of the backlog can regrow. Closing it means running clippy in this job, which was left out of scope deliberately.
  • media_tests.rs reaches validate_xla_raw_counts_with_audio only through the supports_audio = false wrapper, so the true branch has no direct unit coverage, and the sign of that flag is the security-relevant bit.

Closes #1304

The `xla-compile` job denied `unused_imports` rather than `warnings` because the `cuda,xla-iree` and `xla-diagnostics` feature sets carried a dead-code and clippy backlog that would have made the job red the day it landed. This clears the backlog and widens the gate.

Resolution per item, following the criterion in #1304: cfg-gate to the feature set that has a real consumer where the gate needs no duplicate definition, otherwise allow with a comment naming the caller, and delete only when no consumer exists under any feature combination.

In `mlxcel-xla`: `IreeRaggedLlama::decode_ragged_logits` is now `#[cfg(feature = "diagnostics")]`, matching its only callers (`LlavaReferenceDiagnosticEngine::capture` and the Gemma3n diagnostic runners in `batch.rs`); serving calls `decode_ragged_logits_with_modes` directly. `decode_ragged_mrope_logits` is deleted: a repository-wide search over every file type found the definition and one error-message string inside its `_with_modes` sibling, and no caller. The `AuxiliaryWeightDType::Float16` / `Uint32` variants are allowed under `not(feature = "micro-oracle")`, which is the feature behind `numeric_probe.rs`, their only construction site, while `ffi_code` and `size_bytes` must keep mapping them on every build. `load_audio_module` takes a scoped `too_many_arguments` allow rather than a parameter struct, since both call sites are in the same file and pass a different graph/artifact/entry triple. The nested `if let` in `cache_lock_is_stale` collapses to an edition-2024 let chain, and a doc comment stranded by the bucket-context function added in #1302 is reattached to the `create_ctx` it describes.

In `mlxcel`: the test-only surface of `xla_audio_preprocess.rs` (`AudioPreprocessStage::spawn` / `recv` / `metrics` / `is_healthy`, the `healthy` field, `AudioPreprocessMetrics::snapshot`, `AudioPreprocessMetricsSnapshot`, and the `Cancelled` checkpoint payload) is allowed under `not(test)` with each site naming `xla_audio_preprocess_tests.rs`, following the in-tree `cfg_attr(not(test), allow(dead_code))` pattern. `MediaRequestMetadata::validate_xla_raw_counts` gains the same `not(test)` arm alongside its existing feature arm. `XlaServeWorker::drain_preprocessed` takes a `while_let_loop` allow because the suggested `while let` head would hold a shared borrow of `self` across a body that mutates it. The two `needless_match` sites in `loading/vlm.rs` and `models/sanitize.rs` take a `not(feature = "surgery")` allow: the match only collapses when the `surgery` arm is compiled out, and applying clippy's suggestion would delete active-pipeline resolution from the default build.

`.github/workflows/ci.yml` now sets `RUSTFLAGS: "-D warnings"` for `xla-compile`, and the "Deliberately NOT covered" list records the gap that remains: the job runs `cargo check`, so `-D warnings` denies rustc lints only and clippy's own lints under these feature sets are still gated by nothing in CI.

No runtime behavior changes: the diff is attribute additions, cfg additions, comments, a collapsed `if`, a doc-comment move, and one deletion of an uncalled function.

Closes #1304
@inureyes inureyes added status:review Under review type:chore Maintenance tasks (build, CI, etc.) priority:low Low priority area:core mlxcel-core: MLX FFI, primitives, KV cache, layers labels Aug 22, 2026
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Clear the dead-code and clippy backlog under cuda,xla-iree and xla-diagnostics, then widen the xla-compile job from -D unused_imports to -D warnings, without changing any runtime behavior.

Findings Addressed

None requiring a code change. Every Set A and Set B item in #1304 is resolved, each allow names a real caller, and the "no runtime behavior change" claim holds line by line.

Line-by-line verification of the no-behavior-change claim

  • iree.rs decode_ragged_logits gate: all four callers (batch.rs:1190 in LlavaReferenceDiagnosticEngine::capture, batch.rs:1293 in run_gemma3n_prefix_decode_diagnostic, batch.rs:1472 and :1493 in run_gemma3n_canonical_diagnostics) sit under #[cfg(feature = "diagnostics")] items, and diagnostics = ["iree"] so the gate can never be wider than the module. Serving reaches the same code through decode_ragged_logits_with_modes, which keeps its live caller at batch.rs:1047.
  • iree.rs decode_ragged_mrope_logits deletion: a repository-wide search (all file types, excluding .git and target) returns the removed definition, the _with_modes sibling, the xla_llama_decode_ragged_mrope_logits extern and its C definition, and one error string. No Rust caller in any crate, test, bench, example, or spike, under any feature combination. micro-oracle does not reach it: numeric_probe.rs and numeric_oracle.rs never name either method. Confirmed empirically with cargo clippy -p mlxcel-xla --features iree,micro-oracle --all-targets -- -D warnings, which exits 0 on this branch. Removing the wrapper also strands nothing, since _with_modes retains its own caller.
  • aux_manifest.rs let chain: identical control flow. Both shapes are "read succeeds AND pid parses, then probe /proc", both have no else, and && in a let chain short-circuits, so cache_lock_owner_pid is still only called on a successful read. Neither version had a failure path to preserve; every non-matching case falls through to the mtime check, as before.
  • vlm.rs:333 and sanitize.rs:1668: the cfg_attr sits on the let resolved_transform statement whose initializer is the flagged match, which is the node clippy reports under. Both match bodies are untouched, and under the default feature set (default = ["surgery"]) the attribute expands to nothing, so the default path is byte-identical.
  • xla_audio_preprocess.rs: every annotated item has a real caller in xla_audio_preprocess_tests.rs. spawn (8 sites), recv (:122, :201, :214, and more), metrics (:132 and more), is_healthy (:140, :312, :330), snapshot via stage.metrics().snapshot(), AudioPreprocessMetricsSnapshot through the fields those assertions read, and the Cancelled payload at :263. The healthy field is genuinely written by the production path (spawn_with_loader, :464-:516) and only read back through is_healthy, so the comment is accurate. Serving matches Cancelled(_) at xla_worker_admission.rs:395 and xla_audio_preprocess.rs:812, so the payload really is unread outside tests. No allow here papers over a genuinely dead item.
  • xla_worker_admission.rs: the borrow argument checks out. A while let Some(stage) = self.image_preprocessor.as_ref() head holds a shared borrow across a body that calls self.handle_preprocessed and assigns self.image_preprocessor = None.
  • ci.yml comment: every factual claim verified. The job does run cargo check (both steps), collapsible_if / needless_match / too_many_arguments / while_let_loop are all clippy-only lints, and the clippy job above at line 139 does run cargo clippy -p mlxcel --lib --tests -- -D warnings at default features only.

metal,accelerate, reasoned statically

Safe. make verify-clippy runs cargo clippy --workspace --all-targets --features metal,accelerate -- -D warnings, without --no-default-features, so surgery stays on and the two needless_match attributes expand to nothing. mlxcel-xla builds there with no features, so iree.rs, aux.rs, aux_manifest.rs and phi4_audio.rs are all behind #[cfg(feature = "iree")] and are not compiled at all. On the mlxcel side the only two changed files that compile are media.rs and xla_audio_preprocess.rs, and both changes are allow attributes that cannot break a build. xla_audio_preprocess.rs additionally still carries the module-level #[cfg_attr(not(feature = "xla-iree"), allow(dead_code))] at batch/mod.rs:70, which covers the whole module on that feature set.

The xla-diagnostics-cpu trap is avoided by construction: no cfg added on the mlxcel side keys on a diagnostics feature at all.

Remaining Items

  • iree.rs:3103 error string still reads decode_ragged_mrope_logits expects ... inside decode_ragged_mrope_logits_with_modes, naming a function that no longer exists (LOW) - deliberate and disclosed in the PR body, and rewording it would touch a user-visible string under a no-behavior-change constraint, so leaving it is defensible.
  • media.rs:204 condition any(not(feature = "xla-iree"), not(test)) is wider than it needs to be (LOW) - the not(feature = "xla-iree") disjunct is inert, because in the one configuration it adds (xla-iree off, test on) media_tests.rs uses the method unconditionally, so no lint could fire there. not(test) alone is equivalent and would match the rewritten doc comment, which now explains only the test-caller rationale.
  • iree.rs:2296-:2305 carries the same stranded-doc-comment defect this PR fixed at :1819 (LOW, pre-existing) - the IreeRaggedLlama doc block is attached to PreparedPrefillDiagnostics, so Self::prefill_slot_logits and Self::decode_ragged_logits are broken intra-doc links. It predates this branch and is not a clippy warning (no blank line separates it), so it is outside the backlog this PR was scoped to.

Note on the widened gate

RUSTFLAGS: "-D warnings" applies to every unit cargo compiles, not only the primary package. Registry dependencies are shielded by cargo's --cap-lints allow, so the practical blast radius is the workspace path crates and their build scripts, which is the intent. Changing RUSTFLAGS does invalidate the persistent target directory, so the first run after merge is a cold rebuild; the 120-minute timeout leaves ample headroom against the measured cold cost on this runner.

Verification

  • All stated requirements implemented (every Set A and Set B item, plus the four not in the issue body)
  • No placeholder/mock code remaining
  • Integrated into project code flow (the gate change is in the job that runs it)
  • Project conventions followed (cfg_attr(not(test), allow(dead_code)) already used in model_metadata.rs, server/startup.rs, loading/nonstandard.rs, loading/config_backed.rs)
  • Existing modules reused where applicable
  • No unintended structural changes (10 files, all in scope; build.rs and tests/molmo2_xla_vision_parity.rs untouched)
  • rustfmt --edition 2024 --check clean on all nine changed Rust files; ci.yml parses as YAML
  • cargo clippy -p mlxcel-xla --features iree,micro-oracle --all-targets -- -D warnings exits 0

No CRITICAL or HIGH findings.

Review follow-up on the #1304 backlog clearing. No behavior change and no change to which lints are denied; this fixes places where a comment or a message asserted something the tree does not support, which is the failure mode a suppression-heavy PR has to guard against.

`iree.rs`: the two arity-check error messages named the thin wrappers rather than the functions that emit them. `decode_ragged_mrope_logits` is deleted by this PR and `decode_ragged_logits` is now `diagnostics`-only, so a production `cuda,xla-iree` build could return a message naming a function that build does not contain. Both now name their `_with_modes` emitter.

`xla_audio_preprocess.rs`: `AudioPreprocessStage::spawn` is also called from `xla_worker_tests.rs:247`, not only `xla_audio_preprocess_tests.rs`. The acceptance criterion for #1304 is that every allow names the caller keeping the item alive, so an incomplete list is the specific thing that criterion exists to prevent.

`xla_worker_admission.rs`: `drain_preprocessed` contains two drain loops, image and audio, and the function-level `allow(clippy::while_let_loop)` covers both. The comment described only the image one.

`ci.yml`: records two things the "Deliberately NOT covered" list did not. First, the path dependencies' test targets are outside this gate: there is no `default-members`, so `cargo check` here resolves to `-p mlxcel` and `--all-targets` expands within that package only, leaving mlxcel-xla's `#[cfg(test)]` modules ungated by every job, since the `clippy` job builds default features where the crate is default-off. The #1304 test plan ran `-p mlxcel-xla --all-targets` by hand, which CI will not. Second, the blast radius and the brittleness bound of `-D warnings`: it reaches every path-built unit, so mlxcel-core, mlxcel-surgery, mlxcel-xla and the build scripts are gated here too, while registry and git dependencies cannot red the job because cargo compiles those with `--cap-lints allow`, and `rust-toolchain.toml` pins the toolchain exactly so a new rustc release cannot turn the job red without a deliberate pin bump.

Validated with `cargo clippy -p mlxcel-xla --lib --features iree --all-targets -- -D warnings` under `RUSTFLAGS=-D warnings` (clean), `rustfmt --edition 2024 --check` on all three Rust files, and a YAML parse of the workflow.

Refs #1304
@inureyes

Copy link
Copy Markdown
Member Author

Security and maintenance-risk review

No CRITICAL or HIGH findings. The ordinary vulnerability surface is genuinely absent here: no new I/O, no new dependencies, no parsing, no trust boundary moved. The review focused on the three risks a suppression PR actually carries.

1. Do the suppressions hide a real defect? No.

Every allow was checked against its named caller, and every claim holds.

Item Claimed live in Verified
AudioPreprocessStage::spawn tests xla_audio_preprocess_tests.rs:106,166,241 and xla_worker_tests.rs:247
recv / metrics / snapshot / is_healthy tests all four called in xla_audio_preprocess_tests.rs
AudioPreprocessMetricsSnapshot snapshot() yes
healthy field worker liveness written at spawn_with_loader 476/483/496
AuxiliaryWeightDType::Float16 / Uint32 micro-oracle numeric_probe.rs:693,699,705; lib.rs:60-61 gates the module on that feature
validate_xla_raw_counts media_tests.rs 5 call sites

The not(test) pattern is self-enforcing rather than a permanent silencer: cargo check --all-targets compiles the mlxcel lib twice, once with cfg(test), so deleting the sole test caller re-reds this job instead of going quiet.

On the validate_xla_raw_counts asymmetry specifically: it is not a latent bug. The wrapper is _with_audio(images, audio, videos, false) verbatim, and admission passes a computed flag (self.audio_preprocessor.is_some(), xla_worker_admission.rs:57-61), never a hardcoded false. Every check in the shared body runs in production; the dead item is a test-facing alias, not a skipped validator. One follow-up worth filing separately: media_tests.rs reaches _with_audio only through the false wrapper, so the supports_audio = true branch has no direct unit coverage, and the sign of that flag is the security-relevant bit.

On healthy: production never reads it, but it is not a missed-failure path. Worker death is detected through TryRecvError::Disconnected in drain_preprocessed, which clears the stage and errors every pending request. The flag is genuinely redundant in serving, so the allow is the right call.

On Cancelled(AudioPreprocessCheckpoint): serving matches Cancelled(_) and observability.audio_preprocess_cancelled is a single unlabelled counter, so the checkpoint distinction is computed and discarded in production. Keeping the payload is defensible as argued; a checkpoint label on that counter would be a reasonable later improvement.

2. The deletion is safe.

decode_ragged_mrope_logits has no reachable caller. Repo-wide grep excluding .git and target, filtered of the _with_modes sibling and the xla_llama_ extern, leaves exactly zero references after this change. Checked for the paths a plain grep misses: mlxcel-xla has one macro_rules! (validation.rs:499, MLIR fixtures) and no paste! or concat_idents!, so no generated call site; no doc test, no pub use, no trait impl, and the C symbol plus the _with_modes Rust sibling both remain live via batch.rs:1052.

3. The cfg gate is correct.

All four decode_ragged_logits callers are inside #[cfg(feature = "diagnostics")] items: LlavaReferenceDiagnosticEngine (batch.rs:1134), run_gemma3n_prefix_decode_diagnostic (:1262), and run_gemma3n_canonical_diagnostics (:1322). diagnostics = ["iree"], so the new gate is strictly narrower than the module's existing iree gate and cannot break a combination. No non-diagnostics caller exists.

4. CI maintenance risk from -D warnings

Not brittle against compiler churn. rust-toolchain.toml pins channel = "1.97.1" exactly rather than stable, and the job resolves cargo through the rustup shim with no toolchain-install step, so the pin applies. A new rustc release cannot red this job on its own. The cost moves to the pin bump, which must now also re-clear these two feature sets.

Two things worth recording rather than assuming, which the follow-up commit adds to the workflow:

  • Blast radius. RUSTFLAGS reaches every path-built unit, so mlxcel-core, mlxcel-surgery, mlxcel-xla and the build scripts are gated here too, and a cuda-only warning in mlxcel-core now reds a job named for OpenXLA. Registry and git dependencies cannot, because cargo compiles those with --cap-lints allow.
  • A coverage gap the exclusion list did not have. There is no default-members, so cargo check here resolves to -p mlxcel and --all-targets expands within that package only. The path dependencies are built as plain library units, so mlxcel-xla's #[cfg(test)] modules are gated by no job at all: the clippy job builds default features, where the crate is default-off. The test plan above ran -p mlxcel-xla --all-targets by hand, which CI will not.

One-time cache effect only: RUSTFLAGS is part of cargo's fingerprint, so the persistent target dir was invalidated once (the observed 7m44s rebuild) and returns to the ~1 min warm figure the workflow already documents.

Fixes applied (89c0a5d)

All LOW, comment and message accuracy only.

  1. iree.rs: both arity-check messages named the thin wrappers instead of their _with_modes emitters, so a production build could return a message naming a function it does not contain.
  2. xla_audio_preprocess.rs: spawn's comment named one test file; xla_worker_tests.rs calls it too. An incomplete caller list is the specific thing chore: clear the OpenXLA dead-code backlog so the CI gate can deny all warnings #1304's acceptance criterion exists to prevent.
  3. xla_worker_admission.rs: drain_preprocessed has two drain loops and the allow covers both; the comment described only the image one.
  4. ci.yml: the two items above.

Validated with cargo clippy -p mlxcel-xla --lib --features iree --all-targets -- -D warnings under RUSTFLAGS=-D warnings (clean), rustfmt --edition 2024 --check on all three Rust files, and a YAML parse of the workflow. metal,accelerate remains unverified; it cannot be built on this Linux host.

@inureyes inureyes added status:done Completed and removed status:review Under review labels Aug 22, 2026
@inureyes
inureyes merged commit 6128944 into main Aug 22, 2026
10 checks passed
@inureyes
inureyes deleted the chore/issue-1304-openxla-dead-code-backlog branch August 22, 2026 13:40
@inureyes inureyes self-assigned this Aug 27, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
…ablup#1381)

## Summary

The `xla-compile` job denied `unused_imports` rather than `warnings` because the `cuda,xla-iree` and `xla-diagnostics` feature sets carried a dead-code and clippy backlog that would have made the job red the day it landed. This clears that backlog and widens the gate to `-D warnings`.

Resolution followed the criterion in the issue: cfg-gate to the feature set that has a real consumer where the gate needs no duplicate definition, otherwise allow with a comment naming the caller, and delete only when a search finds no consumer under any feature combination.

## What changed

### `mlxcel-xla`

- `src/lib/mlxcel-xla/src/iree.rs`: `IreeRaggedLlama::decode_ragged_logits` is now `#[cfg(feature = "diagnostics")]`. Its only callers are `LlavaReferenceDiagnosticEngine::capture` and the Gemma3n diagnostic runners in `batch.rs`, all of which are already `#[cfg(feature = "diagnostics")]`; serving calls `decode_ragged_logits_with_modes` directly.
- `src/lib/mlxcel-xla/src/iree.rs`: `decode_ragged_mrope_logits` is deleted. This is the one deletion in the PR. `grep -rn "decode_ragged_mrope_logits" . --exclude-dir=.git --exclude-dir=target` filtered of the `_with_modes` sibling and the `xla_llama_` extern returns exactly two hits: the definition itself, and an error-message string inside `decode_ragged_mrope_logits_with_modes` that stays. There is no caller in any crate, test, bench, or example, under any feature combination.
- `src/lib/mlxcel-xla/src/iree.rs`: a doc comment describing `create_ctx` had been stranded above a blank line when lablup#1302 inserted `create_bucket_ctx` and its own doc block between them, which is what `clippy::empty_line_after_doc_comments` was reporting. It is moved back onto `create_ctx`.
- `src/lib/mlxcel-xla/src/aux.rs`: `AuxiliaryWeightDType::Float16` and `Uint32` are allowed under `not(feature = "micro-oracle")`. `numeric_probe.rs`, behind that feature, is their only construction site, while `ffi_code` and `size_bytes` have to keep mapping them for the FFI contract on every build. Gating the variants themselves would force a `cfg` onto each arm of those two matches, including the `Float32 | Uint32` arm.
- `src/lib/mlxcel-xla/src/phi4_audio.rs`: `load_audio_module` takes a scoped `#[allow(clippy::too_many_arguments)]`. A parameter struct would ripple into both call sites for a private single-file helper, so the allow was preferred per the issue's guidance.
- `src/lib/mlxcel-xla/src/aux_manifest.rs`: the nested `if let` in `cache_lock_is_stale` collapses to an edition-2024 let chain.

### `mlxcel`

- `src/server/batch/xla_audio_preprocess.rs`: the test-only surface is allowed under `not(test)`, following the `#[cfg_attr(not(test), allow(dead_code))]` pattern already used in `src/model_metadata.rs` and `src/server/startup.rs`. Each site names `xla_audio_preprocess_tests.rs` as the caller: `AudioPreprocessStage::spawn` (serving uses `spawn_with_loader` to keep MLX handles thread-confined), `recv` (serving must not block, so it drains with `try_recv`), `metrics`, `is_healthy`, the `healthy` field it reads, `AudioPreprocessMetrics::snapshot`, and `AudioPreprocessMetricsSnapshot`. The `Cancelled(AudioPreprocessCheckpoint)` payload keeps its field with the same allow: serving matches it as `Cancelled(_)`, and the checkpoint distinction belongs in the type because `Cancelled` is constructed at several checkpoints in that file.
- `src/server/media.rs`: `validate_xla_raw_counts` gains a `not(test)` arm alongside its existing `not(feature = "xla-iree")` one. `media_tests.rs` is its only caller; the XLA admission path calls `validate_xla_raw_counts_with_audio` directly because it knows whether the loaded family supports audio.
- `src/server/batch/xla_worker_admission.rs`: `drain_preprocessed` takes `#[allow(clippy::while_let_loop)]`. The suggested `while let Some(stage) = self.image_preprocessor.as_ref()` head holds a shared borrow of `self` across a body that calls `&mut self` methods and clears the field, so the `match` shape is load-bearing rather than stylistic.
- `src/loading/vlm.rs` and `src/models/sanitize.rs`: the two `needless_match` sites take `#[cfg_attr(not(feature = "surgery"), allow(clippy::needless_match))]`. The match only collapses to `match transform { Some(t) => Some(t), None => None }` when the `surgery` arm is compiled out, which is why the lint fires under `--no-default-features` and not under the default feature set. Applying clippy's suggestion would delete active-pipeline resolution from the default build, so the lint is silenced only for the builds that see the collapsed shape.

### CI

- `.github/workflows/ci.yml`: `xla-compile` now sets `RUSTFLAGS: "-D warnings"`, and the paragraph explaining the narrower `-D unused_imports` policy is replaced.
- `.github/workflows/ci.yml`: the "Deliberately NOT covered" list records the gap that remains after this change. The job runs `cargo check`, so `-D warnings` denies rustc lints only. `dead_code` and `unused_imports` are gated now, but `collapsible_if`, `needless_match`, `too_many_arguments`, `while_let_loop` and the rest of clippy's own lints are still gated by nothing in CI under these feature sets, because the `clippy` job covers default features only. That half of the backlog can regrow silently; swapping this job's `cargo check` for `cargo clippy` was deliberately left out of scope.

## No runtime behavior change

The diff is attribute additions, `cfg` additions, comments, one collapsed `if`, one doc-comment move, and the deletion of one function that has no caller. No executed code path changes.

## Test plan

Run on the GB10 host with the IREE runtime provisioned (`bash scripts/iree/setup-cuda.sh`, `eval "$(bash scripts/iree/setup-cuda.sh --env)"`, `MLX_CUDA_ARCHITECTURES=121`), and re-run on the final commit after the review follow-ups landed.

Acceptance criteria:

- [x] `cargo clippy --features cuda,xla-iree --all-targets -- -D warnings`: exit 0, no warnings.
- [x] `cargo clippy --no-default-features --features xla-diagnostics --all-targets -- -D warnings`: exit 0, no warnings.
- [x] Default-feature regression, `cargo clippy -p mlxcel --lib --tests -- -D warnings`: exit 0, no warnings.

The two commands the job itself runs, under the widened flag, because `cargo clippy -- -D warnings` applies the flag only to the primary package while `RUSTFLAGS` reaches every path-built unit including `mlxcel-core` and `mlxcel-surgery`. Clippy passing is therefore not sufficient evidence that the job will be green:

- [x] `RUSTFLAGS="-D warnings" cargo check --features cuda,xla-iree --all-targets`: exit 0.
- [x] `RUSTFLAGS="-D warnings" cargo check --no-default-features --features xla-diagnostics --all-targets`: exit 0.

Scoped and mechanical checks:

- [x] `cargo clippy -p mlxcel-xla --lib --features iree --all-targets -- -D warnings`
- [x] `cargo clippy -p mlxcel-xla --lib --features iree,diagnostics --all-targets -- -D warnings`
- [x] `cargo clippy -p mlxcel-xla --lib --features iree,micro-oracle --all-targets -- -D warnings`, confirming the `micro-oracle` cfg arm on the `AuxiliaryWeightDType` variants is not narrowed wrongly
- [x] `rustfmt --edition 2024 --check` on every changed Rust file
- [x] `.github/workflows/ci.yml` parses as YAML

End to end, this PR's own CI exercises the change it makes: `OpenXLA feature compile` ran for 7m44s under the new `RUSTFLAGS: "-D warnings"` and passed, so the widened gate is green on arrival rather than red. `OpenXLA feature link`, added by lablup#1305, also ran because `src/lib/mlxcel-xla/**` is in its path filter.

Not verified:

- [ ] `metal,accelerate`. It cannot be built on this Linux host, so it is unverified by execution rather than confirmed. The static argument that it is unaffected: `make verify-clippy` runs `--features metal,accelerate` without `--no-default-features`, so `surgery` stays on and both `needless_match` attributes expand to nothing; `mlxcel-xla` builds with no features there, so `iree.rs`, `aux.rs`, `aux_manifest.rs` and `phi4_audio.rs` sit behind `#[cfg(feature = "iree")]` and never compile; and on the `mlxcel` side only `media.rs` and `xla_audio_preprocess.rs` compile, where every change is an `allow` attribute that cannot break a build.

## Follow-ups this surfaced, out of scope here

- `mlxcel-xla`'s `#[cfg(test)]` modules are gated by no CI job at all. There is no `default-members`, so `cargo check` in this job resolves to `-p mlxcel` and `--all-targets` expands within that package only, while the `clippy` job builds default features where `mlxcel-xla` is default-off. Recorded in the workflow's exclusion list.
- Clippy-only lints under these feature sets remain ungated, so that half of the backlog can regrow. Closing it means running clippy in this job, which was left out of scope deliberately.
- `media_tests.rs` reaches `validate_xla_raw_counts_with_audio` only through the `supports_audio = false` wrapper, so the `true` branch has no direct unit coverage, and the sign of that flag is the security-relevant bit.

Closes lablup#1304
@inureyes inureyes added this to the 0.7 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:low Low priority status:done Completed type:chore Maintenance tasks (build, CI, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: clear the OpenXLA dead-code backlog so the CI gate can deny all warnings

1 participant