Skip to content

Benchmarks: Separate cuDNN workload setup from algorithm selection - #853

Draft
gusui-msft wants to merge 4 commits into
mainfrom
feat/cudnn-prepared-plan
Draft

gusui-msft wants to merge 4 commits into
mainfrom
feat/cudnn-prepared-plan

Conversation

@gusui-msft

@gusui-msft gusui-msft commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Split legacy cuDNN initialization into descriptor creation, algorithm/workspace setup, and tensor preparation. Each direction resolves one typed algorithm: manual mode keeps the requested ID; automatic mode requires one successful cuDNN search result. The workspace query and convolution consume that same ID. Geometry is read from the executor's existing configuration, without copying eight vectors into a second configuration object.

Scope

The PR changes eight files: five native headers (the shared executor, the descriptor helper, and the three operations), one regression test, its CMake registration, and the CUDA CI pipeline. No new production header, backend, or CLI option. Default workloads, precision dispatch, warm-up/timing, and output are unchanged by this PR. The default-algorithm fix is #901; storage/compute precision remains separate in #852.

Validation (1d761695, H100 80GB, CUDA 13.0, cuDNN 9.12)

  • A clean default build compiled and linked the benchmark without building the test executable. An explicit test build passed the host error-path CTest with GPUs hidden and the GPU CTest with real cuDNN calls. The latter checks zero/one searches and the algorithm passed to the workspace query and both warm-up and timed execution, for all three convolution directions.
  • The candidate native binary ran all 18 configurations from main at a647f2b4 (Benchmarks: Restore valid timings for two default cuDNN convolutions #901): 18/18 manual and 18/18 automatic produced three finite, positive timing samples each. The two obsolete manual Winograd settings on the topic branch still report CUDNN_STATUS_NOT_SUPPORTED; there is no silent fallback.
  • For an independent asymmetric FP32 convolution, all six direction/mode combinations matched a CPU reference accumulated in FP64, with TF32 disabled. Maximum absolute error: 6.91e-6 over 5,152 values. This is a functional check, not a mixed-precision or performance qualification.
  • Six negative controls were rejected by the regression tests: removing the result-count or candidate-status check, passing the wrong algorithm to each direction's convolution, and passing the wrong algorithm to the forward workspace query.

Prepared-plan experiments remain on the separate experiment/cudnn-prepared-plan-20260916 branch.

Copilot AI lite review requested due to automatic review settings September 16, 2026 18:09

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.

🟡 Changes recommended

Prepared-plan descriptor ownership, full-sample qualification, and execution-mode validation issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds opt-in prepared cuDNN backward-filter execution while preserving legacy behavior through immutable workloads, screened plans, numerical qualification, separate metrics, tests, and documentation.

Changes:

  • Adds prepared plan construction, policy-based selection, and FP64 qualification.
  • Integrates prepared execution, configuration validation, and metrics.
  • Adds regression tests, build targets, and user documentation.
File summaries
File Summary
tests/benchmarks/micro_benchmarks/test_cudnn_workload.cpp Workload immutability tests
tests/benchmarks/micro_benchmarks/test_cudnn_prepared.py Python boundary and metric tests
tests/benchmarks/micro_benchmarks/test_cudnn_prepared.cpp Native prepared execution tests
tests/benchmarks/micro_benchmarks/test_cudnn_plan_policy.cpp Policy and selection tests
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_reference.h Numerical reference qualification
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_prepared_selection.h Candidate qualification and selection
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_prepared_plan.h cuDNN backend plan management
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_plan_policy.h Plan and accuracy policies
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_function.h Prepared execution lifecycle
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_function_helper.h Prepared configuration and dispatch
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_convolution_workload.h Immutable workload snapshot
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_config.h Prepared configuration state
superbench/benchmarks/micro_benchmarks/cudnn_function/convolution_backward_filter.h Prepared backward-filter executor
superbench/benchmarks/micro_benchmarks/cudnn_function/CMakeLists.txt Test targets and linking
superbench/benchmarks/micro_benchmarks/cudnn_function.py CLI normalization and prepared metrics
docs/user-tutorial/benchmarks/micro-benchmarks.md Prepared execution contract and validation documentation
Review details

Suppressed comments (3)

superbench/benchmarks/micro_benchmarks/cudnn_function.py:389

  • When --execution_mode prepared is selected, a custom JSON containing executionMode: "legacy" is silently overwritten by the config.update below and then runs through prepared screening. An explicit execution-mode contract should reject a mismatched value (or require the field to be omitted) rather than changing its meaning.
        if self._args.enable_auto_algo:
            raise ValueError('Prepared execution does not use legacy auto algorithm selection.')

superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_prepared_plan.h:125

  • This engine output handle has the same ownership problem as the engine-config array: cudnnBackendGetAttribute can overwrite the placeholder returned by create, but only the placeholder remains registered in descriptors_.values. The returned engine descriptor is then left unmanaged for every candidate, so repeated prepared selections leak cuDNN backend resources.
                auto engine = create(CUDNN_BACKEND_ENGINE_DESCRIPTOR);
                int64_t returned = 0;
                CHECK_CUDNN_ERROR(cudnnBackendGetAttribute(candidate, CUDNN_ATTR_ENGINECFG_ENGINE,
                                                           CUDNN_TYPE_BACKEND_DESCRIPTOR, 1, &returned, &engine));

superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_reference.h:254

  • This returns as soon as any output in the current sample fails, so later screening samples (including the actual operands) are never executed. That contradicts the five-input/full-output qualification and can leave the device operands on a probe when no later candidate runs; continue through all samples and return failures_ == 0 after the loop.
            if (failures_ != 0) {
                return false;
            }
  • Files reviewed: 14/14 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 16, 2026 18:20

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.

🔵 Needs a closer look

Two review issues remain, and full CUDA/cuDNN build and GPU runtime qualification are pending.

Review details

Suppressed comments (2)

superbench/benchmarks/micro_benchmarks/cudnn_function/convolution_backward_filter.h:29

  • plan_build_ms_ measures the entire CudnnPreparedSelection construction, not just backend plan construction: it includes reference generation, CPU cross-checks, workspace allocation, and full-output qualification for every candidate. Emitting this as plan_build_ms (and documenting it as plan-build time) misattributes the expensive qualification cost and leaves no metric for distinguishing selection/qualification from plan creation; measure the phases separately or rename this field to reflect selection/qualification time.
            auto start = std::chrono::steady_clock::now();
            const CudnnConvolutionWorkload workload(*this);
            const CudnnPlanPolicy policy(this->get_use_tensor_op(), this->get_workspace_limit_mib());
            prepared_.reset(
                new CudnnPreparedSelection(this->cudnn_handle, workload, policy, this->x, this->filter, this->h));
            plan_build_ms_ =
                std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - start).count();

superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_function_helper.h:203

  • from_json explicitly accepts executionMode: "legacy", but contains also sends that mode through the new rethrow path at lines 246-248. An explicit legacy configuration therefore changes the existing behavior for runtime errors from printing Error and returning normally to propagating out of run_benchmark; only prepared mode should enable fail-fast handling.
        explicit_execution_mode = function_config.contains("executionMode");
  • Files reviewed: 14/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 16, 2026 19:10
@gusui-msft gusui-msft changed the title Benchmarks: Decouple cuDNN prepared workload, policy and execution Benchmarks: Decouple cuDNN workload and legacy execution setup Sep 16, 2026

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.

🟡 Changes recommended

The new configuration test fails to compile because of an include cycle.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.36%. Comparing base (c548e79) to head (1d76169).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #853   +/-   ##
=======================================
  Coverage   86.36%   86.36%           
=======================================
  Files         107      107           
  Lines        8258     8258           
=======================================
  Hits         7132     7132           
  Misses       1126     1126           
Flag Coverage Δ
cpu-python3.10-unit-test 71.95% <ø> (ø)
cpu-python3.12-unit-test 71.95% <ø> (ø)
cuda-unit-test 84.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gusui-msft
gusui-msft force-pushed the feat/cudnn-prepared-plan branch from 16c0d8f to 14f665b Compare September 22, 2026 21:09
Copilot AI lite review requested due to automatic review settings October 15, 2026 03:39
@gusui-msft
gusui-msft force-pushed the feat/cudnn-prepared-plan branch from 14f665b to c51181f Compare October 15, 2026 03:39

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.

🟢 Approval recommended

No unresolved issues were identified, and the focused regression covers the new snapshot behavior.

0 open findings

1 resolved since last review

🧠 Review effort: Lite

@gusui-msft
gusui-msft force-pushed the feat/cudnn-prepared-plan branch from c51181f to 1021848 Compare October 28, 2026 17:06
Copilot AI lite review requested due to automatic review settings October 28, 2026 17:06

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.

🟡 Changes recommended

The change has an unresolved critical header dependency cycle that prevents the benchmark and new test from compiling.

1 open issue

Review effort: Lite

gusui-msft and others added 2 commits November 17, 2026 16:52
Snapshot the convolution workload and legacy execution policy before descriptor setup. Preserve algorithm selection, input initialization, benchmark timing, defaults, and result format.
The CUDA build registers cudnn_config_test, but no pipeline runs CTest,
so its snapshot assertions never execute in CI. Run the CPU-labelled
tests after building the benchmarks, and fail if no test is registered.

Include <functional> and <numeric> in cudnn_helper.h, which uses
std::multiplies and std::accumulate, so the header compiles on its
own. Drop the workaround include from cudnn_execution_config.h.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gusui-msft
gusui-msft force-pushed the feat/cudnn-prepared-plan branch from 1021848 to 69db692 Compare November 17, 2026 16:53
Copilot AI lite review requested due to automatic review settings November 17, 2026 16:53

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.

🔵 Needs a closer look

The CUDA/cuDNN runtime-preparation refactor lacks full SDK linking, GPU runtime, and representative numerical/performance validation, so human confirmation of legacy behavior is needed.

No open issues 🎉

1 resolved since last review

Review effort: Lite

Resolve each operation to a single typed algorithm without overwriting the request. Use that result for both workspace sizing and execution. Exercise manual and automatic selection and distinguish convolution stride from dilation in the host regression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 25, 2026 17:51
@gusui-msft gusui-msft changed the title Benchmarks: Decouple cuDNN workload and legacy execution setup Benchmarks: Separate cuDNN workload setup from algorithm selection Nov 25, 2026

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.

🟡 Changes recommended

An active nit remains because the PR description’s stated six-file scope does not match the nine files changed in this revision.

1 open issue

Review effort: Lite

Reuse the executor configuration and reject empty or failed search results before querying workspace. Check the algorithm IDs at the real cuDNN calls for all three directions and build the regression explicitly in CUDA CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 25, 2026 18:22

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.

🟢 Approval recommended

No active review issues remain, and the change includes targeted regression coverage with registered CUDA CI tests for consistent algorithm selection and execution.

No open issues 🎉

1 resolved since last review

Review effort: Lite

This branch has not been deployed

No deployments
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.

2 participants