Skip to content

[AMD] Update QuarkQuantization pass for Quark 0.12#2532

Open
thpereir wants to merge 1 commit into
microsoft:mainfrom
thpereir:quark-0.12-fix
Open

[AMD] Update QuarkQuantization pass for Quark 0.12#2532
thpereir wants to merge 1 commit into
microsoft:mainfrom
thpereir:quark-0.12-fix

Conversation

@thpereir

@thpereir thpereir commented Jun 19, 2026

Copy link
Copy Markdown

Describe your changes

Updates QuarkQuantization to work with AMD Quark 0.12, which introduced two breaking API changes:

ONNX path — calibration reader fix:
Quark 0.12 rejects calibration inputs that are not model inputs. Olive was forwarding the full dataset batch (including label columns like class) to the reader, causing INVALID_ARGUMENT: Invalid input name during calibration — the workflow would complete with exit code 0 but produce no output model. Fixed by passing model_path/io_config to create_calibration_dataloader() so non-input columns are filtered out, matching the pattern already used by OnnxQuantization.

Torch path — API update:

  • revert_model_patching was removed in Quark 0.12 (patching is now reverted internally during export). Removed the import and call.
  • prepare_for_moe_quant is deprecated and raises on transformers>=5. Replaced with preprocess_for_quantization.

Version gating:
Both ONNX and Torch paths now gate on amd-quark>=0.12.0 with a clear ValueError so users get an actionable error message instead of a cryptic ImportError.

Checklist before requesting a review

  • Add unit tests for this change.

  • Make sure all tests can pass.

  • Update documents if necessary.

  • Lint and apply fixes to your code by running lintrunner -a

  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.

    The QuarkQuantization pass now requires amd-quark>=0.12.0. Users on 0.11.x will receive a clear ValueError with an upgrade prompt. The ONNX calibration path and Torch path are updated to work correctly with the 0.12 API.

(Optional) Issue link

@thpereir thpereir marked this pull request as ready for review June 22, 2026 19:59
Copilot AI review requested due to automatic review settings June 22, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates Olive’s QuarkQuantization pass to align with AMD Quark 0.12 behavior and APIs across both ONNX and Torch backends.

Changes:

  • Updated Torch quantization integration to use Quark 0.12 APIs (preprocess_for_quantization) and removed now-obsolete patch reversion.
  • Updated ONNX calibration dataloader construction to pass model_path/io_config, filtering non-model-input columns (to avoid Quark 0.12 invalid input errors).
  • Raised the ONNX-side minimum Quark version check to >=0.12.0 and updated log/docs to reference 0.12.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
olive/passes/quark_quantizer/torch/quark_torch_quantization.py Migrates Torch quantization flow to Quark 0.12 APIs and adjusts the quantize/freeze/export sequence accordingly.
olive/passes/quark_quantizer/quark_quantization.py Updates Quark 0.12 messaging/version gating and fixes ONNX calibration dataloader creation to filter non-input columns.

Comment thread olive/passes/quark_quantizer/quark_quantization.py
@xiaoyu-work

Copy link
Copy Markdown
Collaborator

We can also add a version pin here: https://github.com/microsoft/Olive/blob/main/olive/olive_config.json#L601-L619

Fix the ONNX calibration path: Quark 0.12 rejects extra inputs in the
calibration data reader, so pass model_path/io_config to filter out
dataset labels (e.g. `class`) that are not model inputs.

Update the Torch path for the Quark 0.12 API: replace the removed
`revert_model_patching` and the deprecated `prepare_for_moe_quant`
(which now raises on transformers>=5) with `preprocess_for_quantization`.

Bump the required amd-quark version to >=0.12.0.
@thpereir

Copy link
Copy Markdown
Author

We can also add a version pin here: https://github.com/microsoft/Olive/blob/main/olive/olive_config.json#L601-L619

Good call, updated

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.

3 participants