← Back to Pull requests

microbenchmarks: use pytest as execution backend #726

Closed
unknown closed this pull request without merging on Nov 20, 2026 22:35 UTC
View on GitHub
unknown unknown commented on Aug 31, 2026 23:10 UTC
Author

Description

  • The dashboard itself is outside TE: https://github.com/AMD-ROCm-Internal/TE-dashboard

  • Migrates the microbenchmarks from standalone argparse scripts to a pytest runner; each benchmark becomes a (parametrized) pytest, replacing the run_benchmarks() driver

  • Shape/precision/backend/direction sweeps are parametrize axes, filterable via -k/-m (e.g. -k "mxfp8 and hipkittens", -k "bwd and QKV")

  • Inspired by pytest-benchmark and similar functionality in usv (but does not add any extra required dependencies)

  • Reuses the torch.utils.benchmark timing, rotating input buffers

  • Advantages over the previous run_benchmarks() driver:

  • - Benchmark selection/filtering (e.g., "run all mxfp8 GEMM benchmarks") without code changes
    - Direct integration of non-default backends (triton, ck_tile, hipkittens, flydsl)
    - More consistent console output (incl. markdown table formatting)
    - CPU pinning/frequency governor
    - Setting GPU_MAX_HW_QUEUES
    - Direct generation of dashboard-compatible runs
    - Potential future benefit: pass/fail regression gating
  • Additional improvements in this PR:

  • - GPU interference check: before running, warns when another process is already using the benchmark GPU (may skew timings); pass --abort-on-gpu-interference to fail instead. Needs amdsmi package (no-op without it).
    - Throughput aggregation output
  • Example usage:

  •   # pytest: MXFP8 GEMM, HipKittens backend, backward only, save CSV + per-sample data
      python -m pytest benchmark_gemm.py -k "mxfp8 and hipkittens and bwd" --csv --csv-samples
      
      # standalone (still runs through pytest): Llama3 shapes, Triton backend, no input rotation
      python benchmark_gemm.py -k "Llama3 and triton" --no-rotating --csv
      

      $ python benchmark_casting.py -k "Qwen and 72B and not dequantize and mxfp8-E4M3" -v --kernel-profile
    
      ========================================================================= test session starts =========================================================================
      platform linux -- Python 3.12.3, pytest-9.1.1, pluggy-1.6.0 -- /opt/venv/bin/python
      cachedir: .pytest_cache
      rootdir: /dockerx/TransformerEngine
      configfile: pyproject.toml
      collected 360 items / 352 deselected / 8 selected
      
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M1024] PASSED                                                                               [ 12%]
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M2048] PASSED                                                                               [ 25%]
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M4096] PASSED                                                                               [ 37%]
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M8192] PASSED                                                                               [ 50%]
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M1024] PASSED                                                                            [ 62%]
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M2048] PASSED                                                                            [ 75%]
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M4096] PASSED                                                                            [ 87%]
      benchmark_casting.py::test_cast[Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M8192] PASSED                                                                            [100%]
      
      benchmark: 8 tests
      
      | Benchmark | Config                                       | Wall Median (ms) | Wall Throughput | Kernel Median (ms) | Kernel Throughput |
      | :-------- | :------------------------------------------- | ---------------: | --------------: | -----------------: | ----------------: |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M1024    |           0.0085 |    2987.78 GB/s |             0.0083 |      3050.48 GB/s |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M2048    |           0.0145 |    3519.02 GB/s |             0.0143 |      3548.89 GB/s |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M4096    |           0.0251 |    4050.32 GB/s |             0.0247 |      4111.69 GB/s |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-hip-M8192    |           0.0397 |    5124.33 GB/s |             0.0392 |      5182.93 GB/s |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M1024 |           0.0184 |    1357.53 GB/s |             0.0099 |      2556.67 GB/s |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M2048 |           0.0185 |    2739.02 GB/s |             0.0184 |      2768.89 GB/s |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M4096 |           0.0302 |    3371.57 GB/s |             0.0303 |      3351.91 GB/s |
      | casting   | Qwen2.5-72B-mxfp8-e4m3-quantize-triton-M8192 |           0.0561 |    3628.13 GB/s |             0.0559 |      3637.62 GB/s |
      
      aggregate throughput (work-weighted harmonic mean over shapes): 2 groups
      
      | Benchmark | Group                                                 | n | Wall Throughput | Kernel Throughput |
      | :-------- | :---------------------------------------------------- | : | --------------: | ----------------: |
      | casting   | Format=mxfp8-e4m3  Direction=quantize  Backend=hip    | 4 |    4345.66 GB/s |      4401.74 GB/s |
      | casting   | Format=mxfp8-e4m3  Direction=quantize  Backend=triton | 4 |    3091.67 GB/s |      3328.87 GB/s |
      =================================================================== 8 passed, 352 deselected in 2.70s ==================================================================
      

    Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • Infra/Build change

  • Code refactoring
  • Changes

    Please list the changes introduced in this PR:

  • Change A

  • Change B
  • Checklist:

  • I have read and followed the contributing guidelines

  • The functionality is complete

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation

  • My changes generate no new warnings

  • I have added tests that prove my fix is effective or that my feature works

  • New and existing unit tests pass locally with my changes
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: matthiasdiener Review duration: 116605m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.57) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #726"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 57% (MEDIUM) · Higher = larger blast radius
    57%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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.7% · Safe to merge
    24.7%