← Back to Pull requests

Fix attribute access on captured composite constants #2024

Closed
unknown closed this pull request without merging on Oct 12, 2026 23:35 UTC
View on GitHub
unknown unknown commented on Oct 02, 2026 12:56 UTC
Author

What problem are you trying to solve?

Captured vector, quaternion, transformation, and struct values were returned unchanged when accessing an attribute in a kernel, so component/field access could produce incorrect results or type errors.

Closes #2023

What does this change?

Keep the existing early handling for scalar/native constants, let captured ctypes composite values use the existing vector/quaternion/transformation extraction paths, and resolve captured struct fields as compile-time constants.

Existing pull requests

  • I searched open pull requests for duplicate or overlapping work.

  • Related pull requests: None found.
  • Validation

  • Regression validation: Added and registered test_captured_constant_attributes, covering captured vector components, transformation quaternion components, scalar/composite fields on a directly captured module-level StructInstance, wp.static(), and an @wp.func path. The unsupported closure-captured StructInstance case was removed after validation showed Warp does not accept struct instances as closure constants.

  • Static validation: python3 -m py_compile warp/_src/codegen.py warp/tests/test_compile_consts.py; pre-commit passed including Ruff, Ruff format, generated-file/version checks, and typo checks; git diff --check passed.

  • Runtime validation: Attempted focused pytest collection for test_compile_consts.py; this macOS checkout has no built warp/bin/libwarp.dylib, so import/collection stops during native library initialization. The original collection blocker from wp.constant(StructInstance) and the invalid closure-captured struct test are removed.

  • NVIDIA GPU: Not run; no CUDA/native Warp runtime is available in this checkout.
  • Checklist

  • I have read and followed the Contributing Guidelines.

  • This pull request does not bundle unrelated changes unless a maintainer agreed to the broader scope.

  • My branch is up to date with main and contains one commit, unless a maintainer agreed to keep the change as multiple commits.

  • I included the required changelog fragment.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Bug Fixes
    Fixed attribute access for captured vector, quaternion, transformation, and struct values in compiled kernels. Components and fields can now be read from captured values, including scalar struct fields and vector and transformation components.
    * Struct field access also works through wp.static and an @wp.func path.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 334 lines (+250 / -84) across 4 files Reviewer: efegokdemir Review duration: 15039m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 334 lines diff across 4 files
    0.42
    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.348
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2024"
    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: 42.2% (MEDIUM) · Higher = larger blast radius
    42.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: 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: 16.7% · Safe to merge
    16.7%
    Repository