Files
OpenJarvis/tests/hardware/test_amd.py
T
Jon Saad-FalconandClaude Opus 4.6 990d7d8a79 Expand test suite to 1031 tests: new agents, tools, MCP layer, model catalog
Add ReAct and OpenHands agents, WebSearch and CodeInterpreter tools,
full MCP protocol layer (server/client/transport), Gemini cloud engine
support, 12 new model specs (4 local MoE + 8 cloud), trace system,
and comprehensive test coverage across all dimensions (hardware, engine,
memory, agents, tools, MCP, integration).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 04:59:11 +00:00

114 lines
3.5 KiB
Python

"""AMD-specific hardware tests."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from openjarvis.core.config import (
GpuInfo,
HardwareInfo,
_detect_amd_gpu,
recommend_engine,
)
pytestmark = pytest.mark.amd
# ---------------------------------------------------------------------------
# Detection / rocm-smi parsing
# ---------------------------------------------------------------------------
class TestAMDDetection:
"""Tests for _detect_amd_gpu() against various rocm-smi outputs."""
@patch("openjarvis.core.config.shutil.which", return_value="/usr/bin/rocm-smi")
@patch(
"openjarvis.core.config._run_cmd",
return_value="AMD Instinct MI300X",
)
def test_rocm_smi_parsing(self, mock_run, mock_which):
gpu = _detect_amd_gpu()
assert gpu is not None
assert gpu.vendor == "amd"
assert "MI300X" in gpu.name
@patch("openjarvis.core.config.shutil.which", return_value=None)
def test_rocm_smi_not_found(self, mock_which):
assert _detect_amd_gpu() is None
@patch("openjarvis.core.config.shutil.which", return_value="/usr/bin/rocm-smi")
@patch(
"openjarvis.core.config._run_cmd",
return_value="AMD Instinct MI250X\nAMD Instinct MI250X",
)
def test_amd_gpu_model(self, mock_run, mock_which):
"""First line of rocm-smi output is used as the GPU name."""
gpu = _detect_amd_gpu()
assert gpu is not None
assert "MI250X" in gpu.name
@patch("openjarvis.core.config.shutil.which", return_value="/usr/bin/rocm-smi")
@patch("openjarvis.core.config._run_cmd", return_value="")
def test_rocm_smi_empty_output(self, mock_run, mock_which):
"""Empty output from rocm-smi returns None."""
assert _detect_amd_gpu() is None
@patch("openjarvis.core.config.shutil.which", return_value="/usr/bin/rocm-smi")
@patch(
"openjarvis.core.config._run_cmd",
return_value="AMD Instinct MI300X",
)
def test_amd_vram(self, mock_run, mock_which):
"""AMD detection does not parse VRAM; defaults to 0.0."""
gpu = _detect_amd_gpu()
assert gpu is not None
assert gpu.vram_gb == 0.0
# ---------------------------------------------------------------------------
# Engine recommendation
# ---------------------------------------------------------------------------
class TestAMDEngineRecommendation:
"""Tests that AMD cards map to vllm."""
def test_mi300x_recommends_vllm(self):
hw = HardwareInfo(
platform="linux",
cpu_brand="AMD EPYC 9654",
cpu_count=96,
ram_gb=768.0,
gpu=GpuInfo(
vendor="amd", name="AMD Instinct MI300X",
vram_gb=192.0, count=1,
),
)
assert recommend_engine(hw) == "vllm"
def test_amd_generic_recommends_vllm(self):
hw = HardwareInfo(
platform="linux",
cpu_brand="AMD EPYC",
cpu_count=64,
ram_gb=256.0,
gpu=GpuInfo(vendor="amd", name="AMD GPU", vram_gb=0.0, count=1),
)
assert recommend_engine(hw) == "vllm"
def test_amd_multi_gpu_recommends_vllm(self):
hw = HardwareInfo(
platform="linux",
cpu_brand="AMD EPYC 9654",
cpu_count=128,
ram_gb=1024.0,
gpu=GpuInfo(
vendor="amd", name="AMD Instinct MI300X",
vram_gb=192.0, count=4,
),
)
assert recommend_engine(hw) == "vllm"