Skip to content

[None][fix] Do not treat a bare fmha_v2_cu directory as completed generation#16743

Open
brnguyen2 wants to merge 3 commits into
NVIDIA:mainfrom
brnguyen2:brnguyen/fix-fmha-generation-stamp
Open

[None][fix] Do not treat a bare fmha_v2_cu directory as completed generation#16743
brnguyen2 wants to merge 3 commits into
NVIDIA:mainfrom
brnguyen2:brnguyen/fix-fmha-generation-stamp

Conversation

@brnguyen2

@brnguyen2 brnguyen2 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

generate_fmha_cu creates the fmha_v2_cu output directory before the (minutes-long) kernel generation runs, but the build skips generation whenever that directory exists. An interrupted first generation (Ctrl-C, node failure, build timeout) leaves an empty/partial directory that every subsequent non-clean build trusts — launcher .cu sources are missing, and the build fails later at link time with undefined run_fmha_v2_* symbols.

Fixes this by writing a .generation_complete stamp as the last step of generate_fmha_cu (removed again as its first step) and keying the skip check on the stamp instead of the directory. The stamp is only created after validating that at least one *_sm*.cu file was produced, so a silent failure in the generator won't leave a misleading stamp. Existing checkouts regenerate once to acquire the stamp; the content-compare copy keeps mtimes of unchanged files so no recompilation results.

Test Coverage

No automated tests — this code path requires a full FMHA kernel generation run which takes several minutes and depends on CUDA toolchain setup not present in CI. Manual verification:

  • Interrupt an fmha_v2_cu generation mid-run, then rebuild without --clean — confirm generation restarts rather than skipping.
  • Let generation complete fully, then rebuild — confirm generation is skipped (stamp present).
  • Confirm a clean build from scratch still works end-to-end.

PR Checklist

  • Please check this after reviewing the above items as appropriate for this PR.

@brnguyen2
brnguyen2 requested a review from a team as a code owner July 22, 2026 16:06
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The wheel build script tracks FMHA CUDA generation with a .generation_complete stamp, invalidating it before generation, validating generated files, creating it after completion, and using it to determine whether regeneration is needed.

Changes

FMHA generation tracking

Layer / File(s) Summary
FMHA generation stamp lifecycle
scripts/build_wheel.py
Defines the .generation_complete path, removes it before generation, validates and cleans generated output, creates the stamp after successful generation, and uses its presence to trigger regeneration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: yuanjingx87, yiqingy0

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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
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.
Title check ✅ Passed The title clearly matches the main change: using a completion stamp instead of directory existence to gate FMHA regeneration.
Description check ✅ Passed The description follows the template and includes the problem, solution, test coverage, and checklist items.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@scripts/build_wheel.py`:
- Around line 267-272: Rename fmha_generation_stamp to _fmha_generation_stamp,
annotate its fmha_v2_cu_dir parameter and return value with Path, and update all
call sites at the referenced locations to use the private helper name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7c055ea9-658b-4781-a213-3e2122362c82

📥 Commits

Reviewing files that changed from the base of the PR and between 45d1c11 and 43622ca.

📒 Files selected for processing (1)
  • scripts/build_wheel.py

Comment thread scripts/build_wheel.py Outdated
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61027 [ run ] triggered by Bot. Commit: cacfdd2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61027 [ run ] completed with state FAILURE. Commit: cacfdd2
/LLM/main/L0_MergeRequest_PR pipeline #49284 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61062 [ run ] triggered by Bot. Commit: c40ce12 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61062 [ run ] completed with state FAILURE. Commit: c40ce12
/LLM/main/L0_MergeRequest_PR pipeline #49316 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61070 [ run ] triggered by Bot. Commit: c40ce12 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61070 [ run ] completed with state FAILURE. Commit: c40ce12
/LLM/main/L0_MergeRequest_PR pipeline #49325 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61090 [ run ] triggered by Bot. Commit: c40ce12 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61090 [ run ] completed with state FAILURE. Commit: c40ce12
/LLM/main/L0_MergeRequest_PR pipeline #49344 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61292 [ run ] triggered by Bot. Commit: c40ce12 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61292 [ run ] completed with state FAILURE. Commit: c40ce12
/LLM/main/L0_MergeRequest_PR pipeline #49525 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

…eration

generate_fmha_cu creates the fmha_v2_cu output directory before running
the (minutes-long) fmha_v2 kernel generation, but the build skips
generation whenever that directory exists. An interrupted first
generation (Ctrl-C, node failure, build timeout) therefore leaves an
empty or partial directory that every subsequent non-clean build trusts:
the launcher .cu sources are missing while the checked-in fmha_cubin.cpp
table still references them, and the build fails much later at link with
undefined run_fmha_v2_* symbols. Nothing recovers short of --clean,
which is not an obvious remedy for that error.

Write a .generation_complete stamp as the last step of generate_fmha_cu
(removed again as its first step) and key the skip check on the stamp
instead of the directory. Existing checkouts regenerate once to acquire
the stamp; the content-compare copy keeps mtimes of unchanged files, so
no recompilation results.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
…annotations

Rename fmha_generation_stamp to _fmha_generation_stamp and annotate its
parameter and return type with Path, per coding guidelines for private
helpers and annotation coverage.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
@brnguyen2
brnguyen2 force-pushed the brnguyen/fix-fmha-generation-stamp branch from c40ce12 to 7d048a4 Compare July 23, 2026 19:21
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@scripts/build_wheel.py`:
- Around line 335-336: Validate generated_files after FMHA generation and before
_fmha_generation_stamp(fmha_v2_cu_dir).touch(): reject empty results and ensure
they contain the expected fmha_v2_cu/*_sm*.cu outputs. Only create the
completion stamp after validation succeeds, preserving regeneration when outputs
are missing or malformed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b371d625-6642-4c42-97be-ef4f44feffe1

📥 Commits

Reviewing files that changed from the base of the PR and between cacfdd2 and 7d048a4.

📒 Files selected for processing (1)
  • scripts/build_wheel.py

Comment thread scripts/build_wheel.py
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61377 [ run ] triggered by Bot. Commit: 7d048a4 Link to invocation

…tamp

Raise RuntimeError if no *_sm*.cu files were produced before touching
the stamp, so a silent generation failure doesn't leave an apparently
complete stamp that causes subsequent builds to skip regeneration.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61377 [ run ] completed with state FAILURE. Commit: 7d048a4
/LLM/main/L0_MergeRequest_PR pipeline #49605 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61391 [ run ] triggered by Bot. Commit: b392900 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61391 [ run ] completed with state FAILURE. Commit: b392900
/LLM/main/L0_MergeRequest_PR pipeline #49618 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

1 similar comment
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61407 [ run ] triggered by Bot. Commit: b392900 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61409 [ run ] triggered by Bot. Commit: b392900 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github/16743-b392900 #61407 was force-killed by a newer pipeline run.
L0 job information not available (job may not have been triggered yet).

Link to superseding invocation

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