feat(modelkit): add swin2sr support and canonical cpu recipe - #1204
Draft
fangyangci wants to merge 1 commit into
Draft
feat(modelkit): add swin2sr support and canonical cpu recipe#1204fangyangci wants to merge 1 commit into
fangyangci wants to merge 1 commit into
Conversation
fangyangci
enabled auto-merge (squash)
July 24, 2026 05:49
ssss141414
marked this pull request as draft
August 15, 2026 20:44
auto-merge was automatically disabled
August 15, 2026 20:44
Pull request was converted to draft
ssss141414
force-pushed
the
fangyangci/add-caidas-swin2sr-support
branch
from
August 15, 2026 21:23
37a1094 to
69847a8
Compare
Contributor
|
APPROVE Independent post-PR review completed for exact head Scope and engineering review
Independent validation
Quality and shipment gates
Engineering observations: fp16 is slower on the tested CPU; CPU/VitisAI static-rule coverage and optimized-node mapping gaps remain explicitly reported without support inference. These are non-blocking. Owner routes: none. |
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.
Summary
Adds canonical CPU fp32/fp16 recipes for
caidas/swin2SR-classical-sr-x2-64image-to-image super-resolution and fixes shared compare-mode task validation so the model can reach tensor comparison without adding a broad image-to-image benchmark evaluator. The shipped Effort/Outcome is L2, and the highest Goal verdict is L2 PASS with full planned tuple coverage and no deferred tuples. The fp16 artifact preserves numeric parity but is slower than fp32 on the tested CPU host.Model metadata
What the model does
Upscales an RGB image by 2x using a Swin Transformer V2 restoration backbone and pixel-shuffle reconstruction head.
caidas/swin2SR-classical-sr-x2-64@cee1c923c6a37361c6e5650b65dcf4be821e5d52, its model card/config, and Swin2SR paper arXiv:2209.11345v1 (verified).Primary user stories
pipeline_tag=image-to-image(verified).verified).mapped).Supported tasks
image-to-imageacross the checkpoint, Transformers, Optimum ONNX, and WinML surfaces. Evidence: checkpointpipeline_tag,Swin2SRForImageSuperResolution, and the current-main WinML inspect/recipe-free build (verified).Model architecture
verified).Validation and support evidence
1. Baseline
24cccfb23d6e3c3b93ae9bb94399c326cee8ecea; WinML0.3.0.pixel_valuesfloat32[1,3,64,64]toreconstructionfloat32[1,3,128,128].image-to-image,AutoModelForImageToImage, opset 17, fixed float32[1,3,64,64]input, eager Transformers attention, hierarchy tags, GELU/highdimRTR-lowdimRTR/MatMul-Add optimizations, no quantization, and no compilation._resolve_taskrejectedimage-to-imageagainst the metric evaluator registry even though compare mode dispatchescompare-tensor; the real Set5 decode and preprocessing had passed.89main-only /2PR-only commits, five changed paths), lacked fp32 coverage and the compare-mode validator fix, and had no acceptance-eligible exact-lock execution. The frozen model identity/profile/source citations were reused; config, build, perf, parity, Eval, Analyze, and quality gates were rerun on the reconstructed final head.feature-extractionandimage-to-image; WinML adds no task registration (VENDOR-ONLY). A direct canonical Optimum model-config import fails upstream because_CAN_RECORD_REGISTRYis unavailable under the repository lock, but supported WinML inspect/config/build paths resolveSwin2srOnnxConfigthroughTasksManagerand are not blocked.2. Goal
3. Outcome
examples/recipes/caidas_swin2SR-classical-sr-x2-64/cpu/cpu/image-to-image_fp32_config.jsonexamples/recipes/caidas_swin2SR-classical-sr-x2-64/cpu/cpu/image-to-image_fp16_config.jsonsrc/winml/modelkit/eval/evaluate.pytests/unit/eval/test_eval.pytests/unit/models/test_swin2sr_support.pyexamples/recipes/README.mdis untouched.swin2sr-001throughswin2sr-011: fixed fp32/fp16 IO contract; hierarchy facts; mode-driven compare dispatch; exact perf and parity behavior; fp16 initializer/size change; component mapping gaps; and bounded static-rule findings._meta-109was reused for explicit provider/device static Analyze with--no-run-unknown-op --no-check-optim; it was not duplicated.fc63c516a5eb68aee6b6df15ac2d7c9585a05646, containing onlycopilot-skills/dev_skill/adding-model-support/model_knowledge/swin2sr.json.4. Per-EP/device/precision results and Functional smoke Eval
Both L0 artifacts are self-contained opset-17 ONNX models with float32
[1,3,64,64]input and float32[1,3,128,128]output. fp32 has 2,096 nodes, 695 initializers (672 FLOAT, 23 INT64), and 70,912,129 bytes. fp16 has 2,098 nodes, 695 initializers (672 FLOAT16, 23 INT64), and 35,854,351 bytes. The tested fp16 CPU path is slower than fp32: mean/p50 increase from 776.928/774.658 ms to 942.144/936.591 ms, throughput falls from 1.29 to 1.06 samples/s, and RSS delta rises from 196.0 to 243.1 MB.L2 numeric comparison:
[1,3,128,128][1,3,128,128]Functional smoke Eval: exactly one final-head FP32 CPU compare Eval was run. No fp16 Eval is claimed.
69847a89be6f7085d003ba08b003eb182cc5f88a;CPUExecutionProvider/ cpu / fp32.eugenesiow/Set5@d8b579a20afde95b4d8ed6bf6383447d33027295, configdata/Set5_LR_x2.tar.gz, memberSet5_LR_x2/baby.png.[100,100,156,156];pixel_valuesfloat32[1,3,64,64], observed range[0.0313725508749485,1.0].reconstructionis[1,3,128,128].5. Delta
Recipe delta from the current-main auto-config:
image-to-image_fp32_config.json_notestrippingimage-to-image_fp16_config.json/quant:null->mode=fp16, samples=10, task=image-to-image, model_id=caidas/swin2SR-classical-sr-x2-64, model_type=swin2sr, fp16_keep_io_types=trueThe fp16
/quantchange declares the required precision while preserving the baseline model, loader, export IO, attention compatibility, optimization, and compile semantics. Both recipes load throughWinMLBuildConfig; the fp32 structure resolves to fp32 and fp16quant.moderesolves to fp16. The change is reducible consistently with the charter, andexamples/recipes/README.mdremains untouched.Code delta:
_resolve_taskinsrc/winml/modelkit/eval/evaluate.pyremains model-task-driven, but skips ordinary metric-registry validation whenmode=comparebecause evaluator dispatch selects the task-agnosticcompare-tensorevaluator. Tests cover the shared resolver/dispatcher/evaluate path and Swin2SR vendor registration/default task without an unused plainwinmlimport.Bug fix explanation:
winml eval --mode comparewith a resolvableimage-to-imagemodel and real input failed before inference with "Task 'image-to-image' is not supported," even though compare mode is tensor comparison._resolve_taskvalidated the resolved model task against the labeled-dataset metric evaluator registry beforeget_evaluator_classcould remap compare mode tocompare-tensor. Therefore a valid HF model task with no metric evaluator was rejected on the wrong registry boundary._resolve_tasknow preserves the resolved model task for HF reference loading and bypasses metric-registry validation only forconfig.mode == 'compare'; evaluator dispatch still selectsTensorSimilarityEvaluatorthroughcompare-tensor.mode=onnxstill rejectsimage-to-image; existing supported tasks resolve in both modes; compare retains the model task and tensor metrics; two-ONNX compare remains task/model-id optional; recipe-owned semantics are not overridden. The intentional change is that compare mode accepts a resolvable task without a labeled-dataset metric evaluator.6. Analyze summary - component level and op level
Both artifacts returned ANALYZE-PARTIAL-SUCCESS (exit meaning: static analysis contains partial/unknown classifications). These are bounded static rule classifications only; they do not establish runtime execution, support, or fallback behavior.
Component-level summary
Expandnodes partial; none unsupportedThe mapping gap is retained: final optimization may remove or rewrite export-scope names, leaving 579 fp32 and 581 fp16 optimized scaffolding nodes without a semantic scope.
Op-level summary
Expandpartial (72 nodes), none unsupportedCPU/cpu and VitisAI/NPU are all-unknown rule-coverage gaps for both artifacts. No runtime support inference is made. This bounded explicit-provider scan follows existing methodology finding
_meta-109.7. Reproduce commands