← Back to Pull requests

Fix generic vector float norm helpers #2257

Open
unknown opened this pull request with 363 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 08, 2026 04:09 UTC
Author

What problem are you trying to solve?

Fixes #2224.

A dtype-generic kernel that works with wp.vec3 fails to compile when instantiated with wp.vec3h or wp.vec3d. The helpers mixed Python float constants with the vector's scalar type in norm_l1, norm_huber, norm_pseudo_huber, and consequently smooth_normalize.

This blocks dtype-generic spatial/numerical kernels from using the same norm implementation across float16, float32, and float64 vectors.

What does this change?

  • Derive constants from the vector's scalar dtype before combining them with vector arithmetic.

  • Keep the existing norm and normalization formulas unchanged.

  • Add one regression that exercises all four helpers over vec3h, vec3f, and vec3d.

  • Add changelog fragment 2224.fixed.md.
  • Existing pull requests

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

  • Related pull requests: None found. I also asked in the issue whether an outside implementation was wanted before submitting this focused patch.
  • Validation

  • Regression validation: test_vec_norm_dtypes fails to compile before the helper changes and passes after them.

  • NVIDIA GPU: NVIDIA RTX 6000 Ada Generation, SM89, CUDA Toolkit 13.4, driver 13.2.

  • Other validation: uvx pre-commit run --files warp/_src/math.py warp/tests/test_math.py changelog/2224.fixed.md passed all hooks, including generated-file checks, Ruff, format, and typos.
  • Targeted validation used the patched source files with the official warp-lang==1.19.0 wheel's CPU+CUDA native library because this host does not have the CUDA runtime headers needed to compile the current main native library from source.

    Warp 1.19.0 initialized:
       CUDA Toolkit 13.4, Driver 13.2
       Devices:
         "cpu"      : "x86_64"
         "cuda:0"   : "NVIDIA RTX 6000 Ada Generation" (47 GiB, sm_89, mempool enabled)
    
    test_vec_norm_dtypes_cpu ... ok
    Ran 1 test in 6.458s
    OK
    
    test_vec_norm_dtypes_cuda_0 ... ok
    Ran 1 test in 18.076s
    OK
    

    Validation after syncing with main

    The Huber threshold comparison uses the primal value for forward-mode jets.
    The arithmetic retains the vector dtype and preserves the jet derivatives.

    I built Warp from source on Yokota with CUDA 13.2 and ran the following tests
    on the updated head e7d0c3d72 (RTX 3090):

    test_vec_norm_dtypes_python_scope ... ok
    test_vec_norm_dtypes_cpu ... ok
    test_vec_norm_dtypes_cuda_0 ... ok
    test_norm_huber_cpu ... ok
    Ran 4 tests in 74.320s
    OK
    

    Ruff check and format checks passed for the changed Python files.

    Checklist

  • I have read and followed the Contributing Guidelines.

  • This pull request does not bundle unrelated changes.

  • My branch is up to date with main and contains one commit.

  • I included the required changelog fragment.
  • AI assistance: OpenAI Codex investigated, implemented, and validated this change under human direction.

    Diff: 363 lines (+272 / -91) across 4 files Reviewer: LiRunGuo Review duration: 38247m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 363 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: 35%
    42%
    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.353
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2257"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.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: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    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: 43.0% · Lower = rushed or shallow review
    43.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: 24.3% · Safe to merge
    24.3%
    Repository