Fix silent all-zero fbank in chunk embedding prep when the 30s model is absent - #17
Conversation
…sent compute_chunk_fbank treated 'chunk fits in the 30s model' and 'the 30s model exists' as one condition: for chunk_audio.len() <= 480_000 with fbank_30s == None it fell through to the end of the function and returned the all-zero tensor it had allocated, producing silently wrong embeddings rather than an error. orchestrate.rs already handles this correctly by falling back to the 10s model. Route both call sites through a pure select_fbank_path helper so the choice is explicit and unit-testable.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe chunk embedding preparation path now selects an available fbank model. Short chunks fall back to the 10-second model when the 30-second model is unavailable. Unit tests cover selection and no-model cases. ChangesFbank model selection
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change makes short chunks fall back to the available 10-second model instead of producing an all-zero feature buffer; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| src/pipeline/chunk_embedding/prep.rs | The new selector fixes the silent all-zero fallback while preserving existing model limits, buffer bounds, and sequential-path semantics. |
Reviews (1): Last reviewed commit: "fix(chunk-embedding): fall back to 10s f..." | Re-trigger Greptile
Closes #16
The bug
ChunkPrep::compute_chunk_fbank(src/pipeline/chunk_embedding/prep.rs) nested the "does this chunk fit the 30s model?" test inside the "is the 30s model loaded?" test:Because the 10s branch is the
else ifof the length check, it is unreachable for chunks<= 480_000samples. Withfbank_30s == Nonea short chunk therefore returns the zeroed buffer allocated up front — a well-formed, all-zero tensor. No error, no panic; just silently wrong embeddings downstream.run_sequential_chunksinorchestrate.rs:240-269already does this correctly, keying the fallback off whether the 30s fbank was actually produced rather than off chunk length.The fix
Extracted the choice into a small pure function so the two conditions are combined and the decision is explicit and testable:
compute_chunk_fbanknow dispatches onFbankPath, so a short chunk with no 30s model falls back to the 10s path exactly asorchestrate.rsdoes. The 30s and 10s computation bodies are unchanged — this is purely a control-flow correction.Tests
Four unit tests in
prep.rscover the matrix (30s available, 30s missing, long chunk, no models). The regression test isshort_chunk_falls_back_to_10s_when_30s_missing.Verified on real Apple Silicon hardware (
arm64Mac Studio), sincechunk_embeddingis gated behind#[cfg(feature = "coreml")]and does not compile on Linux (theobjc2*dependencies are Apple-only):Before the fix (original nested logic restored, same machine), the regression test fails precisely as expected while the other three pass:
Noneis exactly the state that yielded the all-zero fbank.After the fix, all four pass and the lib suite is
88 passed; 2 failedout of 90.The 2 failures (
fast_apple_embeddings_match_python_fixture,fast_apple_split_primary_batch_matches_single_tail_path) are pre-existing and unrelated — I confirmed they fail identically with stock, unmodifiedprep.rson the same machine (fixture drift in my local model artifacts, not a regression from this change).Summary by CodeRabbit