Skip to content

feat(onnx): single EP-aware session builder for embedding and segmentation - #32

Merged
ekhodzitsky merged 2 commits into
masterfrom
feat/ep-session-builder
Jul 10, 2026
Merged

ekhodzitsky merged 2 commits into
masterfrom
feat/ep-session-builder

Conversation

@ekhodzitsky

Copy link
Copy Markdown
Owner

Foundation for the execution-provider track: EP wiring was duplicated and hardcoded to CoreML at two ort session sites and absent at the third (the fbank embedder), so PipelineConfig.execution_provider was inert dead code — selecting NNAPI/CUDA/XNNPACK silently ran on CPU with no signal.

What changed

  • onnx::build_session_with_ep(path, ep, intra_threads) is now the single place embedding/segmentation ort sessions are constructed: ONNX header validation always runs before ort parses the file (the validate-before-build invariant), the EP is registered in one audited spot, and unwired providers log a tracing warning and run on CPU (ort's built-in CPU fallback keeps inference correct — registration failure is deliberately not fatal, per the task design).
  • The canonical ExecutionProvider enum (with target-aware auto()) moves to polyvoice::onnx — the module that owns session creation — eliminating the would-be cyclic dep; pipeline_v2::config re-exports it so existing imports keep compiling.
  • OnnxEmbeddingExtractor::new, FbankOnnxExtractor::new, PowersetSegmenter::with_config gain an ep parameter; PowersetSegmenter::new keeps its signature (target default). All callers across bins/tests/examples updated.
  • Default behavior is byte-identical: CoreML on Apple Silicon for segmentation + legacy embedding (as hardcoded today), plain CPU for the fbank embedder (which never had an EP). Threading the configured EP through the pipelines is the next task in the track.
  • Module contract + README updated (EP selection lives here).

Versioning

Breaking (constructor signatures + enum move, mitigated by re-export) — covered by the 0.10.0 bump already in flight on this release cycle (PR #31). CHANGELOG updated under Unreleased.

Verification

  • TDD: garbage file fails header validation before reaching ort; unwired EPs (CUDA, auto()) build OK on a real model without panicking; intra-threads path covered.
  • cargo test --lib onnx --features onnx: 8/8. Full cargo nextest run --all-features: 424 passed.
  • cargo hack check --feature-powerset --depth 2 --lib --bins: clean (no broken feature combos).
  • clippy -D warnings + fmt clean.

🤖 Generated with Claude Code

…ation

EP wiring was duplicated and hardcoded at three independent ort session
sites: CoreML inlined in the legacy embedder and the powerset segmenter,
and the fbank embedder had no EP at all — so the ExecutionProvider in
PipelineConfig was dead code and selecting Nnapi/Cuda/XnnPack silently
ran on CPU with no signal.

- onnx::build_session_with_ep(path, ep, intra_threads) is now the ONE
  place these sessions are constructed: header validation always runs
  before ort parses the file, the EP is registered in one audited spot,
  and unwired providers (NNAPI/CUDA/XNNPACK, or CoreML without the
  `coreml` feature) log a tracing warning and run on CPU.
- The canonical ExecutionProvider enum (with target-aware auto()) moves
  to polyvoice::onnx — the module that owns session creation — and stays
  re-exported from pipeline_v2::config, so existing imports compile.
- OnnxEmbeddingExtractor::new, FbankOnnxExtractor::new, and
  PowersetSegmenter::with_config gain an `ep` parameter (breaking;
  covered by the in-flight 0.10.0 bump). PowersetSegmenter::new keeps
  its signature and picks the target default. Default behavior is
  byte-identical: CoreML on Apple Silicon for segmentation/legacy
  embedding, plain CPU for the fbank embedder (threading the configured
  EP through the pipelines is the follow-up).
- Module contract + README document the new surface; TDD unit tests
  cover validate-before-build on garbage and the no-panic CPU fallback
  for unwired providers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 30.00000% with 63 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/onnx/mod.rs 51.16% 21 Missing ⚠️
src/embedder/mod.rs 0.00% 15 Missing ⚠️
src/segmentation/powerset.rs 0.00% 10 Missing ⚠️
src/ecapa/mod.rs 0.00% 7 Missing ⚠️
src/bin/polyvoice-mcp.rs 0.00% 5 Missing ⚠️
src/bin/polyvoice.rs 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

The runner pool serves images whose latest-stable Xcode differs (26.3 vs
26.6). Build-script outputs cached by rust-cache embed absolute toolchain
paths, so a cache built under one Xcode poisons the link line on a runner
with another (dead -L search paths -> ld: library 'clang_rt.osx' not
found). Keying the cache with the setup-xcode output isolates caches per
Xcode version; non-macOS jobs get a constant empty suffix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ekhodzitsky
ekhodzitsky merged commit aa83ff9 into master Jul 10, 2026
13 checks passed
@ekhodzitsky
ekhodzitsky deleted the feat/ep-session-builder branch July 10, 2026 13:37
ekhodzitsky added a commit that referenced this pull request Jul 31, 2026
…ation (#32)

* feat(onnx): single EP-aware session builder for embedding and segmentation

EP wiring was duplicated and hardcoded at three independent ort session
sites: CoreML inlined in the legacy embedder and the powerset segmenter,
and the fbank embedder had no EP at all — so the ExecutionProvider in
PipelineConfig was dead code and selecting Nnapi/Cuda/XnnPack silently
ran on CPU with no signal.

- onnx::build_session_with_ep(path, ep, intra_threads) is now the ONE
  place these sessions are constructed: header validation always runs
  before ort parses the file, the EP is registered in one audited spot,
  and unwired providers (NNAPI/CUDA/XNNPACK, or CoreML without the
  `coreml` feature) log a tracing warning and run on CPU.
- The canonical ExecutionProvider enum (with target-aware auto()) moves
  to polyvoice::onnx — the module that owns session creation — and stays
  re-exported from pipeline_v2::config, so existing imports compile.
- OnnxEmbeddingExtractor::new, FbankOnnxExtractor::new, and
  PowersetSegmenter::with_config gain an `ep` parameter (breaking;
  covered by the in-flight 0.10.0 bump). PowersetSegmenter::new keeps
  its signature and picks the target default. Default behavior is
  byte-identical: CoreML on Apple Silicon for segmentation/legacy
  embedding, plain CPU for the fbank embedder (threading the configured
  EP through the pipelines is the follow-up).
- Module contract + README document the new surface; TDD unit tests
  cover validate-before-build on garbage and the no-panic CPU fallback
  for unwired providers.

* ci: key macOS rust-cache to the selected Xcode version

The runner pool serves images whose latest-stable Xcode differs (26.3 vs
26.6). Build-script outputs cached by rust-cache embed absolute toolchain
paths, so a cache built under one Xcode poisons the link line on a runner
with another (dead -L search paths -> ld: library 'clang_rt.osx' not
found). Keying the cache with the setup-xcode output isolates caches per
Xcode version; non-macOS jobs get a constant empty suffix.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ekhodzitsky added a commit that referenced this pull request Jul 31, 2026
…ation (#32)

* feat(onnx): single EP-aware session builder for embedding and segmentation

EP wiring was duplicated and hardcoded at three independent ort session
sites: CoreML inlined in the legacy embedder and the powerset segmenter,
and the fbank embedder had no EP at all — so the ExecutionProvider in
PipelineConfig was dead code and selecting Nnapi/Cuda/XnnPack silently
ran on CPU with no signal.

- onnx::build_session_with_ep(path, ep, intra_threads) is now the ONE
  place these sessions are constructed: header validation always runs
  before ort parses the file, the EP is registered in one audited spot,
  and unwired providers (NNAPI/CUDA/XNNPACK, or CoreML without the
  `coreml` feature) log a tracing warning and run on CPU.
- The canonical ExecutionProvider enum (with target-aware auto()) moves
  to polyvoice::onnx — the module that owns session creation — and stays
  re-exported from pipeline_v2::config, so existing imports compile.
- OnnxEmbeddingExtractor::new, FbankOnnxExtractor::new, and
  PowersetSegmenter::with_config gain an `ep` parameter (breaking;
  covered by the in-flight 0.10.0 bump). PowersetSegmenter::new keeps
  its signature and picks the target default. Default behavior is
  byte-identical: CoreML on Apple Silicon for segmentation/legacy
  embedding, plain CPU for the fbank embedder (threading the configured
  EP through the pipelines is the follow-up).
- Module contract + README document the new surface; TDD unit tests
  cover validate-before-build on garbage and the no-panic CPU fallback
  for unwired providers.

* ci: key macOS rust-cache to the selected Xcode version

The runner pool serves images whose latest-stable Xcode differs (26.3 vs
26.6). Build-script outputs cached by rust-cache embed absolute toolchain
paths, so a cache built under one Xcode poisons the link line on a runner
with another (dead -L search paths -> ld: library 'clang_rt.osx' not
found). Keying the cache with the setup-xcode output isolates caches per
Xcode version; non-macOS jobs get a constant empty suffix.

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants