Enable graph capture for WebGPU models and DML continuous decoding tests - #2099
Merged
Conversation
qjia7
commented
Apr 24, 2026
Contributor
- Add enable_graph_capture flag to model download config in _test_utils.py
- When enable_graph_capture=True and device=webgpu, pass enable_webgpu_graph=true to the model builder so generated models have enableGraphCapture=1
- Enable graph capture for qwen-2.5-0.5b model (used by guidance tests)
- Remove #if !USE_DML guard from multi-turn guidance tests since PR [WebGPU] Support continuous decoding (RewindTo) with graph capture #2083 fixed RewindTo for DML (DML always uses graph capture/static mask)
- Add enable_graph_capture flag to model download config in _test_utils.py - When enable_graph_capture=True and device=webgpu, pass enable_webgpu_graph=true to the model builder so generated models have enableGraphCapture=1 - Enable graph capture for qwen-2.5-0.5b model (used by guidance tests) - Remove #if !USE_DML guard from multi-turn guidance tests since PR #2083 fixed RewindTo for DML (DML always uses graph capture/static mask)
Test RewindTo with the qwen-2.5 model. Exercises the static mask rewind path if the EP supports it (DML by default, WebGPU with enableGraphCapture=1 set by _test_utils.py), otherwise falls back to the dynamic mask path. Guarded by TEST_QWEN_2_5, skipped when the model is not available. Verified: RewindQwen25CAPI passes (full rewind + partial rewind).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates test infrastructure to generate WebGPU models with graph capture enabled (via model-builder extra options) and expands continuous decoding (RewindTo) test coverage to include the qwen-2.5 test model, aligning with recent backend fixes.
Changes:
- Extend
test/python/_test_utils.pymodel download configuration to carry a per-model “graph capture” flag and passenable_webgpu_graph=truewhen building WebGPU models. - Enable WebGPU graph capture for the qwen-2.5-0.5b model used by guidance-related tests.
- Add a new C API test that validates
RewindTobehavior on the qwen-2.5 model, and adjust DML-related guards in guidance tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/python/_test_utils.py | Adds a per-model graph-capture flag and wires it to the model builder via --extra_options enable_webgpu_graph=true for WebGPU builds. |
| test/guidance_tests.cpp | Removes the DML continuous-decoding guard from the (currently disabled) multi-turn guidance tests. |
| test/c_api_tests.cpp | Adds a qwen-2.5-based RewindTo regression test intended to exercise static-mask rewind when supported. |
- Fix GetModelPath to cache per model_type using unordered_map instead of a single static string. Previously, whichever model resolved first would be returned for all subsequent calls regardless of model_type. - Add comment clarifying enable_graph_capture currently only affects WebGPU EP. - Disable RewindQwen25CAPI for CUDA builds (USE_CUDA guard) pending investigation. - Use value check (#if !USE_CUDA) instead of #if !defined(USE_CUDA) since CMake always defines USE_CUDA as 0 or 1. Verified: All 29 CAPITests pass (20 passed, 9 skipped).
Address reviewer feedback in test infra and coverage updates. - Keep enable_graph_capture generic, remove default arg, and pass graph_capture explicitly from callers. - Move WebGPU-specific behavior note to implementation site where enable_webgpu_graph is applied. - Clarify CUDA exclusion comment for RewindQwen25CAPI: known pre-existing dynamic mask issue, to be fixed in a separate PR. - Restore DML continuous-decoding guard in guidance tests. - Clarify model path probing rationale and keep per-model path cache fix in test utils.
Fix CodeQL too-few-arguments warning after download_model signature update. - Add enable_graph_capture=False to whisper-tiny download_model call in Python E2E test. - Keep behavior unchanged for whisper model generation. Verified: python -m py_compile test/python/_test_utils.py test/python/test_onnxruntime_genai_e2e.py
Remove the !USE_CUDA guard so the test runs on all EPs in CI.
Keep RewindQwen25CAPI excluded on CUDA to avoid CI regression. Document that the CUDA failure is a pre-existing issue exposed by this PR and should be fixed in a separate follow-up PR.
Contributor
Author
|
@kunal-vaishnavi Please take another look. The windows CUDA CI seems not stable. |
Enable CUDA graph-capture model generation in test/python/_test_utils.py by mapping enable_graph_capture to enable_cuda_graph for CUDA builds. Remove the CUDA exclusion from CAPITests.RewindQwen25CAPI and keep the test body provider-agnostic by relying on generated model config. Update position input comments to reflect CUDA static-mask handling when enable_cuda_graph is active.
- Keep qwen-2.5-0.5b as baseline (no graph capture) for general API tests (hidden_states, multi-token prefill, batch>1) - Add qwen-2.5-0.5b-graph with graph capture enabled for graph-capture EPs (WebGPU, CUDA, DML, NvTensorRtRtx) - RewindQwen25CAPI prefers graph model, falls back to baseline - Skip graph-capture model generation on unsupported devices (e.g. CPU)
Disable RewindQwen25CAPI test on CUDA using preprocessor guard (#if TEST_QWEN_2_5 && !USE_CUDA) since the rewind operation fails on CUDA for qwen-2.5 model with both static mask (graph-capture variant) and non-static mask (baseline variant). Added TODO comment to track the need for investigating root cause of this failure. Test continues to run on WebGPU and DML where it works correctly.
Contributor
Author
|
@kunal-vaishnavi @baijumeswani It seems that the CUDA CIs still fail. |
Remove "cuda" from _GRAPH_CAPTURE_DEVICES to avoid HF model download failures in CUDA CI pipeline.
baijumeswani
approved these changes
May 19, 2026
kunal-vaishnavi
approved these changes
May 19, 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.