← Back to Pull requests

[rocjitsu][consan] Track native application dispatch lifetimes #16517

Open
unknown opened this pull request with 648 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 23, 2026 17:37 UTC
Author

Applications can create queues before loading code objects and issue overlapping native helper kernels with null completion signals. The controlled ConSan runtime requires a frozen prepared module, one queue and a dedicated completion for each nonoverlapping launch, so it rejects these application sequences. Observing native completion requires tracking each launch without making the application allocate signals or adding dependencies between its queues.

Add the opt-in RJ_CONSAN_APPLICATION_PROFILE=1 adapter. Reuse the existing native ABI inventory to admit exact original images listed in RJ_CONSAN_NATIVE_IMAGES, matching both their digest and complete bytes. Resolve every entry at executable freeze before publishing bindings, reject kernel-object collisions across modules, and bind dispatches to their queue agent. Support system-memory compute queues created through the core or AMD API before image loading, preserving priority, CU mask and profiling calls. Queue count is governed by ROCR and system resources; ConSan adds no application queue-count cap.

For standard and AMD extended format 3 native dispatches with null completions, substitute a fresh runtime-owned signal initialized to 1. Preserve the other packet bytes, including arguments, resource requests, fences, dependencies, cluster geometry and performance hints. Keep coalesced packet order without inserting barriers or dependency edges. Private completion publication adds overhead, so exact timing equivalence is not claimed.

Each launch retains its module, queue identity and submission sequence until the observer reads exactly 0 from its private completion. Independent launches can retire out of order. Queue and executable destruction wait for their own launches, while rj_consan_drain() waits for the prefix submitted before the call. Charge the execution budget per dispatch rather than per batch packet, allowing trailing barriers to pass. After admission failure, notify eligible tracked AND/OR barrier completions with -1 while retaining signals already owned by pending dispatches.

Count successful HSA initialization and shutdown calls through the installed hooks, starting with the installing hsa_init reference. Automatically finish before releasing the final tracked reference; intermediate shutdown leaves admission open for remaining clients. Calls that bypass the hooks are outside this accounting contract. Keep Runtime ownership until OnUnload so HIP exit handlers can still use the hooks, and defer deletion through an enclosing shutdown call. Both Linux plugin variants use NODELETE to keep hook code mapped when ROCR unloads the tool inside that call, retaining the DSO mapping for the process lifetime.

Native-only setup requires neither a prepared artifact nor RJ_CONSAN_CAPTURE_PATH, and produces no selected capture or LDS-analysis coverage. Selected LDS execution retains the controlled queue and dedicated-completion path. A configured selected artifact still requires its capture settings and makes finish fail if its capture never starts.

Current limits

The application adapter retains these restrictions; image/module counts and the execution budget are profile policy rather than hardware limits:

| Boundary | Current behavior |
|---|---|
| Images and modules | At most 16 distinct native images, 256 MiB of aggregate original image bytes and 16 native modules. The module-count guard runs before image classification, so loading the optional selected image after 16 native modules is rejected; loading it first permits those native modules. |
| Dispatch budget | At most 1,024 cumulative dispatches per Runtime, including native-only launches. Draining does not replenish the budget. |
| Native resource requests | Private allocation must equal the descriptor's static requirement; group allocation must meet the static minimum and fit within 64 KiB. These checks currently reject legal larger private allocations and larger-LDS requests on capable targets. |
| Empty lifecycle | Native-only finish rejects a run with no dispatches, causing final automatic shutdown to fail despite having no pending work or selected capture. |
| Packet profile | Nonzero application completions and extended format 4 remain unsupported. Application-profile dispatch admission is native-only. |

Example walkthrough

For an illustrative allowed image containing kernel C, create Q0 and Q1 before loading and freezing the image as module M. Submit independent C launches with admitted resource requests and completion handle 0. The runtime creates S0 and S1, each initialized to 1:

Queue  Application packet   Published packet    Retained launch state
Q0     C, completion=0  ->  C, completion=S0  -> seq 1, module M, Q0
Q1     C, completion=0  ->  C, completion=S1  -> seq 2, module M, Q1

A drain started after both submissions waits for both. If Q1 completes first, observing S1=0 retires sequence 2 and permits Q1 destruction; drain and destruction of shared module M still wait for sequence 1. Observing S0=0 completes that prefix. A C packet with a nonzero application completion is rejected.

Diff: 648 lines (+486 / -162) across 8 files Reviewer: hanhanW Review duration: 10947m
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 648 lines diff across 8 files
0.52
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.387
Shallow Review Depth shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #16517"
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: 52.0% (MEDIUM) · Higher = larger blast radius
52.0%
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: 27.7% · Safe to merge
27.7%