CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
83 lines
2.4 KiB
Python
83 lines
2.4 KiB
Python
"""Tests for perfxpert.tools.sol — including anti-Sakana reward-hacking defense."""
|
||
|
||
import pytest
|
||
|
||
from perfxpert.tools import sol
|
||
from perfxpert.tools._class import ToolClass
|
||
|
||
|
||
# -- sanity_check (anti-Sakana) --------------------------------------------
|
||
|
||
def test_claimed_speedup_within_sol_passes():
|
||
"""Normal optimization — 2× speedup on fp64 kernel ~ 40 TFLOPS on MI300X (peak 81.7)."""
|
||
r = sol.sanity_check(
|
||
achieved_flops_per_sec=40e12,
|
||
kernel_type="fp64",
|
||
gfx_id="gfx942",
|
||
)
|
||
assert r["plausible"] is True
|
||
|
||
|
||
def test_claimed_speedup_exceeding_sol_rejected():
|
||
"""Sakana-style: claim 500 TFLOPS fp64 on MI300X whose peak is 81.7."""
|
||
r = sol.sanity_check(
|
||
achieved_flops_per_sec=500e12,
|
||
kernel_type="fp64",
|
||
gfx_id="gfx942",
|
||
)
|
||
assert r["plausible"] is False
|
||
assert "exceeds" in r["reason"].lower() or "peak" in r["reason"].lower()
|
||
assert r["sol_peak"] == 81.7e12
|
||
|
||
|
||
def test_fp32_variant():
|
||
"""MI300X FP32 peak = 163.4 TFLOPS."""
|
||
r = sol.sanity_check(
|
||
achieved_flops_per_sec=150e12,
|
||
kernel_type="fp32",
|
||
gfx_id="gfx942",
|
||
)
|
||
assert r["plausible"] is True
|
||
|
||
|
||
def test_bf16_variant():
|
||
"""MI300X BF16 peak = 1307 TFLOPS (matrix)."""
|
||
r = sol.sanity_check(
|
||
achieved_flops_per_sec=1000e12,
|
||
kernel_type="bf16",
|
||
gfx_id="gfx942",
|
||
)
|
||
assert r["plausible"] is True
|
||
|
||
|
||
def test_unknown_kernel_type_raises():
|
||
# gpu_specs.yaml now exposes peak_fp16_tflops on every arch (Phase
|
||
# 10 Live-Roofline extension) so "fp16" is no longer an unknown
|
||
# kernel_type. Use a token that will stay unknown forever.
|
||
with pytest.raises(ValueError):
|
||
sol.sanity_check(achieved_flops_per_sec=1e12, kernel_type="fp42", gfx_id="gfx942")
|
||
|
||
|
||
# -- classify_utilization --------------------------------------------------
|
||
|
||
def test_utilization_high():
|
||
assert sol.classify_utilization(0.85)["category"] == "high"
|
||
|
||
|
||
def test_utilization_medium():
|
||
assert sol.classify_utilization(0.60)["category"] == "medium"
|
||
|
||
|
||
def test_utilization_low():
|
||
assert sol.classify_utilization(0.20)["category"] == "low"
|
||
|
||
|
||
def test_utilization_out_of_range_raises():
|
||
with pytest.raises(ValueError):
|
||
sol.classify_utilization(1.5)
|
||
|
||
|
||
def test_is_read_only_class():
|
||
assert sol.sanity_check.__tool_class__ == ToolClass.READ_ONLY
|
||
assert sol.classify_utilization.__tool_class__ == ToolClass.READ_ONLY
|