Files
cs249r_book/mlsysim/tests/test_hardware.py
Vijay Janapa Reddi a78f1bd8b0 feat(mlsysim): add documentation site, typed registries, and 6-solver core
Complete MLSYSIM v0.1.0 implementation with:

- Documentation website (Quarto): landing page with animated hero
  and capability carousel, 4 tutorials (hello world, LLM serving,
  distributed training, sustainability), hardware/model/fleet/infra
  catalogs, solver guide, whitepaper, math foundations, glossary,
  and full quartodoc API reference
- Typed registry system: Hardware (18 devices across 5 tiers),
  Models (15 workloads), Systems (fleets, clusters, fabrics),
  Infrastructure (grid profiles, rack configs, datacenters)
- Core types: Pint-backed Quantity, Metadata provenance tracking,
  custom exception hierarchy (OOMError, SLAViolation)
- SimulationConfig with YAML/JSON loading and pre-validation
- Scenario system tying workloads to systems with SLA constraints
- Multi-level evaluation scorecard (feasibility, performance, macro)
- Examples, tests, and Jetson Orin NX spec fix (100 → 25 TFLOP/s)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 15:59:51 -05:00

32 lines
1020 B
Python

import pytest
from pydantic import ValidationError
from mlsysim.hardware import Hardware, HardwareNode
from mlsysim.core.constants import Q_
def test_hardware_registry():
a100 = Hardware.A100
assert a100.name == "NVIDIA A100"
assert a100.release_year == 2020
assert a100.compute.peak_flops.magnitude == 312.0
# Check ridge point calculation
ridge = a100.ridge_point()
assert "flop/B" in str(ridge.units) or "flop / byte" in str(ridge.units)
assert 100 < ridge.magnitude < 200 # ~153
def test_hardware_validation():
# Should raise error on invalid quantity string
with pytest.raises(ValidationError):
HardwareNode(
name="Broken",
release_year=2025,
compute={"peak_flops": "not a number"},
memory={"capacity": "10 GiB", "bandwidth": "100 GB/s"}
)
def test_json_serialization():
a100 = Hardware.A100
json_data = a100.model_dump_json()
assert "NVIDIA A100" in json_data
assert "312" in json_data