Skip to content

Benchmarks: Fix cuDNN storage/compute types and FP16 initialization - #852

Open
gusui-msft wants to merge 5 commits into
mainfrom
fix/cudnn-data-type-correctness
Open

gusui-msft wants to merge 5 commits into
mainfrom
fix/cudnn-data-type-correctness

Conversation

@gusui-msft

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

Copy link
Copy Markdown
Contributor

Description
Fix the cuDNN configuration's convolution compute type without overwriting the tensor storage type. Previously, requesting FP16 storage with FP32 compute changed input_type_ to FP32, so dispatch could execute FP32 while the configuration still described FP16.

Correct FP16 dispatch also exposes the half initializer's reversed host-to-device copy arguments. This PR includes the necessary initialization fix.

Major Revision

  • Make set_conv_type() and get_conv_type() use conv_type_ independently of input_type_.
  • Seed FP16 initialization with the requested seed and copy the initialized host buffer to the device buffer in the correct direction.

Minor Revision

  • Keep the patch runtime-only: two files, +4/-3; no regression-test files or CMake changes.
  • Leave benchmark cases, algorithms, timing and metric names unchanged. Corrected FP16 results require new baselines; this is not a latency-variance fix.

Validation

  • The unchanged runtime fixes were previously validated for independent storage/compute types and seeded FP16 initialization on CUDA 13.0 / cuDNN 9.12.
  • Rebased onto main at 5411041d809c7573984acdc2a989057b589b8366 on September 11; published head is bb7391a9e6796604f0e250e1ef38d84595b31e17.
  • Verified that the complete two-file patch and runtime file contents are identical to the pre-rebase revision, CMake matches current main, the regression-test file is absent, and git diff --check passes.
  • No new GPU run was performed for the test removal or rebase. No automated regression test is included.

Copilot AI lite review requested due to automatic review settings September 10, 2026 23:58

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 review issues remain.

Pull request overview

Fixes cuDNN storage/compute type handling and FP16 buffer initialization.

Changes:

  • Separates convolution compute type from tensor storage type.
  • Corrects seeded FP16 host-to-device initialization.
File summaries
File Summary
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_helper.cpp Corrects seeded FP16 initialization and device copy direction.
superbench/benchmarks/micro_benchmarks/cudnn_function/cudnn_config.h Preserves independent input and convolution types.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.88%. Comparing base (fe4cf96) to head (a885635).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #852      +/-   ##
==========================================
- Coverage   86.62%   85.88%   -0.74%     
==========================================
  Files         114      114              
  Lines        9224     9224              
==========================================
- Hits         7990     7922      -68     
- Misses       1234     1302      +68     
Flag Coverage Δ
cpu-python3.10-unit-test 72.68% <ø> (ø)
cpu-python3.12-unit-test 72.68% <ø> (ø)
cpu-python3.7-unit-test 71.95% <ø> (ø)

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.

Keep storage and convolution compute precision independent, seed and transfer half data correctly, and fix workspace, descriptor, and exception safety.

Add native, CLI, and parser regressions and document FP16 baseline migration. Preserve the host-wall timing loop, default cases, and metric names.
Keep independent storage and compute types, seeded half initialization, and two direct native regressions. Defer documentation, parser, resource, stride, and exception-handling changes to separate work.
@gusui-msft
gusui-msft force-pushed the fix/cudnn-data-type-correctness branch from 827d80e to bb7391a Compare September 11, 2026 17:06
@gusui-msft
gusui-msft marked this pull request as ready for review September 11, 2026 17:06
@gusui-msft
gusui-msft requested a review from a team as a code owner September 11, 2026 17:06
Copilot AI review requested due to automatic review settings September 11, 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.

🟢 Approval recommended

No unresolved review issues were identified.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI lite review requested due to automatic review settings October 13, 2026 18:13

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 that would block approval.

0 open findings

🧠 Review effort: Lite

Copilot AI lite review requested due to automatic review settings December 1, 2026 18:02

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 dispatch and FP16/FP32 initialization changes require GPU compilation and runtime validation across supported versions, which is unavailable in this review environment.

No open issues 🎉

Review effort: Lite

void set_use_tensor_op(bool use_tensor_op) { use_tensor_op_ = use_tensor_op; }
void set_input_type(const cudnnDataType_t &input_type) { input_type_ = input_type; }
void set_conv_type(const cudnnDataType_t &conv_type) { input_type_ = conv_type; }
void set_conv_type(const cudnnDataType_t &conv_type) { conv_type_ = conv_type; }

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.

[SHOULD-FIX] Unsupported inputType/convType pairs now abort via an uncaught const char*

With this change, run_benchmark (cudnn_function_helper.h) sees the real (input_type, conv_type) pair. Before, set_conv_type overwrote input_type_, so the final else branch was unreachable. Now pairs such as inputType 0, convType 2 reach:

                    throw "invalid input and conv type";

That throws a const char*. Both run_benchmark and main in cudnn_test.cpp only catch (std::exception &e), so the process calls std::terminate (SIGABRT) and prints no Error: line.

Impact: Custom configs that previously ran (with the wrong types) now abort without a diagnostic. The Python wrapper records only a generic execution failure.

Recommendation:

throw std::invalid_argument("invalid input/conv type combination: inputType=" +
    std::to_string(function.get_input_type()) + ", convType=" + std::to_string(function.get_conv_type()));

Apply the same fix to the sibling throw "invalid function name" / throw "ERROR: invalid input function name".

host_input[i] = __float2half((float)std::rand() / (float)(RAND_MAX));
}
CUDA_SAFE_CALL(cudaMemcpy(host_input, *input, sizeof(half) * size, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaMemcpy(*input, host_input, sizeof(half) * size, cudaMemcpyHostToDevice));

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.

[SHOULD-FIX] Default FP16 path becomes live but has no GPU validation or type-separation regression test

Nine default configs in cudnn_function.py use inputType: 2, convType: 0. Before this PR they actually ran <float,float>, so CudnnFunction<half,float> and this rand<half> (with its reversed memcpy) never ran in practice. The PR notes say there was no GPU run after the rebase. test_cudnn_functions only asserts 0 < values[0] < math.inf, so it would still pass if conv_type_ were overwritten again. <half,half> is still not exercised.

Impact: If any default half/float algo or tensor-op combination is unsupported, it yields a -1 timing that only shows up on GPU CI or in production runs.

Recommendation:

  • Run pytest tests/benchmarks/micro_benchmarks/test_cudnn_function.py on at least one GPU SKU and attach the results.
  • Add a cheap regression check: emit the resolved types from the binary and assert on them, or add a host-only check that from_json keeps input_type=HALF, conv_type=FLOAT.
  • Optionally add an inputType 2, convType 2 custom case.

bool get_use_tensor_op() { return use_tensor_op_; }
cudnnDataType_t &get_input_type() { return input_type_; }
cudnnDataType_t &get_conv_type() { return input_type_; }
cudnnDataType_t &get_conv_type() { return conv_type_; }

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.

[NON-BLOCKING] inputtype_2 metrics change meaning without changing names

_process_raw_result builds metric names from the requested config. This fix changes what *_inputtype_2_*_time actually measures (from FP32/FP32 to FP16 storage with FP32 compute) while keeping the same names.

Impact: Historical baselines and diagnosis rules will show a step change that looks like a regression or improvement.

Recommendation: Add a release note naming the affected metrics and the revision boundary, and refresh the stored cudnn-function baselines.

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.

3 participants