Fix quantization P0 bugs#680
Merged
Merged
Conversation
timenick
reviewed
May 20, 2026
Collaborator
timenick
left a comment
There was a problem hiding this comment.
Five findings — none blocking, but worth addressing before merge. The biggest one is that the new error message redirects users to --help, but --help doesn''t yet mention auto as an accepted value, so users hitting the BadParameter still won''t know how to fix it.
vortex-captain
approved these changes
May 20, 2026
timenick
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Title
fix(quantize/eval): validate --precision, stream default image dataset, support pixel_mask paddingPR Description
Summary
Three independent fixes bundled together — two are user-reported bugs, one is a side-fix found while validating object detection.
Changes
1. Reject invalid
--precisionvalues (fixes #555)Previously,
winml quantize --precision banana(or any unrecognized string) silently fell through touint8/uint8defaults and reported "Success!", masking user typos likew4a16orfp64._resolve_quant_typesnow raisesclick.BadParameterfor any precision that is notNone,"auto"(case-insensitive), or a value accepted byis_quantized_precision. The error message lists the accepted forms.2. Stream the default image calibration dataset (fixes #433)
The default calibration dataset (
timm/mini-imagenet) was downloading the entire training split (~5 GB) just to pull 10 calibration samples.ImageDataset._get_default_datasetnow setsstreaming=Trueby default, and the shared_load_and_samplehelper takes the streaming path whenstreamingis enabled andmax_samplesis set (streaming without a sample cap would be strictly worse than a bulk download, so it falls back automatically).ObjectDetectionDatasetreuses the same helper, eliminating duplicated load/sample logic.Verified: with the HF cache cleared, running
winml quantize -m resnet-50 --task image-classification --model-name microsoft/resnet-50 --samples 10leavesdatasets--timm--mini-imagenetat 0 MB on disk.3. Support
pixel_maskinput for DETR-family object detectionSome object detection exports (DETR, etc.) declare a
pixel_maskinput alongsidepixel_values, which the HF image processor only populates meaningfully when padding to a fixed canvas.WinMLObjectDetectionEvaluator.prepare_pipelinenow detects this case and switches the processor to aspect-preserving resize (shortest_edge/longest_edge) +pad_size+do_pad=True. Models withoutpixel_maskkeep the previous exact-resize, no-padding behavior.Tests
TestQuantizePrecisionValidation— parametrized overbanana,w4a16,int4,fp64; assertsquantize_onnxis never invoked.TestPreparePipeline::test_pixel_mask_path_enables_paddingandtest_no_pixel_mask_path_disables_padding— cover both branches with a sentinel to prove the wrong branch did not run. Usesmonkeypatchfor the parent-classprepare_pipelinestub so the override is reverted on teardown.All 84 affected unit tests pass.
Manual verification
winml quantize -p banana→BadParameter: 'banana' is not a supported quantization precision. Expected: auto | int8 | int16 | w{x}a{y} ...datasets--timm--mini-imagenet= 0.0 MB on disk; only 10 examples flowed throughMap/Aligning the labels