Skip to content

Fix OpenVINO Matcher Model on XPU and Remove SAM-HQ-Tiny as default#870

Open
rajeshgangireddy wants to merge 22 commits intoopen-edge-platform:mainfrom
rajeshgangireddy:fixes/minor_fixes_01
Open

Fix OpenVINO Matcher Model on XPU and Remove SAM-HQ-Tiny as default#870
rajeshgangireddy wants to merge 22 commits intoopen-edge-platform:mainfrom
rajeshgangireddy:fixes/minor_fixes_01

Conversation

@rajeshgangireddy
Copy link
Copy Markdown
Contributor

@rajeshgangireddy rajeshgangireddy commented Mar 19, 2026

Pull Request

Description

Matcher's openvino model wasn't working as expected on XPU. There were a few small issues and a major one : SAM-HQ-TINY which was our default decoder doesn't work as expected as an OpenVINO model.
The model doesn't produce useful masks and the output is non-deterministic as well - same images gives different masks with non-negligible differences. On CPU, the model works deterministically but without great accuracy.

In this PR :

  • Remove SAM-HQ-Tiny as the default model. Now the default is SAM-HQ-Base
  • Expose the Large variant of SAM-HQ
  • Make fixes for OpenVINO model for Matcher
  • Add a script to evalutate performance of different combinations of encoders and decoders here: library/tools/benchmark_variants.py
  • Add a notebook with OpenVINO Matcher Model

TODO

  • Remove library/tools/benchmark_variants.py if it's not useful
  • Make sure application is working fine
  • Clean script files which are not needed.

Type of Change

  • feat - New feature
  • 🐞 fix - Bug fix
  • 📚 docs - Documentation
  • ♻️ refactor - Code refactoring
  • 🧪 test - Tests
  • 🔧 chore - Maintenance

Related Issues

Breaking Changes


Examples

Screenshots

But masks with B60 are not working as expected.
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
…da, xpu,cpu

-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
…da, xpu,cpu

-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
…s documentation and codebase

-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
…ommit

- Remove debug_ov_gpu.py, openvino_simple.py (diagnostic scripts)
- Remove examples/assets/coco/masks_comparison.png (debug artifact)
- Move benchmark_variants.py to tools/benchmark_variants.py with updated usage
- Add tools/__init__.py and configure ruff per-file-ignores for tools/
- Fix import warnings at top-level in predictor.py (PLC0415)
- Fix unused unpacked variables in benchmark_variants.py (RUF059)
- Add noqa to pre-existing SLF001/PLR6104 in predictor.py
- Add markdownlint ignores for .venv, cuda, xpu, node_modules directories
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
…limitation

-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
@rajeshgangireddy rajeshgangireddy marked this pull request as ready for review March 20, 2026 15:09
Copilot AI review requested due to automatic review settings March 20, 2026 15:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates Instant Learn’s SAM-HQ model defaults and improves the Matcher OpenVINO export/runtime path to address XPU/GPU issues, while updating API/UI defaults, tests, docs, and adding developer benchmarking artifacts.

Changes:

  • Switch default SAM-HQ decoder from SAM-HQ-tiny to SAM-HQ-base, add SAM-HQ-large, and deprecate SAM-HQ-tiny.
  • Rework Matcher export/inference graph behavior for ONNX/OpenVINO (static shapes, output naming fixes, export-specific prompt/mask paths, XPU runtime fixes).
  • Update app/backend + UI defaults/tests/docs and add benchmarking scripts + an OpenVINO export notebook.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
library/tools/benchmark_variants.py Adds a dev benchmark script for encoder/decoder combinations across PyTorch/OpenVINO.
library/tools/benchmark_matcher_variants.py Adds an additional benchmark script (currently overlaps with the above).
library/tools/init.py Introduces a tools package marker/docstring for dev utilities.
library/tests/unit/scripts/test_benchmark.py Updates unit tests to use SAM-HQ-base as the benchmark backbone default.
library/tests/integration/models/test_model_integration.py Updates integration tests to use SAM-HQ-base instead of SAM-HQ-tiny and minor formatting fixes.
library/tests/integration/models/test_matcher_export.py Updates export/inference integration tests for OpenVINO static shapes and new default SAM.
library/src/instantlearn/utils/constants.py Adds SAM_HQ_BASE/SAM_HQ_LARGE and updates model map metadata; marks SAM_HQ_TINY deprecated.
library/src/instantlearn/utils/args.py Changes benchmark CLI default SAM from SAM-HQ-tiny to SAM-HQ-base.
library/src/instantlearn/models/soft_matcher/soft_matcher.py Changes default SAM for SoftMatcher to SAM-HQ-base.
library/src/instantlearn/models/per_dino/per_dino.py Changes default SAM for PerDino to SAM-HQ-base.
library/src/instantlearn/models/matcher/prompt_generators.py Adds an export-optimized prompt selection path to reduce ONNX/OpenVINO graph complexity.
library/src/instantlearn/models/matcher/matcher.py Adjusts Matcher defaults and improves ONNX/OpenVINO export reliability (static reshape, output renaming, FP16 compression option).
library/src/instantlearn/models/grounded_sam/grounded_sam.py Changes default SAM for GroundedSAM to SAM-HQ-base.
library/src/instantlearn/components/sam/predictor.py Adds SAM-HQ-base/large support, deprecation warning for tiny, XPU-safe mask decoder patching, and improved device/dtype syncing.
library/src/instantlearn/components/sam/decoder.py Adds export-safe prompt/mask paths for fixed-shape ONNX/OpenVINO and adjusts mask tensor handling.
library/pyproject.toml Adds ruff per-file ignores for tools/notebooks to support dev workflows.
library/examples/matcher_openvino_export.ipynb Adds a notebook demonstrating Matcher → OpenVINO export and CPU inference/visualization.
library/docs/02-quick-start.md Updates quick start example to use SAM-HQ-base.
library/docs/01-introduction.md Updates supported SAM model list to base/large/HQ (removes tiny).
library/README.md Updates README examples/model tables/memory notes to base/large/HQ and changes defaults.
application/ui/src/test-utils/mocks/mock-model.ts Updates mocked model config default sam_model to SAM-HQ-base.
application/ui/src/setup-test.ts Updates UI test fixtures default sam_model to SAM-HQ-base.
application/ui/src/features/prompts/models/model-toolbar/model-configuration/model-configuration-dialog.test.tsx Updates UI test expectations for decoder selection (Tiny → Base).
application/ui/src/features/prompts/models/model-toolbar/model-configuration/model-configuration-dialog.component.tsx Updates decoder dropdown options (adds Base/Large, removes Tiny).
application/ui/src/features/prompts/models/api/use-get-models.ts Updates default UI model configurations to SAM-HQ-base.
application/backend/tests/unit/runtime/core/components/models/test_openvino_model.py Updates backend unit tests for OpenVINO handler output-port based inference and mask typing expectations.
application/backend/tests/unit/runtime/core/components/factories/test_model.py Updates backend factory tests to use SAM-HQ-base.
application/backend/tests/unit/api/endpoints/test_models.py Updates API endpoint tests default sam_model payloads to SAM-HQ-base.
application/backend/app/runtime/core/components/models/openvino_model.py Improves OpenVINO runtime handler (static reshape, infer request usage, output-port mapping, input resizing).
application/backend/app/domain/services/schemas/processor.py Updates allowed SAM models and defaults to Base; adds Large to allowed set.
application/backend/app/api/endpoints/models.py Updates OpenAPI examples/defaults from SAM-HQ-tiny to SAM-HQ-base.
README.md Updates top-level supported SAM model list to base/large/HQ (removes tiny).

Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
- decoder.py: update _pad_outputs docstring to reflect float32 dtype
- openvino_model.py: apply consistent binarization (> 0.5) in all paths
- benchmark: add batch dimension, use named output ports, fix usage text
- Remove duplicate benchmark_variants.py (kept benchmark_matcher_variants.py)
-e
Signed-off-by: rajeshgangireddy <rajesh.gangireddy@intel.com>
@LenaRudaya LenaRudaya linked an issue Mar 26, 2026 that may be closed by this pull request
2 tasks
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.

[Task]: OpenVINO Matcher Model on Intel GPUS

2 participants