Skip to content

Add strict validation for RVC4 quantization overrides - #288

Open
rolandocortez wants to merge 2 commits into
mainfrom
feat/rvc4-encoding-strictness
Open

Add strict validation for RVC4 quantization overrides#288
rolandocortez wants to merge 2 commits into
mainfrom
feat/rvc4-encoding-strictness

Conversation

@rolandocortez

@rolandocortez rolandocortez commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add opt-in rvc4.strict_quantization_overrides validation, disabled by default.
  • Reject activation and parameter encoding names that are not present in the effective ONNX model before invoking SNPE.
  • Validate overrides from both rvc4.encodings and raw --quantization_overrides arguments.
  • Reject ambiguous multiple override sources in strict mode.
  • Preserve the existing behavior when strict mode is disabled.

Qualcomm SNPE 2.41 accepts extra activation/parameter entries in quantization overrides without failing, and its --strict option does not apply to quantization override name matching. The validation is therefore implemented on the ModelConverter side.

Strict matching uses subset semantics: missing encodings are allowed; only provided names that do not exist in the model are rejected.

Testing

  • 18 passedtests/unit/test_rvc4_encoding_strictness.py
  • 3 passedtests/conversion/test_rvc4_encodings.py
  • Validated with SNPE 2.41.0 / ONNX 1.18.0

Summary by CodeRabbit

  • New Features

    • Added optional strict validation for RVC4 quantization overrides.
    • When enabled, checks override names against ONNX activation and parameter names.
    • Rejects unknown or ambiguous overrides before conversion.
    • Strict validation is disabled by default and skipped for FP16 conversions.
  • Bug Fixes

    • Prevents invalid quantization overrides from reaching Qualcomm conversion tools.
    • Reports unsupported validation for non-ONNX inputs when strict mode is enabled.

@rolandocortez
rolandocortez requested a review from a team as a code owner August 28, 2026 12:36
@rolandocortez
rolandocortez requested review from kozlov721 and removed request for a team August 28, 2026 12:36
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 672e6045-8ba0-4420-9519-a4a1ffa8cd93

📥 Commits

Reviewing files that changed from the base of the PR and between 9ff0d11 and 0f254ac.

📒 Files selected for processing (1)
  • tests/conversion/test_rvc4_encodings.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The RVC4 exporter now supports optional strict quantization-override validation. It checks override names against the effective ONNX model and rejects invalid or ambiguous sources before Qualcomm tooling.

Changes

RVC4 quantization validation

Layer / File(s) Summary
Override validation flow
configs/defaults.yaml, modelconverter/utils/config.py, modelconverter/packages/rvc4/exporter.py
Adds the strict_quantization_overrides option. The exporter parses file-based and raw override sources and validates non-FP16 conversions before Qualcomm tooling.
ONNX namespace validation
modelconverter/utils/encodings.py, tests/unit/test_rvc4_encoding_strictness.py
Collects activation and parameter names from the top-level ONNX graph without loading external data. Validation reports unknown names by encoding group.
Validation policy coverage
tests/unit/test_rvc4_encoding_strictness.py, tests/conversion/test_rvc4_encodings.py
Tests strict and non-strict modes, FP16 behavior, non-ONNX inputs, empty names, source ambiguity, sorted errors, and validation against the final effective model.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 0f254

The PR adds opt-in validation for RVC4 quantization overrides while preserving existing behavior by default; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: klemen1999, kozlov721, n950

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant RVC4Exporter
  participant EncodingUtilities
  participant EffectiveONNXModel
  participant QualcommTooling
  User->>RVC4Exporter: configure quantization overrides
  RVC4Exporter->>EncodingUtilities: parse override source
  EncodingUtilities->>EffectiveONNXModel: collect activation and parameter names
  EffectiveONNXModel-->>RVC4Exporter: return model namespaces
  RVC4Exporter->>RVC4Exporter: validate override names
  RVC4Exporter->>QualcommTooling: invoke conversion if validation passes
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding opt-in strict validation for RVC4 quantization overrides.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rvc4-encoding-strictness

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.85039% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.04%. Comparing base (23d0e9f) to head (0f254ac).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
modelconverter/packages/rvc4/exporter.py 89.09% 6 Missing ⚠️
tests/conversion/test_rvc4_encodings.py 93.54% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #288       +/-   ##
===========================================
+ Coverage   79.09%   99.04%   +19.94%     
===========================================
  Files          84       85        +1     
  Lines        6875     7126      +251     
===========================================
+ Hits         5438     7058     +1620     
+ Misses       1437       68     -1369     
Flag Coverage Δ
conversion 44.33% <38.18%> (?)
unit 79.56% <83.07%> (+0.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@klemen1999
klemen1999 requested a review from N950 August 28, 2026 12:59
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