Repository navigation
Description
Summary
PR #434 (issue #427) made the Gemma 4 Conformer audio encoder's conv2d/conv1d FFI calls fallible (via the new try_conv2d/try_conv1d wrappers) so a data-dependent conv shape fault returns a per-request error instead of std::terminate-aborting the whole server. The Nemotron-H Nano Omni audio encoder (the Parakeet-style SoundEncoder) has the same latent abort class on its own inference path and was intentionally left out of #427's Gemma-4-only scope. This issue extends the same hardening to it.
Background
try_conv2d and try_conv1d already exist in the cxx bridge as of #434 (src/lib/mlxcel-core/src/lib.rs, src/lib/mlxcel-core/cpp/mlx_cxx_bridge.{h,cpp}). They have bodies identical to the non-fallible ops but are declared -> Result on the Rust side, so cxx catches MLX's eager graph-build shape-mismatch throw at the FFI boundary. The remaining work is to route the Nemotron-H Nano Omni audio conv calls through them and thread Result to the request boundary, exactly as #434 did for Gemma 4.
This is a remote-DoS hardening: a crafted audio request whose runtime-derived shape mismatches the conv weights would otherwise abort the server process for all clients. The same class is documented in ADR 0003 and was first addressed for the audio synthesis matmul path in #384.
Affected call sites
In src/audio/nemotron_h_nano_omni/encoder.rs, the following conv calls are non-fallible and run on a data-dependent path (shapes derived from the runtime post-subsampling time/frequency length; see the "Computed at runtime per call" comment near line 406):
mlxcel_core::conv2d(...)at line 197 (Parakeet subsampling conv2d stack)- the
conv2d/conv1dcalls at lines ~549, ~570, ~583 (depthwise/pointwise convolution module)
The forward methods on these structs currently return bare UniquePtr<MlxArray>, so Result must be threaded up the SoundEncoder forward chain to the point where the audio encoder is invoked (the Nemotron-H Nano Omni VLM embedding path in src/vision/nemotron_h_nano_omni_vl.rs, reached from the model/VLM prefill request path), where it should surface as a per-request error.
Scope
- Route the data-dependent
conv2d/conv1dcalls insrc/audio/nemotron_h_nano_omni/encoder.rsthroughtry_conv2d/try_conv1d(already available; no new FFI needed). - Thread
Result<_, String>up theSoundEncoderforward chain (subsampling conv module, convolution module, encoder blocks, the top-level encoder forward) and out to the Nemotron-H Nano Omni VLM embedding builder and its request-path call sites, mirroring the fix: make conv2d/conv1d fallible at the FFI boundary so conv shape faults don't abort the server #434 propagation throughgemma4_vl.rsandmodel_worker/vlm_runtime/generate_vlm. - Leave any statically-shaped conv calls (shapes fixed by config, not derived from runtime audio length) unchanged, matching fix(mlxcel-core): make audio-path MLX ops fallible at the FFI boundary #384/fix: make conv2d/conv1d fallible at the FFI boundary so conv shape faults don't abort the server #434 scoping. Audit each call site to classify it.
Acceptance criteria
- A conv shape mismatch on the Nemotron-H Nano Omni audio path produces a per-request
Err(surfaced as a request error), not a process abort. - The
Resultpropagates to a real request boundary without being swallowed or converted to a reachable panic. - No behavior change on the happy path; no per-op overhead added to statically-shaped conv hot paths.
- An FFI-level or encoder-level test demonstrates the audio conv path returns an error rather than terminating (the
try_conv2d/try_conv1dFFI Err tests from fix: make conv2d/conv1d fallible at the FFI boundary so conv shape faults don't abort the server #434 already cover the wrapper itself; add coverage for the new routing if practical).
Related
Follow-up to #427 / PR #434 (Gemma 4 Conformer). Same crash class as #384 (try_matmul, audio synthesis). ADR 0003 documents the release panic=unwind + core-thread fail-fast model that makes a returned Err recoverable while an uncaught C++ throw is not.
Activity
test(audio): add conv1d abort-safety test and extend fault isolation …
fix: route nemotron omni audio-encoder convs through fallible FFI (la…
fix: route nemotron omni audio-encoder convs through fallible FFI (la…