mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-11-14 18:24:37 -06:00
The toolchain folder is now binder/, and the root ./binder symlink is gone. The command is ./binder/binder: a plain path to the script, with no link and no install step. Every invocation moved with it: pre-commit entries, workflow steps, the VS Code extension's command palette, help text, and docs. - bindery/ paths and bindery.* imports, including the chapter code cells that import binder.tools.figures, now name binder/. - Binder (mybinder.org) reads its configuration from a root binder/ folder and refuses to build when binder/ and .binder/ both exist. .binder/postBuild and .binder/requirements.txt move into binder/, so the TinyTorch "Launch Binder" buttons keep working; binder/README.md records which file names the toolchain must not use there. - contributors/projects.json still pointed the book's contributor record at publishing/; it now names binder/, where that .all-contributorsrc lives. - The margin-figure reader-link audit report linked its 222 figures through the retired quarto/ tree; the links now resolve under books/. The hooks reformatted hidden Python cells and trimmed whitespace in the Volume II chapters whose figure imports this rename touches. Checks: ./binder/binder check cli passes (contract and canonical hooks), binder.tools.figures imports, and every workflow YAML file parses. binder test suite, excluding the four modules that cannot import mlsysim through the root symlink (fixed separately): 7 failed, 346 passed. The GitHub repository variables BOOK_ROOT, BOOK_TOOLS, BOOK_DEPS, and BOOK_DOCKER still name the retired book/ layout and must change when this reaches origin.
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
# test_registry.py
|
|
# Unit tests for the mlsysim Hardware and Models registries.
|
|
|
|
import unittest
|
|
from mlsysim import Hardware, Models
|
|
from mlsysim.core.units import ureg
|
|
|
|
class TestMLSysRegistry(unittest.TestCase):
|
|
def test_hardware_ridge_points(self):
|
|
"""Test that ridge points are calculated correctly and are positive."""
|
|
h100 = Hardware.Cloud.H100
|
|
ridge = h100.ridge_point()
|
|
self.assertGreater(ridge.magnitude, 0)
|
|
self.assertIn('flop', str(ridge.units))
|
|
self.assertIn('B', str(ridge.units))
|
|
|
|
# H100: ~2 PFLOPS / 3.35 TB/s = ~590 FLOP/byte
|
|
self.assertGreater(ridge.magnitude, 100)
|
|
self.assertLess(ridge.magnitude, 1000)
|
|
|
|
def test_model_size(self):
|
|
"""Test model weight storage calculations."""
|
|
gpt3 = Models.Language.GPT3
|
|
from mlsysim.core.units import BYTES_FP16, BYTES_INT4
|
|
|
|
# GPT-3 175B @ FP16 (2 bytes) = 350 GB
|
|
size_fp16 = gpt3.size_in_bytes(BYTES_FP16)
|
|
self.assertAlmostEqual(size_fp16.to('GB').magnitude, 350, delta=1)
|
|
|
|
# GPT-3 175B @ INT4 (0.5 bytes) = 87.5 GB
|
|
size_int4 = gpt3.size_in_bytes(BYTES_INT4)
|
|
self.assertAlmostEqual(size_int4.to('GB').magnitude, 87.5, delta=1)
|
|
|
|
def test_assertions(self):
|
|
"""Test that unrealistic hardware/models trigger assertions."""
|
|
from mlsysim.hardware.types import HardwareNode
|
|
from pydantic import ValidationError
|
|
|
|
# Non-positive bandwidth
|
|
with self.assertRaises(ValidationError):
|
|
HardwareNode(name="Broken", release_year=2024, compute={"peak_flops": "not a number"}, memory={"capacity": "1 GB", "bandwidth": "0 GB/s"})
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|