← Back to Pull requests

UCT/CUDA_IPC/ROCM_IPC: Zero the padding of a packed rkey #12509

Open
unknown opened this pull request with 270 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 30, 2026 13:56 UTC
Author

What?


The remote key packed by cuda_ipc and rocm_ipc no longer contains uninitialized padding bytes.

Why?


Fixes #12099.

uct_cuda_ipc_rkey_t has 4 bytes of padding between pid and d_bptr. uct_cuda_ipc_extended_rkey_t, which is packed in a non-default PID namespace, has 4 more at its end. uct_cuda_ipc_mkey_pack() sets the fields one by one, so these bytes kept whatever the destination buffer held: heap data for ucp_rkey_pack(), or the previous contents of a send buffer when the key is packed into a rendezvous RTS.

uct_rocm_ipc_key_t ends with 4 bytes of padding. The key is allocated with ucs_malloc() and copied as a whole when it is packed, so the packed key carries heap data as well.

As a result:

  • Packing the same memory twice can give different bytes. An application that compares packed keys sees a change where there is none (ai-dynamo/nixl#2437).

  • 4 to 8 bytes of process memory are sent to the peer with every packed key.
  • Unpacking does not read these bytes, so transfers are not affected.

    How?


  • cuda_ipc: uct_cuda_ipc_mkey_pack() zeroes the whole packed key before it sets the fields. uct_cuda_ipc_rkey_packed_size() gives the size to both the MD query and the pack, so that the extended key is covered.

  • rocm_ipc: the key is allocated with ucs_calloc(). The memset of its IPC signal became redundant and is removed.

  • Test: test_md.mkey_pack_all_bytes packs the same memory handle into a buffer filled with 0x00 and a buffer filled with 0xff, and expects equal bytes. It runs for every MD that registers memory and needs an rkey.
  • The rocm_ipc case is not caught by comparing the two buffers, because a byte copied from the uninitialized key is equal in both. The test covers it with VALGRIND_CHECK_MEM_IS_DEFINED(), which takes effect only under valgrind.

    Testing


    Not built or run locally: there was no CUDA or ROCm host at hand, so this relies on CI. The test logic was replayed against a copy of the cuda_ipc structures: without the memset the two buffers differ in 4 bytes (8 for the extended key), and with it they are equal.

    🤖 Generated with Claude Code

    Diff: 270 lines (+202 / -68) across 3 files Reviewer: tvegas1 Review duration: 1234m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 270 lines diff across 3 files
    0.39
    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%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.335
    Real PR Conversation Timeline
    1 comments
    "Review active on #12509"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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% · Safe to merge
    21%
    Repository