Skip to content

Honor NPZ calibration input in static quantization - #1507

Draft
ssss141414 wants to merge 2 commits into
microsoft:mainfrom
ssss141414:auto-optimize/npz-calibration-load-path
Draft

ssss141414 wants to merge 2 commits into
microsoft:mainfrom
ssss141414:auto-optimize/npz-calibration-load-path

Conversation

@ssss141414

@ssss141414 ssss141414 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a reusable NPZ-backed ORT calibration reader on top of the existing validated InputDataDataset
  • honor calibration_load_path in static QDQ quantization before task-specific or random fallback
  • document the NPZ contract and cover sample limiting, invalid limits, rewind, validation, and end-to-end static quantization

Why

Static quantization accepted calibration_load_path in configuration but did not consume it. For the Wav2Vec2 optimization demo this silently selected random calibration, which was not representative of speech and failed the declared tensor-quality gate.

Reproduction

$env:UV_DEFAULT_INDEX = "https://packagefeedproxy.microsoft.io/pypi/simple"
$env:PYTHONPATH = (Resolve-Path .\src).Path
..\.venv\Scripts\python.exe -m pytest tests\unit\datasets\test_input_data.py tests\unit\test_quant_passes.py -q
..\.venv\Scripts\python.exe -m pytest tests\unit\packaging\test_wheel_install.py -q

The immutable end-to-end replay is in demo/deliveries/v2/bundle: run repro.ps1 to verify hashes, WinML 0.4.0, and exact PR HEAD 828fce6dea347360338307a6d863d13edb78a5ef before rebuilding. repro-run.ps1 is the underlying clean public-CLI replay.

Validation

  • 57 focused unit tests passed.
  • 2 packaging/wheel tests passed with the required corporate package mirror.
  • git diff --check origin/main...HEAD passed.
  • Full unit suite collected 10,647 tests and reached 83%; it was terminated by a native windowsml access violation while tests/unit/session/conftest.py initialized the EP catalog. This is outside the changed calibration path. The two packaging failures observed before termination were independently rerun with the corporate mirror and passed.
  • Two clean public WinML rebuilds produced byte-identical W8A16 artifacts.
  • Delivery receipt status: validated; champion SHA-256 316802bd3f3912fa1df24c12181555a98834c1a1efaf998c700e59171f789a92.

Measured result

On Snapdragon X QNN NPU, burst mode and graph finalization mode 3:

  • speech-calibrated baseline p50: 8495.1555 ms
  • optimized leader p50: 32.5255 ms
  • mean paired gain: 99.6151%
  • 95% CI: [99.5989%, 99.6313%]
  • protocol: four sessions per side, 5 warmups + 30 timed iterations, paired A/B/B/A/A/B/B/A order
  • correctness/tensor gates: pass
  • task quality: provisional because the frozen speech windows do not have emotion-regression labels

Complexity review

Fallback seven-rung review (Ponytail unavailable): Lean already. Ship. Net removable lines: 0. The implementation reuses existing loading, validation, dtype conversion, batching, and sample slicing; the new class is only the ORT CalibrationDataReader adapter required for get_next and rewind. No dependency, option, or model-specific path was added.

Risks

  • NPZ keys must match model input names; existing dataset validation reports mismatches.
  • Calibration sample limiting preserves current dataset batching semantics.
  • Detail profiling fell back to basic attribution for the multi-partition graph, so hardware/memory/DRAM counters are unavailable; no such counters are inferred.

Rollback

Revert commits 828fce6dea347360338307a6d863d13edb78a5ef and c8c8ad2a5183159a45e48dc5ae1ab200b9fcb453. Static quantization will return to task-specific/random calibration fallback, and callers relying on calibration_load_path will again have that configuration ignored.

Review state

  • Graph Scout: NO_MATERIAL_OMISSION
  • Complexity review: complete via documented fallback
  • First Check-in Reviewer findings resolved: NPZ contract documented, non-positive sample limits rejected, and immutable delivery v2 binds and verifies the exact PR implementation
  • Final Check-in Reviewer: READY_FOR_CHECK_IN with no blocking findings
  • All nine hosted PR checks passed at HEAD 828fce6dea347360338307a6d863d13edb78a5ef
  • PR intentionally remains Draft; do not merge or mark ready without explicit approval

This change was discovered while using the auto-optimize skill on audeering/wav2vec2-large-robust-12-ft-emotion-msp-dim.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant