← Back to Pull requests

[rocjitsu][consan] Preserve per-entry ABI in prepared images #16514

Open
unknown opened this pull request with 428 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 23, 2026 17:08 UTC
Author

Whole-image preparation rejects compiler metadata such as hidden arguments and required workgroup shapes. Shared validation also requires every entry to have a zero-sized private segment, so a native sibling can prevent preparation even when only other kernels are selected for instrumentation.

Separate metadata consistency from instrumentation eligibility. Recognize supported hidden arguments, constant buffer pointers, power-of-two kernarg alignment and required workgroup shapes while retaining argument width, offset and bounds checks:

  • Selected entries: retain the private-segment restriction and reject dynamic stack requirements before publishing an artifact.

  • Native entries: preserve private/group resources and allow VGPR usage below descriptor capacity. Provide a separate native-image inventory without selected manifests or detector coverage.
  • Carry each entry's .kernarg_segment_align and .reqd_workgroup_size through preparation, saved facts and artifact verification. At runtime, use max(metadata alignment, HSA alignment) for kernarg admission and reject launches that differ from the original required shape. Preserve workgroup identity sources and existing multi-workgroup, barrier and loop report layouts.

    Extend the entry wire format and change the producer compatibility token. Older artifacts must be regenerated.

    Example walkthrough

    Select A/B in an image containing A, B and C. The extended ABI fixture has these original requirements (sizes are in bytes):

    | Entry | Kernarg | Alignment | LDS | Private | Required workgroup |
    |-------|---------|-----------|-----|---------|--------------------|
    | A | 16 | 8 | 8 | 0 | 64x1x1 |
    | B | 32 | 8 | 256 | 0 | 64x1x1 |
    | C | 24 | 32 | 64 | 68 | 32x2x1 |

    Preparation produces one replacement image:

    original.hsaco                    prepared.hsaco
    +-----------------------+         +------------------------------+
    | A: selected           | ------> | A: probes, kernarg 16 -> 32   |
    | B: selected           | ------> | B: probes, kernarg 32 -> 48   |
    | C: native sibling     | ------> | C: original ABI and resources |
    +-----------------------+         +------------------------------+
    

    A's original argument block contains seed at offset 0, a four-byte hidden_block_count_x at offset 4 and an output pointer at offset 8. The existing wrapper mechanism retains those bytes and appends two pointers:

    Byte offsets:
    0       4        8          16            24         32
    +-------+--------+----------+-------------+----------+
    |  seed | hidden | output*  |  orig args* | context* |
    +-------+--------+----------+-------------+----------+
    

    Offsets 0..15 are the original arguments; 16..31 are the extension. The existing entry prologue restores the original guest kernarg pointer. This change lets metadata admission and saved ABI facts honor that layout.

    A launch with grid 256x1x1 and workgroup 64x1x1 still has four workgroups and eight wave32 report rows. Workgroup 32x1x1 is rejected despite being below the maximum size, because it violates A's required shape.

    C can remain native with its 68-byte private segment and 32-byte alignment. Preserving its 32x2x1 requirement does not add 2D native dispatch support: the controlled native launch profile still requires one 1D workgroup.

    Diff: 428 lines (+321 / -107) across 5 files Reviewer: hanhanW Review duration: 10975m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 428 lines diff across 5 files
    0.45
    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
    Diff Size diff_size
    0.363
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #16514"
    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: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    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: 24.1% · Safe to merge
    24.1%