← Back to Pull requests

fix(miopen): correct CheckNumerics statistics (ALMIOPEN-3391) #16143

Open
unknown opened this pull request with 539 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 17, 2026 19:04 UTC
Author

JIRA ID: ALMIOPEN-3391
Tracking: ALMIOPEN-3391.
Related PR: #12733.

Motivation

CheckNumerics could silently omit statistics and report incorrect extrema for same-sign, zero, infinity, and BF16-subnormal inputs. Its excessive block cap also causes statistics-atomic contention once the global launch size is corrected.

This submits the numerics defects independently of #12733's native-BF16 migration, from develop at 951ff1461d4. BF16 types, depthwise kernels, and HIPRTC disk-header include behavior remain unchanged. #12733 still contains overlapping numerics fixes.

Landing order: merge #16143 first. Then refresh #12733 from develop, remove redundant numerics changes from its diff, and retain the native-BF16 migration and related cleanup. The numerics overlap remains until that refresh; no merge or source split is claimed here.

Technical Details

  • Normalize the statistics argument to the kernel's bool type and launch blocks 256 global work-items.

  • Use positive/negative infinity extrema identities on host and device, with float extrema reductions for every supported dtype. Add float infinity to the HIPRTC limits shim.

  • Bound the grid-stride loop to eight blocks per hardware compute unit, without assuming a CDNA thread/wave limit.

  • Add 34 Smoke regressions covering FP32/FP16/BF16 extrema, zero/NaN/infinity flags, BF16 subnormals, idle blocks, FP8/BF8 finite values and NaNs, and host statistics with Info plus ComputeStats.
  • The host cases verify numerical results and a grid-stride tail, not exact launch geometry. Neither the direct-kernel cases nor FiniteGridStride distinguishes the old global-thread count from numBlocks threadsPerBlock; reverting that multiplier can still leave these permanent tests passing. No permanent geometry assertion is claimed. Scoped test environments restore prior settings. The fixture obtains legacy FP8/BF16 host aliases from the existing test helpers, so it does not depend on #12733's header cleanup.

    Empty tensors return false before allocation or GPU launch. Element counts retain the descriptor's size_t value instead of narrowing to int. The regression fixture uses the existing JSON deserializer to create an actual zero-element descriptor and calls the host input check with nullptr; that deserializer is made visible only in test-enabled builds, without changing normal-build visibility or the public C API.

    Risk Assessment

    Risk Level: Medium — changes the shared CheckNumerics reduction and debug-check launch geometry, including FP8/BF8 consumers. No public API, tensor-storage ABI, BF16 type migration, or convolution change.

    Test Plan

    Repeat test_check_numerics --gtest_filter='Smoke/' on gfx950 or gfx12 to exercise IEEE-exponent-bias FP8/BF8 encodings; gfx942 and gfx1170 exercise FNUZ. Run HIP-mode clang-tidy with a frontend matching the HIP development headers.

    The current branch head is 4b1d76148d2. Its numerics host/kernel, limits shim, descriptor header,
    environment registry, and regression fixture are unchanged from 8d63d8d744d, but the complete
    merged build has not been revalidated here.

    Test Result

    Tested revision: 8d63d8d744d. Standalone Release HIP build with isolated caches and
    ROCM_PATH unset; optional CK/hipconv/MLIR paths were disabled.

  • On gfx942, test_check_numerics --gtest_filter='Smoke/' passed 34/34 cases without skips, including the empty-tensor host case.

  • After final formatting and rebuild, ctest --output-on-failure --no-tests=error -R CheckNumerics passed 10/10, including all three host cases.

  • The actual host input check with MIOPEN_CHECK_NUMERICS=0x11 returned false for zero elements. A real 4,294,967,296-element FP8 tensor reported expected min=1, max=1, and mean=1, showing that its count was not narrowed to an empty tensor.

  • Scoped pre-commit hooks and source-level gtest naming checks passed.
  • These are targeted gfx942 results, not a full MIOpen suite, a new RDNA/gfx950 or IEEE
    FP8-mode run, or a complete clang-tidy pass.

    [ALMIOPEN-3391]: https://amd-hub.atlassian.net/browse/ALMIOPEN-3391?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 539 lines (+404 / -135) across 6 files Reviewer: JonathanLichtnerAMD Review duration: 19450m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 539 lines diff across 6 files
    0.48
    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.376
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #16143"
    general weight: 0.35
    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: 48.0% (MEDIUM) · Higher = larger blast radius
    48.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: 25.6% · Safe to merge
    25.6%