← Back to Pull requests

Preserve literal arguments as constants during lowering #415

Merged
tpn merged 3 files (93 lines) on Oct 30, 2026 14:52 UTC
View on GitHub
tpn tpn commented on Oct 27, 2026 05:28 UTC
Author

Specialized integer and boolean arguments currently remain runtime values during MLIR lowering. A loop such as for i in range(count) can therefore retain a dynamic bound even when count is Literal[int](8), preventing promotion of a per-thread local array into registers.

Materialize these arguments through the existing constant-lowering path while retaining their ABI slots. Keep literal values in device-function symbols so different specializations cannot share a constant body, and route recursive calls to the specialization selected by their argument types.

Validation: six code-generation regressions fail before the fix; the focused compiler, literal-dispatch, extension, and device-function suites pass with 159 passed, 1 existing xfail. Tests cover literal constants, ordinary loop bounds, runtime arguments following literal arguments, distinct no-inline specializations, and recursion. Pre-commit checks pass. Local tests used current Python sources with existing v0.5.4 native assets; a fresh native build remains for CI.

Diff: 93 lines (+78 / -15) across 3 files Reviewer: atmnp Review duration: 4883m
All Vouch review confidence checks passed
Residual risk 0.10 = Change Risk (0.33) × (1 − Review Confidence (0.71)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 93 lines diff across 3 files
0.33
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.56 · 5 substantive comment(s)
0.56
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
70%
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.272
Real PR Conversation Timeline
8 items
copy-pr-bot[bot] copy-pr-bot[bot] commented on Oct 27, 2026 05:28 UTC
Bot

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

copy-pr-bot[bot] copy-pr-bot[bot] commented on Oct 27, 2026 15:21 UTC
Bot

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

tpn tpn commented on Oct 27, 2026 15:23 UTC
Author

/ok to test 9b25ccec2253f1ed9c8c91d225f604114322a605

coderabbitai[bot] coderabbitai[bot] commented on Oct 27, 2026 15:25 UTC
Bot

<!-- coderabbit-ai-generated:v1 -->

<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->

<a href="https://app.coderabbit.ai/change-stack/NVIDIA/numba-cuda-mlir/pull/415?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a>

<!-- review_stack_entry_end -->
<!-- recent_review_start -->

No actionable comments were generated in the recent review.

<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>

<!-- review_info_content -->
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>

  • Source mode: Auto

  • Repository: [NVIDIA/numba-cuda-mlir](<https://github.com/NVIDIA/numba-cuda-mlir>)

  • Branch: [main](<https://github.com/NVIDIA/numba-cuda-mlir/tree/main>)

  • File: [.coderabbit.yaml](<https://github.com/NVIDIA/numba-cuda-mlir/blob/bd28aef6eef61e0fc0fd69257cf1b119925842b1/.coderabbit.yaml>)

  • Commit: [bd28aef](<https://github.com/NVIDIA/numba-cuda-mlir/commit/bd28aef6eef61e0fc0fd69257cf1b119925842b1>)

  • Layers: Repository YAML

  • Review profile: CHILL

  • Plan: Enterprise

  • Run ID: 19fdbf4d-6c2a-4c85-9380-409643916fed
  • </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
    <dl>
    <dd>

    Reviewing files that changed from the base of the PR and between bd28aef6eef61e0fc0fd69257cf1b119925842b1 and 9b25ccec2253f1ed9c8c91d225f604114322a605.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</strong></summary>
    <dl>
    <dd>

    src/numba_cuda_mlir/mlir_lowering.py
    src/numba_cuda_mlir/tools.py

  • tests/test_literals.py
  • </dd>
    </dl>
    </details>

    Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

    </dd>
    </dl>
    </details>

    <!-- recent_review_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>Walkthrough</strong></summary>
    <dl>
    <dd>

    Important: Integer and Boolean literal types now remain available for specialization. Lowering uses literal values as constants, and recursive calls with different argument types route through dispatcher compilation.

    Changes: Literal specialization

    |Layer / File(s)|Summary|
    |:---|:---|
    |Preserve and lower literal arguments <br> src/numba_cuda_mlir/tools.py, src/numba_cuda_mlir/mlir_lowering.py, tests/test_literals.py|Argument normalization preserves Boolean and integer literal types. Lowering assigns their specialized values as constants. Tests cover scalar literals and literal loop bounds.|
    |Route calls by argument types <br> src/numba_cuda_mlir/mlir_lowering.py, tests/test_literals.py|Recursive calls use dispatcher compilation when folded argument types differ from the current function’s types. Tests cover literal-based dispatch and device-function calls.|

    Suggested reviewers: atmnp

    </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <!-- change_assessment_start -->
    <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong>

    <!-- change_assessment_commit:"9b25ccec2253f1ed9c8c91d225f604114322a605" -->
    Change: Bug fix
    <!-- change_assessment_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>9b25c</code></summary>
    <dl>
    <dd>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to 9b25c
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"9b25ccec2253f1ed9c8c91d225f604114322a605","coveredCommitId":"9b25ccec2253f1ed9c8c91d225f604114322a605","kind":"reviewed"} -->

    No actionable issue is established for this change; it is mergeable after normal checks.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>
    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    github-actions[bot] github-actions[bot] commented on Oct 27, 2026 15:34 UTC
    Bot

    Doc Preview CI
    :---:
    | <p></p> :rocket: View preview at <br> https://nvidia.github.io/numba-cuda-mlir/pr-preview/pr-415/ <br><br>
    | <h6><br> Preview will be ready when the GitHub Pages deployment is complete. <br><br></h6>
    <!-- Sticky Pull Request Commentpr-preview -->

    atmnp atmnp approved these changes on Oct 27, 2026 16:43 UTC
    Approved Reviewer

    Approved these changes.

    github-actions[bot] github-actions[bot] commented on Oct 30, 2026 15:06 UTC
    Bot

    Doc Preview CI
    :---:
    Preview removed because the pull request was closed or merged.
    <!-- Sticky Pull Request Commentpr-preview -->

    Reviewers
    Assignees
    tpn tpn
    Labels
    risk: low confidence: 71.0% 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: 33.1% (LOW) · Higher = larger blast radius
    33.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: 71.0% · Lower = rushed or shallow review
    71.0%
    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: 9.6% · Safe to merge
    9.6%