← Back to Pull requests

[CIR][CUDA][offload-merge] Implement Launch Bound propagation #21

Closed
unknown closed this pull request without merging on Sep 07, 2026 20:03 UTC
View on GitHub
unknown unknown commented on Aug 18, 2026 19:44 UTC
Author

In short, this infers the __launch_bounds__ the user never wrote, from the launches this TU actually records. Host <<<grid, block>>> and the device kernel live in the same cir.offload.container, so we can stamp cir.nvvm.maxntid on the NVPTX kernel.

Same visibility as const-prop: the stub is internal, and every use outside its own body is a recorded launch. On top of that, every site has to have a fully constant block dim. If any site is opaque or runtime, we leave the kernel alone as under-shooting maxntid is a launch failure, not a slowdown. The number we write is the max of xyz across those sites, never the min. An existing bound (user __launch_bounds__) is only tightened, never widened.

consider:

static __global__ void foo();

foo<<<1, 64>>>();
foo<<<1, 256>>>();

Device, before:

cir.func @foo() cc(ptx_kernel) {
  cir.return
}

Device after:

cir.func @foo() cc(ptx_kernel) attributes {cir.nvvm.maxntid = "256"} {
  cir.return
}

Note that initially this is CUDA only, launch bounds behave differently for HIP (the upper bounds). The analogous for the latter is apparently amdgpu-flat-work-group-size if the attribute is not explicit by the user codegen assigns 1024. see:

https://github.com/RiverDave/llvm-project/blob/323d3f82f82449e89687368c51ea0cdc65d05efe/clang/lib/CIR/CodeGen/Targets/AMDGPU.cpp#L84

Lastly, this is not wired end to end, I will defer that for another PR as I found some issues with ABI handling in https://github.com/RiverDave/llvm-project/pull/17 -- follow up PR on that soon.

Diff: 199 lines (+149 / -50) across 2 files Reviewer: RiverDave Review duration: 28818m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 199 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.317
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #21"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.1% (MEDIUM) · Higher = larger blast radius
36.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.3% · Safe to merge
14.3%