[Comgr][hotswap] Read source hidden arguments instead of translating them #286
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 598 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.383
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #286"
general
weight: 0.35
martin-luecke
Hidden-argument reads are lowered as ordinary loads of
kernarg_base + source_offset. The kernarg-pointer provenance analysis thatclassified those reads, and the synthesis that rebuilt their values, are
removed.
Why this is correct
1. ROCclr sizes the kernarg buffer from the source kernel's metadata and writes
each declared hidden field at its metadata offset
(
WriteAqlArgAt(hidden_arguments, value, it.size_, it.offset_),clr/rocclr/device/rocm/rocvirtual.cpp). The application loaded the sourcecode object, so those are the source offsets.
2. The dispatch path rewrites
kernel_object,private_segment_size, and undera scaled dispatch
workgroup_size_x/grid_size_x.kernarg_addressisuntouched (
rocr-runtime .../core/runtime/hotswap_aql_patch.h).3. The lifted kernel declares one
byref([N x i8])blob of the source.kernarg_segment_sizeand setsamdgpu-no-implicitarg-ptr, so its segmentis the same size and the backend appends no implicit block.
The byte at
kernarg_base + source_offsetholds the hidden value regardless ofhow the kernel computed the address.
The premise being corrected
Synthesis assumed the target runtime does not populate hidden arguments at the
source offsets, so a hidden read had to be reconstructed from the dispatch
packet or the target ABI's implicit-argument block. Fact 1 contradicts that. The
provenance analysis existed only to decide which reads needed reconstruction, so
it has nothing left to decide.
The analysis was keyed on a register, so it did not recognise a hidden read
through a pointer materialised into a second SGPR pair, e.g. rocSPARSEs
csrmmnn_device_nnz_split_main_256_2doess_add_nc_u64 s[26:27], s[0:1], 0x88then
s_load_b32 s30, s[26:27], 0x0. Those reads already lowered as ordinaryloads and were already correct.
Removed
source-hidden-args.{cpp,h},kernarg-layout.{cpp,h}Added
checkLiftedKernargSegment: post-codegen check that the emitted.kernarg_segment_sizeequals the source's and that the emitted metadatadeclares no
hidden_argument. This is fact 3. A lowering that reintroducesllvm.amdgcn.implicitarg.ptrwould place a block past the end of theruntime's buffer.
Behaviour changes
hidden_private_base/hidden_shared_baseno longer refuse; ROCclr writesthe target queue's apertures.
hidden_global_offset_{x,y,z}no longer needs the HIP zero-offset assumption.ASSUME_HIP_GLOBAL_OFFSET_ZEROhas no effect and is kept for sourcecompatibility.
the requested block before the packet is scaled, so the buffer holds un-scaled
source geometry.
virtualizeScaledDispatchSizewas required because synthesisread the scaled packet.
API
keeping that dispatch's
kernarg_address. Its metadata declares oneby_valueargument and nohidden_entries. Documented on thehotswapgroup.
AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENTwhen the request cannot receive thefactor:
result == NULL, or an unnamed whole-object request, since the factoris per kernel.
amd_comgr_hotswap_transpilealways passes a null result.Named requests with a result are unaffected.
raiseToIRnow takes aRaiseOptionsstruct carrying both ISAs. Post-raiseretry flags moved to an internal type.
Models
Under
HSA_HOTSWAP_STRICT=1, hidden-argument reads originally refused outright:any load at or above
implicitArgsBasethrough the kernarg pair hitcross-arch implicitarg.ptr lowering is unresolved, so vit, gemma3n, llama,wav2vec2 and whisper would not translate (the AISE P-1
implicitarg.ptrfailures). #124 lifted those refusals by synthesizing the values and adding the
analysis to gate it. This change resolves them by reading the byte, which also
covers the hidden kinds synthesis had no implementation for.
All five were re-run on gfx1151 (source gfx1250, STRICT=1, bf16), plus
Qwen3-0.6B. Llama-3.2-1B-Instruct and Qwen3-0.6B: teacher-forced GPU-vs-CPU
argmax divergences 0 and coherent generation. whisper-base: max_abs_diff 1.4e-4
(decoder), 2.3e-4 (encoder). ViT-base-patch16-224: 4.9e-6, argmax match.
wav2vec2-base-960h faults after the MIOpen
Im2d2Col_v2conv kernel andgemma-3n-E2B-it fails in
hipblasLtMatmul. Both fail identically with thepre-change binary, and neither reaches a numeric comparison.