Skip to content

Benchmarks: Decouple cuDNN workload and legacy execution setup - #853

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

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

Conversation

@gusui-msft

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

Copy link
Copy Markdown
Contributor

Description
Refactor existing legacy cuDNN initialization into immutable workload/policy inputs and separate descriptor, algorithm/workspace, and input preparation. No new execution mode.

The CUDA unit-test pipeline now runs the new host regression through CTest after building the benchmarks, and the step fails if the test is not registered. cudnn_helper.h now includes <functional> and <numeric> for the std::multiplies and std::accumulate calls it already makes, so it compiles without relying on include order.

Scope

  • Net diff against main: 6 files, +151/-20, including one 62-line host regression and a 5-line CI step.
  • CLI, all 18 defaults, precision parsing, the three convolution implementations, warmup/timed loop and result format remain unchanged.
  • No prepared backend, numerical-reference runtime, new metric protocol or cuBLAS dependency. The Benchmarks: Fix cuDNN storage/compute types and FP16 initialization #852 precision repair remains separate.

Validation

  • Host configuration regression passed with real CUDA/cuDNN headers and no GPU libraries linked, using Clang 18 (libc++) and GCC 13.4 (libstdc++).
  • The new CI step was exercised locally against a CUDA-enabled CMake configuration (GCC 13.4, nvcc 13.0.48, CMake/CTest 3.31.6) that built only the test target. It passed, failed when a workload snapshot field was deliberately broken, and failed when no test was registered.
  • cudnn_helper.h, cudnn_config.h and cudnn_execution_config.h each compile as the first include. Native benchmark objects compile, and clang-format 14 and no-CUDA CMake configuration pass.
  • Not covered locally: a full SDK link, the Azure CI agent, and GPU numerical or performance qualification. This PR makes no latency-improvement claim.

Prepared experiments remain preserved on the separate experiment/cudnn-prepared-plan-20260916 branch. This PR contains only the legacy workload/policy refactor and the supporting test, CI and include changes.

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 (69db692).

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.12-unit-test 71.95% <ø> (ø)
cpu-python3.7-unit-test 71.41% <ø> (ø)
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 <[email protected]>
@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

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