Add MGP-STR (alibaba-damo/mgp-str-base) image-to-text task support#952
Add MGP-STR (alibaba-damo/mgp-str-base) image-to-text task support#952ssss141414 wants to merge 2 commits into
Conversation
Adds Effort-L1-light registration so MGP-STR scene-text-recognition models resolve under the user-facing 'image-to-text' task label. The vendor MgpstrOnnxConfig (Optimum) already exposes the 3-head outputs (char_logits, bpe_logits, wp_logits) correctly but is registered only under feature-extraction. This PR adds a task-label alias plus MODEL_CLASS_MAPPING binding to MgpstrForSceneTextRecognition. Files: - src/winml/modelkit/models/hf/mgp_str.py: MgpstrImage2TextOnnxConfig subclass (58 lines) - src/winml/modelkit/models/hf/__init__.py: 3-line wiring - examples/recipes/alibaba-damo_mgp-str-base/image-to-text_config.json: recipe (49 lines) - examples/recipes/README.md: catalog row - research/adding-model-support/model_knowledge/mgp_str.json: mgp_str-004 finding Goal-ladder (alibaba-damo/mgp-str-base @ image-to-text @ fp32 @ cpu): - L0 PASS: build 83.7s, 374 nodes, 564.5 MB optimized - L1 PASS: avg=100.76ms, P90=123.26ms, 9.92 samples/sec (20 iters) - L2 PASS: cosine vs PyTorch reference all 3 heads >=0.999999 (max-abs <3e-4) - L3 CLI-BLOCKED: image-to-text task has no default dataset (same as nlpconnect/vit-gpt2-image-captioning per known limitation) Step 1b verification: baseline 'winml build' on main fails with 'mgp-str doesn't support task image-to-text' (real engineering delta, not catalog-only).
Reviewer verification: OV cpu / gpu / npu — branch \shzhen/add-mgp-str-base\Commands\\powershell configuv run winml config -m alibaba-damo/mgp-str-base --task image-to-text -o temp/verify_pr952_mgpstr_config.json build (OV CPU, fp32, using recipe)uv run winml build -c examples/recipes/alibaba-damo_mgp-str-base/image-to-text_config.json -m alibaba-damo/mgp-str-base -o temp/verify_pr952_mgpstr_build --ep openvino --device cpu --precision fp32 --no-quant --no-compile --rebuild perf — cpu / gpu / npu (from built ONNX, 5 iters + 2 warmup)uv run winml perf -m temp/verify_pr952_mgpstr_build/model.onnx --ep openvino --device cpu --iterations 5 --warmup 2 --skip-build -f json evaluv run winml eval -m alibaba-damo/mgp-str-base --task image-to-text --device cpu --ep openvino --samples 1 Results
Notes:
|
|
Validation results (2026-06-25) for PR #952 on this Windows ARM64 host. Scope
Main branch baseline (before PR)
PR #952 branch
Conclusion
|
|
ADDENDUM: main branch baseline (NO support) On current \main\ @ HEAD: Conclusion: This PR adds \image-to-text\ task support (via \MgpstrImage2TextOnnxConfig\ alias + \MODEL_CLASS_MAPPING\ binding). Without this PR, mgp-str only works under \eature-extraction. The engineering delta is real (not catalog-only). All OV devices now pass config/build/perf validation. |
|
the exported model are same as the current supported task? |
Cover the MgpstrImage2TextOnnxConfig alias weightlessly via resolve_io_specs: registration for mgp-str/image-to-text, single pixel_values input, the 3 granularity heads (char_logits, bpe_logits, wp_logits), and the MODEL_CLASS_MAPPING -> MgpstrForSceneTextRecognition binding. 4 passed.
reviewer verdict — APPROVE (draft; awaiting human ready-promotion)Independent re-march of the checklist against the pushed producer fix (
Coverage scope (honest annotation): verified at the OnnxConfig-contract / unit-test level. Verdict: APPROVE. Left as draft per contributor request — promote with |
reviewer verdict — CORRECTION + real Goal-ladder marchAs with #951, my earlier verdict here only cited a pytest unit-test run — that is NOT the Goal ladder. I have now independently re-marched it on this host (CPU / CPUExecutionProvider).
Op-coverage note (tester finding, worth the learner): during L0 the build's coverage-analysis stage logged Coverage: Plus prior unit-test contract coverage (4 passed). Verdict: APPROVE (draft; promote with |
ssss141414
left a comment
There was a problem hiding this comment.
Reviewer verdict (independent second-host re-verification): APPROVE
Role note: this verdict is posted as a review comment because GitHub disallows formally approving one's own PR. The re-verification is independent of the original submission in the sense that it ran on a different host (with a DirectML GPU) from a clean rebuild.
- Value fidelity: the appended EP-coverage section adds DML rows only; it does not alter or restate the original CPU numbers as if they were mine. The CPU latency difference (329.70ms vs the original 100.76ms) is explicitly attributed to different hardware.
- Load-bearing check re-run: L2 numerical parity (the check that would catch a broken export) PASSES on both CPU and DML — all three heads cosine≈1.0 with argmax match. This is the check that matters; it holds on both EPs.
- L0/L1 re-run: build converges, both EPs run to completion. Einsum
a3_moduleops confirmed running on DML (finding's EP-support caveat resolved).
Coverage annotation:
- reachable-verified:
CPUExecutionProvider,DmlExecutionProvider - deferred (host-limited, not a defect):
QNNExecutionProvider/NPU (no NPU on this host),OpenVINOExecutionProvider(present but not exercised for this model)
Terminal state: APPROVE · coverage: partial (CPU+DML verified; QNN/NPU + OpenVINO deferred).
ssss141414
left a comment
There was a problem hiding this comment.
Reviewer verdict — OpenVINO EP-coverage completion (2026-07-10)
Following up my earlier CPU+DML verdict: I mis-labeled the non-CPU/DML EPs as "host-blocked". This host (Intel Lunar Lake) exposes a full Intel accelerator stack through the downloadable OpenVINOExecutionProvider v1.8.80.0. I re-ran the EP flow on all three OpenVINO device targets.
MGP-STR (#952) — APPROVE (strengthened). L1 PASS on OpenVINO NPU, GPU, and CPU. OpenVINO GPU is the fastest EP of all for this model (10.35ms / 96.62 samples/sec, vs DML 106ms). NPU 15.02ms. The 3 a3_module Einsum ops run correctly on NPU+GPU.
Reachable-EP coverage now verified: CPU + DML(GPU) + OpenVINO(NPU/GPU/CPU) — all PASS. Only N/A: QNN (Qualcomm — this is Intel silicon).
Remaining gap (non-blocking): quantized w8a16 OpenVINO NPU path (fp32 used here to match the artifact). No code changes requested.
## Summary
Adds Effort-L1-light registration so MGP-STR scene-text-recognition models resolve under the user-facing
image-to-texttask label. The vendorMgpstrOnnxConfig(Optimum) already exposes the 3-head outputs (char_logits,bpe_logits,wp_logits) correctly, but is registered ONLY underfeature-extraction. This PR adds a task-label alias +MODEL_CLASS_MAPPINGbinding toMgpstrForSceneTextRecognition(the head-bearing class — MGP-STR is NOT a generic Vision2Seq).Files changed (5)
src/winml/modelkit/models/hf/mgp_str.py(NEW, 58 lines) —MgpstrImage2TextOnnxConfig(MgpstrOnnxConfig)subclasssrc/winml/modelkit/models/hf/__init__.py— 3-line wiringexamples/recipes/alibaba-damo_mgp-str-base/image-to-text_config.json(NEW, 49 lines) — recipeexamples/recipes/README.md— catalog rowresearch/adding-model-support/model_knowledge/mgp_str.json—mgp_str-004post-mortem findingGoal-ladder verdict
alibaba-damo/mgp-str-base @ image-to-text @ fp32 @ cpuimage-to-texttask has no default dataset (same as vit-gpt2)Step 1b verification — real engineering vs catalog-only
winml config --task image-to-text(recipe is autoconf-faithful)mgp-str doesn't support task image-to-text for the onnx backend.→ real engineering delta, NOT catalog-only.Known gotchas
architectures: ['MGPSTRModel']but currenttransformersexportsMgpstrModel(CamelCase rename). Without--task image-to-textexplicit,winml inspect/config/buildfail withCannot import MGPSTRModel from transformers. CLI robustness gap separate from this PR.a3_moduleheads are non-fatal on CPU.Verification
EP-coverage update — DirectML validated on a second host (2026-07-10)
The original submission was verified on a host without a DirectML GPU, so the DML EP was left deferred (
not_yet_tested_on: @ dml-gpu (host-blocked)in themgp_strfinding). A second contributor re-ran the full Goal-ladder on a machine that exposesonnxruntime.get_available_providers() == ['DmlExecutionProvider', 'CPUExecutionProvider'], closing that deferred coverage. No code change — this is a pure EP re-verification of the existing L1-light contribution.Per-(EP, device) matrix —
alibaba-damo/mgp-str-base @ image-to-text @ fp32pixel_values[1,3,32,128]→char[1,27,38]/bpe[1,27,50257]/wp[1,27,30522], 564.5 MB external data co-locatedNo dataset provided and no default for task image-to-textNotes (honesty): The L1 CPU latency here (329.70ms) differs from the original submission's 100.76ms because it is different hardware — both are valid, they are not the same machine. The DML rows are net-new coverage, not a restatement of the original numbers. The 3
a3_moduleEinsum ops flagged as possibly EP-unsupported in the finding run correctly on DML; the warnings are parquet-coverage-rule gaps, not runtime failures.Coverage after this update: reachable-verified = CPU + DML. Still deferred = QNN/NPU (no NPU on this host) and OpenVINO (EP present but not exercised for this model).
Reproduce DML:
OpenVINO EP matrix — Intel NPU + GPU + CPU (2026-07-10, follow-up)
Correction to the earlier EP-coverage note: this host is an Intel Core Ultra 7 258V (Lunar Lake) with an Intel AI Boost NPU, an Intel Arc 140V GPU, and the CPU.
onnxruntime-windowsmlauto-installs the downloadable OpenVINOExecutionProvider v1.8.80.0, which targets NPU / GPU / CPU. (Stockonnxruntime.get_available_providers()only lists DML+CPU — the OpenVINO EP is registered through the Windows ML EP infrastructure and must be driven viawinml perf --ep openvino.) So QNN/NPU was never the right "deferred" label here — the NPU is Intel, reached through OpenVINO, and it works.L1 perf —
alibaba-damo/mgp-str-base @ image-to-text @ fp32(20 iters, warmup 5)OpenVINO GPU is the fastest EP for this model — 10.35ms vs DML 106ms vs plain-CPU 330ms. The 3
a3_moduleEinsum ops run correctly on both NPU and GPU. fp32 was used to match the pre-built artifact (the CLI's auto NPU precision is w8a16, which would need a quantized rebuild).Full EP coverage on this host: CPU, DML(GPU), OpenVINO(NPU/GPU/CPU) — all PASS. Only genuinely N/A: QNN (this is Intel silicon, not Qualcomm).
Reproduce: