Skip to content

Update conv get-plan sample heuristic config count#278

Open
yeliu-oss wants to merge 1 commit into
NVIDIA:developfrom
yeliu-oss:yeliu/bug_5880337
Open

Update conv get-plan sample heuristic config count#278
yeliu-oss wants to merge 1 commit into
NVIDIA:developfrom
yeliu-oss:yeliu/bug_5880337

Conversation

@yeliu-oss
Copy link
Copy Markdown

@yeliu-oss yeliu-oss commented Jun 4, 2026

Summary by CodeRabbit

  • Refactor
    • Restructured the internal configuration generation logic for improved code maintainability.
    • Updated the configuration retrieval mechanism to request a more limited set of plans, potentially improving performance and reducing memory overhead.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors the cuDNN heuristics engine configuration generator in conv_sample.cpp by extracting a shared helper function, creating two method variants for controlling the number of configs selected, and updating the generator to use the single-config variant.

Changes

Heuristics engine config selection refactoring

Layer / File(s) Summary
Heuristics config helper extraction and variant methods
samples/legacy_samples/conv_sample.cpp
Extracts shared get_engine_configs_from_heuristics helper with configurable max config count. Refactors heurgen_method to call the helper with unlimited count; adds heurgen_method_first_config for single-config selection. Updates run_from_cudnn_get to use heurgen_method_first_config, changing the plan retrieval behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A refactor swift, a helper born,
Two methods split from config worn,
First one shines through the generator's call,
While shared code handles them all!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring the heuristic engine config count behavior in the conv sample by adding a new method to request only the first configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
samples/legacy_samples/conv_sample.cpp

In file included from samples/legacy_samples/conv_sample.cpp:23:
samples/legacy_samples/conv_sample.h:30:10: fatal error: 'cuda_runtime.h' file not found
30 | #include <cuda_runtime.h>
| ^~~~~~~~~~~~~~~~
1 error generated.
samples/legacy_samples/conv_sample.cpp:230:120-248:1: ERROR translating statement 'CompoundStmt'
Aborting translation of method 'create_operation_graph' in file 'samples/legacy_samples/conv_sample.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.lo

... [truncated 2200 characters] ...

ntend__CFrontend_decl.CFrontend_decl_funct.add_method in file "src/clang/cFrontend_decl.ml" (inlined), line 54, characters 4-52
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.function_decl in file "src/clang/cFrontend_decl.ml", line 90, characters 12-151
Called from ClangFrontend__CFrontend_decl.CFrontend_decl_funct.translate_one_declaration in file "src/clang/cFrontend_decl.ml", line 453, characters 10-56
Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
Called from Stdlib__List.iter in file "list.ml" (inlined), line 110, characters 17-25
Called from Base__List0.iter in file "src/list0.ml" (inlined), line 25, characters 16-35
Called from ClangFrontend__CFrontend.compute_icfg in file "src/clang/cFrontend.ml", line 28, characters 6-130
Called from C


Comment @coderabbitai help to get the list of available commands and usage tips.

@vedaanta vedaanta requested a review from Anerudhan June 4, 2026 16:27
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
samples/legacy_samples/conv_sample.cpp (1)

983-983: ⚡ Quick win

Document the rationale for requesting only the first config.

Changing from heurgen_method (all configs) to heurgen_method_first_config (1 config) significantly alters behavior:

  • Only one plan will be available for execution
  • Workspace size calculation (lines 989-995) will only consider the first plan
  • No fallback plans if the first config fails to build or execute

While this aligns with using cudnnGetPlan for heuristics-only workflows (per comment lines 1011-1013), adding a comment here would clarify that a single top-heuristic config is sufficient for this use case.

📝 Suggested comment
+        // Use first config only since cudnnGetPlan is for heuristics-based plan selection without benchmarking
         std::array<cudnn_frontend::GeneratorSource const, 1> sources = {heurgen_method_first_config};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@samples/legacy_samples/conv_sample.cpp` at line 983, Assigning only the top
heuristic config via heurgen_method_first_config (instead of heurgen_method)
intentionally restricts execution to a single plan: add a comment at the sources
assignment explaining this choice, referencing heurgen_method_first_config and
cudnnGetPlan so readers know we only need the top heuristic for a
heuristics-only workflow; note the implications that workspace size computation
and plan-building will consider only that first config and there will be no
fallback plans if it fails, and justify that this is acceptable because the code
is using cudnnGetPlan-style heuristics rather than enumerating all configs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@samples/legacy_samples/conv_sample.cpp`:
- Line 983: Assigning only the top heuristic config via
heurgen_method_first_config (instead of heurgen_method) intentionally restricts
execution to a single plan: add a comment at the sources assignment explaining
this choice, referencing heurgen_method_first_config and cudnnGetPlan so readers
know we only need the top heuristic for a heuristics-only workflow; note the
implications that workspace size computation and plan-building will consider
only that first config and there will be no fallback plans if it fails, and
justify that this is acceptable because the code is using cudnnGetPlan-style
heuristics rather than enumerating all configs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 54429858-8320-48c5-b8c4-06f48e98e891

📥 Commits

Reviewing files that changed from the base of the PR and between 1a2799b and ff4276d.

📒 Files selected for processing (1)
  • samples/legacy_samples/conv_sample.cpp

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.

1 participant