← Back to Pull requests

Select CUDA kernel specializations before packing launch arguments #461

Closed
unknown closed this pull request without merging on Nov 23, 2026 18:10 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 18:59 UTC
Author

A float64 launch after a float32 launch could silently run the float32 kernel. In #459, both calls passed 1.5, but the second stored 0.0. The same bug affected extensions: two Numba types could select different device code even though prepare_args packed both values as the integer 0.

This PR makes the Python dispatcher select the kernel while it still has the Numba argument types. The selected signature determines how to convert and pack the values, and the native launcher receives the executable explicitly.

Walkthrough

The first two commits fix #459. The last two reduce the work repeated on subsequent launches.

1. Select the overload. When compilation is enabled, reuse an exact signature or compile one. A frozen dispatcher can still select a compatible overload and convert the arguments to its signature.
2. Launch the selected kernel. Carry each argument’s Numba type through extension handling. Use the selected specialization for both argument packing and execution, so a native cache hit cannot substitute a kernel compiled for another type.
3. Cache the selection. Repeated calls with the same effective types and relevant launch configuration can skip overload resolution. Recompilation, new overloads, and changes in compilation policy invalidate affected choices.
4. Streamline scalar preparation. Reuse type information for scalar classes whose Numba type is fixed. Skip packing conversions when the values already match the selected signature. Python integers still need per-value inference because their signedness can depend on their magnitude.

Validation

Both published reproducers passed at commit 2, before either optimization. The scalar launches each stored 1.5, and the extension launches returned 1 and 2. Regression tests also exercise record layouts, tuple element types, frozen conversions, and retained launchers after recompilation. Cache tests count calls to the resolver to verify warm hits and eviction.

Fixes #459.

Diff: 250 lines (+187 / -63) across 3 files Reviewer: brandon-b-miller Review duration: 15791m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 250 lines diff across 3 files
0.39
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.331
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #461"
general weight: 0.35
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: 39.0% (MEDIUM) · Higher = larger blast radius
39.0%
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: 15.4% · Safe to merge
15.4%