← Back to Pull requests

Narrow index arithmetic with CUDA-owned specialization policy #3389

Open
unknown opened this pull request with 396 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 13, 2026 14:09 UTC
Author

Use GPUCompiler's shared narrowing pass and caller-supplied range facts to compute eligible index arithmetic in 32 bits. The compiler implementation is in JuliaGPU/GPUCompiler.jl#1045; this draft pins its tested commit through [sources].

CUDA owns the specialization policy. It classifies converted function and argument values into two bins: all selected index fields fit the chosen 32-bit bounds, or no additional facts. Dimensions, lengths, explicit indexing objects, and cached view offsets/strides participate; unrelated scalar Int data and array byte sizes do not. The selected bounds are ordinary immutable tuples passed as CompilerConfig(...; argument_ranges=...), with no range values encoded in type parameters.

GPUCompiler caches and compiles those assertions. It has no specialization hook, runtime classifier, launch guard, or fallback policy. CUDA retains the exact facts with each compiled kernel, reclassifies later launches (including captured values), and caches an unbounded fallback in the original compilation world. KernelAbstractions type-only warmup supplies the bounded bin and uses the same launch guard. @cuda specialize_indices=false disables automatic argument specialization; low-level cufunction defaults to no additional facts.

Array accessors retain their in-bounds assumptions. The duplicate CUDA pass and emitter are removed, and generic IR tests move to GPUCompiler. CUDA keeps policy, guard, fallback, and exhaustive integer-domain tests. The launch path reuses metadata from cached configurations, hashes range descriptions by their endpoints, and avoids boxing range tuples through dynamic keyword calls for type-valued arguments.

Validation on Julia 1.13.2 / RTX 5080:

  • 13,574 passed and 17 expected broken across execution, array operations, broadcasting, device arrays, KernelInterface, KernelAbstractions, range classification, and narrowing.

  • Classifier and launch guard allocate zero bytes, including 100 selected fields. Coverage includes oversized ranges, closure capture/reconstruction, original-world fallback, type-valued arguments, and strided views.

  • Cached @cuda launch measurements added roughly 30–120 ns for one array and 47–69 ns with a type-valued argument, on baseline launches of about 1.8 and 2.3 μs respectively. Both variants had identical allocation counts. The isolated type-valued guard measured 20 ns median with zero allocations. These are launch microbenchmarks, not workload speedups.

  • The 646 policy/integer-domain checks also pass on Julia 1.10.12. The actual pinned dependency resolves and CUDA is functional on Julia 1.10 and 1.13.
  • The original workload benchmarks have not been rerun. In-bounds assumptions can inhibit LLVM single-use optimizations, so the previously reported reverse! / findall regressions still need investigation. Direct cudacall bypasses the guarded kernel interface, and resource estimates for a bounded variant may differ from its fallback.

    The [sources] pins and temporary root GPUCompiler dependency are for testing this draft; replace them with a release compatibility bound before merging. Julia 1.10 CI reads the same source pin explicitly.

    Diff: 396 lines (+297 / -99) across 4 files Reviewer: maleadt Review duration: 14196m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.43) × (1 − Review Confidence (0.50)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 396 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 70%
    50%
    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.358
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3389"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 50.2% 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: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    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: 50.2% · Lower = rushed or shallow review
    50.2%
    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: 21.5% · Safe to merge
    21.5%