fix(hipdnn): reject inconsistent operand shapes in frontend validation #16036
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #16036"
general
weight: 0.35
BrianHarrisonAMD
Summary
Graph::validate()accepted graphs that engines then read out of bounds (a matmul output larger than its inputs, layer-norm scales and statistics that disagree with X), crashed on zero or short dimensions in convolution backward and resample, and the graph builders crashed on a null tensor argument. Pointwise, reduction and layer-norm backward also rejected or mis-inferred shapes that cuDNN accepts.validate()also accepted graphs that lowering, the backend or every engine then rejected, and convolution and resample shape inference could overflow int64 into a wrong output shape. This change makesvalidate()reject the bad graphs with an error code, infer the shapes cuDNN infers, assign tensor UIDs deterministically, and corrects header examples and reference docs that contradicted the code.JIRA ID : ALMIOPEN-3314
JIRA ID : ALMIOPEN-3320
JIRA ID : ALMIOPEN-3321
JIRA ID : ALMIOPEN-3331
JIRA ID : ALMIOPEN-3383
JIRA ID : ALMIOPEN-3384
JIRA ID : ALMIOPEN-3385
JIRA ID : ALMIOPEN-3389
JIRA ID : ALMIOPEN-3402
JIRA ID : ALMIOPEN-3403
JIRA ID : ALMIOPEN-3404
JIRA ID : ALMIOPEN-3405
JIRA ID : ALMIOPEN-3376
JIRA ID : ALMIOPEN-3342
JIRA ID : ALMIOPEN-3344
JIRA ID : ALMIOPEN-3333
Risk Assessment
Risk 3 of 5. Frontend validation is on every graph's path, and graphs that passed
validate()before can now fail it when their operand shapes are inconsistent or when they use a value hipDNN cannot lower. A search of the samples, Python tests, test SDK, tools and provider tests found no in-repo graph that the new checks reject, apart from existing tests that relied on the old behavior: C++ and Python block-scale dequantize tests that sized the scale by the channel dimension, and resample node tests that set no mode. Those tests are updated. The NVIDIA samples fetched at build time were not searched. The layer-norm normalized dimension count comes from the scale: a lower-rank scale equal to X's trailing dimensions normalizes all of them, as before (x[2,1,14,14]with scale[1,14,14]gives 3), and any other scale is right-aligned to X's rank with leading 1s, so its first dimension that is not 1 starts the normalized range (x[2,3,4,5]with scale[1,5]gives 1). Layer-norm graphs with unit dimensions after the first normalized one (x[N,C,1,1], scale[1,C,1,1]) get a count of 3 instead of 1. A graph serialized with the old count failsvalidate()afterdeserialize(), with a message naming the count, and must be serialized again; count 1 normalized only a size-1 dimension, so such a graph never computed a layer norm. A channels-first scale (x[N,C,H,W], scale[1,C,1,1]), which cuDNN accepts, is now rejected withINVALID_VALUE, because no provider normalizes non-trailing axes and an earlier hipDNN read out of bounds.Some failures move earlier with the same outcome. A pointwise mode, resample mode, padding mode or data type with no hipDNN backend value used to fail at build or plan creation and now fail in
validate(). An SDPA forward graph with dropout but no seed or offset is now rejected invalidate()rather than with "no engine". Graphs that set no tensor UIDs get them in node order, so their serialized form differs from what earlier builds produced, and graphs built with the same setter order and standard library now serialize to identical UIDs. A batch norm momentum without previous running statistics, and resamplegenerate_indexwith a mode other than MAXPOOL, are accepted and ignored, as in cuDNN; resample lowersgenerate_indexas false for those modes.INode::gather_hipdnn_tensorsnow takesdetail::OrderedTensorSet&instead of astd::unordered_set; no node outside the frontend overrides it in this repository or the providers, but an out-of-tree node class that does must change its signature.ASIC Coverage
No ASIC impact: every change is host-side graph validation, shape inference and UID assignment in the header-only frontend, plus documentation, and the tests are host-only. Passing PR CI is sufficient: the hipDNN Superbuild lanes build Linux and Windows and run the host tests. Multi-Arch CI ran the gfx94X GPU lanes (hipdnn, hipdnn-integration-tests, hipdnn-samples, hipdnn-cudnn-samples, hipblasltprovider, hipkernelprovider, miopenprovider, sanity) and all passed. The gfx950 and gfx110X test lanes were still running when this was written.
Testing Summary
developand the new tests kept, 168 of 175 new or changed cases from the first commit fail or crash (45 with SIGFPE or SIGSEGV). The other 7 cover inputs thatdevelopalready handled.HIPDNN_ENABLE_SDPA,HIPDNN_ENABLE_CUDNN_COMPATIBILITYandHIPDNN_ENABLE_KERNEL_INGESTORon.Testing Checklist
ctest -L '^unit$'(Python tooling suites excluded) - Status: Passed (66/66 entries on the first commit; on the latest, the 9 entries that compile the frontend, merged withdevelop: 6909 cases, 4 skipped for missing hardware or data cases)hipdnn_public_frontend_testswithout the GPU execute, autotune, plan-finding and handle suites - Status: Passed (534/534 cases)pytestinpython/frontend_wheel_package/tests- Status: Passed in the automated GitHub checks (Windows Superbuild pytest: 676 passed, 125 skipped; the Linux Superbuild runs the same step and passed)Technical Changes
MatmulNode.hpp: a user-set C must have A's rank, the broadcast batch dimensions of A and B, A's rows and B's columns.BatchnormNode.hpp: the forward scale's channel count must match X; it is read at index 1 for[1,C,...]and at index 0 for[C]and[C,1,1]. Momentum without the previous running mean and variance is accepted and not sent to the backend.LayerNormNode.hpp,LayernormBackwardNode.hpp,detail/Utilities.hpp: one rule derives the normalized dimension count from the scale against X (a lower-rank scale equal to X's trailing dimensions normalizes all of them; any other lower-rank scale is right-aligned with leading 1s, then the first dimension that is not 1 starts the range), and an explicit count wins in the backward node, where a rank-reduced scale is accepted below it; scale and bias must match X's normalized dimensions; statistics have the rank of X or only its batch dimensions, in both directions; a rank-reduced scale[D]on X[B,S,D]infers statistics[B,S,1]. Unset scale and bias dimensions are inferred as cuDNN infers them,[1, X1..], or X's trailing dimensions when the count is set. All checks run on the firstvalidate().ConvolutionFpropNode.hpp,ConvolutionDgradNode.hpp,ConvolutionWgradNode.hpp,node/detail/CheckedShapeMath.hpp: shape terms use checked int64 arithmetic and a term that overflows is rejected; channel dimensions are checked before the group arithmetic divides by them.ResampleFwdNode.hpp,ResampleBwdNode.hpp,detail/ResampleParamsValidation.hpp: supplied window, stride and padding vectors must have one value per spatial dimension, a window and stride of at least 1 and padding of at least 0; output extents use cuDNN's formula with checked arithmetic, and an inferred extent below 1 is rejected. Forward requires a padding mode and accepts and ignoresgenerate_indexfor modes other than MAXPOOL, lowering it as false; both directions reject resample and padding modes with no backend value.TensorAttributes.hpp,PointwiseNode.hpp: data types and pointwise modes with no backend value are rejected, through the same mappers lowering uses.BlockScaleQuantizeNode.hpp,BlockScaleDequantizeNode.hpp: the scale has X's rank; dequantize block sizes align to the trailing dimensions and each scale dimension is at least ceil(X / block).MoeGroupedMatmulNode.hpp: SCATTER requires as many routed rows as token rows. Routing tensors a mode does not use are documented as ignored.SdpaFwdNode.hpp: a non-zero dropout probability needs seed and offset, and cannot be combined with a custom dropout mask (ATTRIBUTE_NOT_SET);padding_maskneeds query and key/value lengths, where a ragged Q supplies the query lengths; bias leading dimensions broadcast against the batch and Q head counts.Graph.hpp,node/Node.hpp,detail/GraphTensorIds.hpp: builders skip naming a null tensor argument instead of dereferencing it, sovalidate()reportsATTRIBUTE_NOT_SET. Ragged-offset tensors join the duplicate-UID check and are validated; custom ops and batch-norm peer statistics gather them. Tensors are collected in node order, so UIDs are assigned deterministically.detail/GraphDetail.hpp: engine configurations are trimmed to the count the backend returns.TensorAttributes.hpp,Attributes.hpp,SdpaAttributes.hpp,CustomOpNode.hpp,CustomOpAttributes.hpp: equality compares alignment and ragged layout, an absent optional tensor equals a null one, SDPA strict equality includes the fused-multiply-add hint, and custom ops support equality.PointwiseNode.hpp,detail/Utilities.hpp: broadcasting aligns trailing dimensions (NumPy rules, as cuDNN); the operand check follows the mode's arity, surplus operands are accepted and left out of the operation and of its autotune match key; a null input reportsATTRIBUTE_NOT_SET.ReductionNode.hpp: output strides are inferred from the output dimensions; an output without dimensions, already rejected, gets a message saying the dimensions must be set.attributes/*.hpp,HeuristicPolicyInfo.hpp,hipdnn_backend.h,Environment.md,PluginDevelopment.md,miopen-plugin.rst, FlyDSLCOVERAGE.md): convolution backward dilation, RMSNorm scale shape,Error::get_message, deprecated knobs, block sizes, pointwise mode names, reduction dimensions, heuristic policy order, engine plugin versions, plugin path changes with a live handle, MIOpen batch-norm running statistics and pass-by-value dropout seeds now match the code.KNOWN_DIVERGENCES.md,PortingGuide.md,plugins.rst: the checks stricter than cuDNN; the layer-norm normalization rule. Reviewers approved the stricter checks (int64 overflow, matmul C, batch norm channel count, layer-norm trailing dimensions, channels-first layer-norm scale) on 2026-11-20 because each prevents an out-of-bounds read or a graph that is guaranteed to fail later.Related: #13970