Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
feat(doctor): add GPU architecture and precision diagnostics (#947)
Samarth Mukhijac252f49519f3
diff --git a/changelog.d/0.75.1/947.added.md b/changelog.d/0.75.1/947.added.mdnew file mode 100644index 00000000..5cee5407--- /dev/null+++ b/changelog.d/0.75.1/947.added.md@@ -0,0 +1 @@+- **`soup doctor` now reports GPU architecture and precision capability diagnostics (#829 by @Samearth17 in #947).** GPU diagnostics show the detected NVIDIA compute capability and architecture, whether the installed Torch build includes native/PTX support for that GPU, and hardware/software support for BF16, FP8, and NVFP4. Unsupported GPU architectures now include a CUDA-enabled PyTorch reinstall hint.diff --git a/docs/backends-and-ops.md b/docs/backends-and-ops.mdindex e9db59f5..9a25854b 100644--- a/docs/backends-and-ops.md+++ b/docs/backends-and-ops.md@@ -553,6 +553,16 @@ soup doctor [--nccl]Shows: Python version, GPU availability, system resources (RAM/Disk), all dependency versions, and fix suggestions. Use `--nccl` to measure and check multi-GPU communication bandwidth against expected hardware ceilings.+### GPU diagnostics++When an NVIDIA GPU is available, `soup doctor` reports its compute capability+and architecture family, whether the installed PyTorch build contains native+or PTX support for that architecture, and the hardware/software gates for+BF16, FP8, and NVFP4. A missing architecture warning includes a CUDA-enabled+PyTorch reinstall hint based on the CUDA version reported by the driver. When+the driver version cannot be mapped to a supported wheel, the hint remains+actionable without constructing a `whl/None` URL.+## Version Infodiff --git a/src/soup_cli/commands/doctor.py b/src/soup_cli/commands/doctor.pyindex 6216040d..ba8496b2 100644--- a/src/soup_cli/commands/doctor.py+++ b/src/soup_cli/commands/doctor.py@@ -473,6 +473,100 @@ def _check_mlx():)+def _gpu_architecture_name(major: int, minor: int) -> str:+ """Return the NVIDIA architecture family for a compute capability."""+ if major >= 12 or major in (10,):+ return "Blackwell"+ if major == 9:+ return "Hopper"+ if major == 8 and minor == 9:+ return "Ada"+ if major == 8:+ return "Ampere"+ if major == 7 and minor in (5,):+ return "Turing"+ if major == 7 and minor in (0, 2):+ return "Volta"+ if major == 6 and minor in (0, 1):+ return "Pascal"+ return "Unknown"+++def _torch_gpu_arch_supported(torch, major: int, minor: int) -> bool:+ """Return whether Torch has native or PTX coverage for this GPU."""+ try:+ arch_list = torch.cuda.get_arch_list()+ except (AttributeError, RuntimeError):+ return False++ target = major * 10 + minor+ for arch in arch_list:+ if arch.startswith("sm_"):+ sm_target = arch.removeprefix("sm_")+ suffixed = sm_target.endswith("a")+ sm_target = sm_target.rstrip("a")+ try:+ target_major = int(sm_target) // 10+ target_minor = int(sm_target) % 10+ except ValueError:+ continue+ if suffixed and sm_target == f"{major}{minor}":+ return True+ if (+ not suffixed+ and target_major == major+ and target_minor <= minor+ ):+ return True+ if arch.startswith("compute_"):+ try:+ ptx_target = int(arch.removeprefix("compute_").rstrip("a"))+ except ValueError:+ continue+ if ptx_target <= target:+ return True++ return False+++def _format_gpu_capability(torch, idx: int) -> tuple[str, bool]:+ """Return ``(capability_text, supported_by_torch)`` for one GPU."""+ try:+ major, minor = torch.cuda.get_device_capability(idx)+ except (AttributeError, RuntimeError, AssertionError):+ return "unknown", False++ architecture = _gpu_architecture_name(major, minor)+ supported = _torch_gpu_arch_supported(torch, major, minor)+ return f"sm_{major}{minor} ({architecture})", supported+++def _get_precision_capabilities(torch) -> dict[str, tuple[bool, bool | None]]:+ """Return hardware/software support for the reported precision features."""+ from soup_cli.utils.advanced_precision import (+ _torchao_available,+ is_blackwell_gpu,+ is_nvfp4_software_supported,+ )+ from soup_cli.utils.fp8 import is_fp8_gpu_supported++ try:+ from soup_cli.utils.gpu import cuda_supports_bf16++ bf16_supported = bool(cuda_supports_bf16())+ except (AttributeError, RuntimeError, AssertionError):+ bf16_supported = False++ torchao_available = bool(_torchao_available())+ nvfp4_software = bool(is_nvfp4_software_supported())++ return {+ "BF16": (bf16_supported, None),+ "FP8": (bool(is_fp8_gpu_supported()), torchao_available),+ "NVFP4": (bool(is_blackwell_gpu()), nvfp4_software),+ }++def _check_gpu():"""Check GPU availability and display info."""try:@@ -486,13 +580,45 @@ def _check_gpu():mem = torch.cuda.get_device_properties(idx)total_gb = getattr(mem, "total_memory", getattr(mem, "total_mem", 0))total_gb = total_gb / (1024**3)- gpus.append(f" GPU {idx}: [bold]{name}[/] ({total_gb:.1f} GB)")++ capability, torch_arch_supported = _format_gpu_capability(torch, idx)+ arch_warning = ""+ if not torch_arch_supported:+ advisory = _detect_gpu_arch_mismatch_advisory()+ arch_warning = (+ " [bold red]Torch build does not include this GPU "+ "architecture[/]"+ )+ if advisory:+ arch_warning += f" [dim]{advisory}[/]"++ gpus.append(+ f" GPU {idx}: [bold]{name}[/] "+ f"({total_gb:.1f} GB) — {capability}{arch_warning}"+ )gpu_info = "\n".join(gpus)cuda_ver = torch.version.cuda or "N/A"++ precision = _get_precision_capabilities(torch)+ precision_lines = []+ for feature, (hardware, software) in precision.items():+ hw_status = "[green]yes[/]" if hardware else "[red]no[/]"+ if software is None:+ precision_lines.append(f" {feature}: hardware={hw_status}")+ else:+ sw_status = "[green]yes[/]" if software else "[yellow]no[/]"+ precision_lines.append(+ f" {feature}: hardware={hw_status}, software={sw_status}"+ )++ precision_info = "\n".join(precision_lines)+console.print(Panel(f"CUDA: [bold green]available[/] (v{cuda_ver})\n"- f"GPUs: [bold]{gpu_count}[/]\n{gpu_info}",+ f"GPUs: [bold]{gpu_count}[/]\n{gpu_info}\n\n"+ "[bold]Precision features[/]\n"+ f"{precision_info}",title="GPU",))@@ -602,6 +728,30 @@ def _nvidia_smi_cuda_version() -> tuple[int, int] | None:return _parse_cuda_version((completed.stdout or "") + (completed.stderr or ""))+def _detect_gpu_arch_mismatch_advisory() -> str:+ """Return a CUDA wheel reinstall hint for an unsupported GPU architecture."""+ driver_cuda = _nvidia_smi_cuda_version()+ if driver_cuda is None:+ return (+ "Try reinstalling a CUDA-enabled PyTorch build that supports "+ "your GPU architecture."+ )++ wheel = _torch_cuda_wheel_tag(driver_cuda)+ if wheel is None:+ return (+ "Try reinstalling a CUDA-enabled PyTorch build that supports "+ "your GPU architecture. Run `nvidia-smi` and install a PyTorch "+ "CUDA wheel compatible with the reported driver."+ )++ index_url = f"https://download.pytorch.org/whl/{wheel}"+ return (+ "Reinstall a CUDA-enabled PyTorch build for your driver: "+ f"`pip install torch --index-url {index_url}`"+ )++def _detect_gpu_hw_without_torch_cuda() -> str:"""v0.40.1 Part C / N3 — return advisory string if nvidia-smi succeedsbut torch lacks CUDA (i.e. user installed the CPU-only wheel).diff --git a/src/soup_cli/utils/advanced_precision.py b/src/soup_cli/utils/advanced_precision.pyindex 99e1eeaa..bdd650ce 100644--- a/src/soup_cli/utils/advanced_precision.py+++ b/src/soup_cli/utils/advanced_precision.py@@ -316,6 +316,19 @@ def apply_fp8_attention(model: object, *, recipe: str = "tensorwise") -> int:return len(already_converted) + len(pending)+def is_nvfp4_software_supported() -> bool:+ """Return True when the installed torchao exposes NVFP4 training support."""+ try:+ from soup_cli.utils.torchao_compat import resolve_torchao_class++ resolve_torchao_class("NVFP4Training")+ resolve_torchao_class("quantize_")+ except Exception: # noqa: BLE001 — diagnostic probe must not crash+ return False++ return True++def apply_nvfp4(model: object) -> int:"""Quantise ``model`` with torchao's NVFP4 scheme (Blackwell-only).diff --git a/tests/test_doctor.py b/tests/test_doctor.pyindex e17501d8..cbaa4faa 100644--- a/tests/test_doctor.py+++ b/tests/test_doctor.py@@ -1,6 +1,5 @@"""Tests for soup doctor command."""-import reimport sysfrom unittest.mock import patch@@ -8,16 +7,16 @@ from typer.testing import CliRunnerfrom soup_cli.cli import appfrom soup_cli.commands.doctor import _version_ok+from tests.conftest import strip_ansirunner = CliRunner()-# Rich/Typer emits per-character ANSI escapes when colour is forced-# (FORCE_COLOR=1), which would break substring assertions on commands.-_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")+def _strip_ansi(text: str) -> str:+ return strip_ansi(text)-def _strip_ansi(text: str) -> str:- return _ANSI_RE.sub("", text)+def _plain(text: str) -> str:+ return " ".join(strip_ansi(text).split())# --- _version_ok tests ---@@ -64,60 +63,537 @@ def test_doctor_runs():"""soup doctor runs without crashing."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "Soup Doctor" in result.output+ assert "Soup Doctor" in _strip_ansi(result.output)def test_doctor_shows_system_info():"""soup doctor shows system info panel."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "Python" in result.output- assert "Platform" in result.output+ output = _strip_ansi(result.output)+ assert "Python" in output+ assert "Platform" in outputdef test_doctor_shows_dependencies():"""soup doctor shows dependency table."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "Dependencies" in result.output- assert "Package" in result.output+ output = _strip_ansi(result.output)+ assert "Dependencies" in output+ assert "Package" in output+++def test_gpu_arch_mismatch_advisory_uses_driver_cuda_wheel(monkeypatch):+ from soup_cli.commands.doctor import _detect_gpu_arch_mismatch_advisory++ monkeypatch.setattr(+ "soup_cli.commands.doctor._nvidia_smi_cuda_version",+ lambda: (13, 2),+ )++ advisory = _detect_gpu_arch_mismatch_advisory()++ assert "download.pytorch.org/whl/cu132" in advisory+ assert "pip install torch" in advisory+++def test_gpu_arch_mismatch_advisory_falls_back_for_unsupported_driver(+ monkeypatch,+):+ from soup_cli.commands.doctor import _detect_gpu_arch_mismatch_advisory++ monkeypatch.setattr(+ "soup_cli.commands.doctor._nvidia_smi_cuda_version",+ lambda: (11, 7),+ )++ advisory = _detect_gpu_arch_mismatch_advisory()++ assert "whl/None" not in advisory+ assert "CUDA-enabled PyTorch build" in advisory+++def test_format_gpu_capability_handles_missing_torch_cuda_attribute():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _format_gpu_capability++ fake_torch = SimpleNamespace(cuda=SimpleNamespace())++ assert _format_gpu_capability(fake_torch, 0) == ("unknown", False)+++def test_gpu_architecture_name_maps_legacy_nvidia_architectures():+ from soup_cli.commands.doctor import _gpu_architecture_name++ assert _gpu_architecture_name(6, 0) == "Pascal"+ assert _gpu_architecture_name(6, 1) == "Pascal"+ assert _gpu_architecture_name(7, 0) == "Volta"+ assert _gpu_architecture_name(7, 2) == "Volta"+ assert _gpu_architecture_name(7, 5) == "Turing"+++def test_torch_gpu_arch_supported_accepts_suffixed_sm_target():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(+ get_arch_list=lambda: ["sm_90a", "sm_100a"],+ )+ )++ assert _torch_gpu_arch_supported(fake_torch, 9, 0) is True+ assert _torch_gpu_arch_supported(fake_torch, 10, 0) is True+++def test_torch_gpu_arch_supported_accepts_exact_sm_target():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(+ get_arch_list=lambda: ["sm_90", "sm_120"],+ )+ )++ assert _torch_gpu_arch_supported(fake_torch, 12, 0) is True+++def test_torch_gpu_arch_supported_accepts_later_minor_same_major():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(+ get_arch_list=lambda: ["sm_75", "sm_80", "sm_86", "sm_90"],+ )+ )++ assert _torch_gpu_arch_supported(fake_torch, 8, 9) is True+++def test_torch_gpu_arch_supported_rejects_earlier_minor_same_major():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(get_arch_list=lambda: ["sm_86"])+ )++ assert _torch_gpu_arch_supported(fake_torch, 8, 0) is False+++def test_torch_gpu_arch_supported_keeps_suffixed_arch_exact():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(get_arch_list=lambda: ["sm_100a"])+ )++ assert _torch_gpu_arch_supported(fake_torch, 10, 3) is False+++def test_torch_gpu_arch_supported_accepts_lower_ptx_target():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(+ get_arch_list=lambda: ["sm_90", "compute_90"],+ )+ )++ assert _torch_gpu_arch_supported(fake_torch, 12, 0) is True+++def test_torch_gpu_arch_supported_rejects_higher_only_ptx_target():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(+ get_arch_list=lambda: ["sm_80", "compute_120"],+ )+ )++ assert _torch_gpu_arch_supported(fake_torch, 9, 0) is False+++def test_torch_gpu_arch_supported_accepts_a_suffixed_architectures():+ from types import SimpleNamespace++ from soup_cli.commands.doctor import _torch_gpu_arch_supported++ fake_torch = SimpleNamespace(+ cuda=SimpleNamespace(+ get_arch_list=lambda: ["sm_90a", "sm_100a"],+ )+ )++ assert _torch_gpu_arch_supported(fake_torch, 9, 0) is True+ assert _torch_gpu_arch_supported(fake_torch, 10, 0) is True+++def test_doctor_gpu_panel_shows_compute_capability_and_precision(monkeypatch):+ """GPU panel reports compute capability and precision feature gates."""+ import importlib.machinery+ import types++ fake_cuda = types.SimpleNamespace(+ is_available=lambda: True,+ device_count=lambda: 1,+ get_device_name=lambda idx: "NVIDIA GeForce RTX 5070 Laptop GPU",+ get_device_properties=lambda idx: types.SimpleNamespace(+ total_memory=8 * 1024**3+ ),+ get_device_capability=lambda idx: (12, 0),+ get_arch_list=lambda: ["sm_75", "sm_80", "sm_90", "sm_120"],+ is_bf16_supported=lambda including_emulation=True: True,+ )++ fake_torch = types.SimpleNamespace(+ __spec__=importlib.machinery.ModuleSpec("torch", None),+ cuda=fake_cuda,+ version=types.SimpleNamespace(cuda="13.0"),+ )++ monkeypatch.setitem(__import__("sys").modules, "torch", fake_torch)+ monkeypatch.setattr(+ "soup_cli.commands.doctor._installed_version_str",+ lambda import_name, pkg_name: None,+ )+ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_gpu_supported",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_available",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision.is_blackwell_gpu",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision._torchao_available",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.torchao_compat.resolve_torchao_class",+ lambda key: object,+ )++ fake_torchao = types.ModuleType("torchao")+ fake_quantization = types.ModuleType("torchao.quantization")+ fake_quantization.NVFP4Config = object+ fake_quantization.quantize_ = lambda *args, **kwargs: None+ fake_torchao.quantization = fake_quantization++ monkeypatch.setitem(__import__("sys").modules, "torchao", fake_torchao)+ monkeypatch.setitem(+ __import__("sys").modules,+ "torchao.quantization",+ fake_quantization,+ )++ result = runner.invoke(+ app,+ ["doctor"],+ env={"COLUMNS": "120", "FORCE_COLOR": "1"},+ )+ out = _plain(result.output)++ assert result.exit_code == 0+ assert "sm_120 (Blackwell)" in out+ assert "Precision features" in out+ assert "BF16: hardware=yes" in out+ assert "FP8: hardware=yes, software=yes" in out+ assert "NVFP4: hardware=yes, software=yes" in out+++def test_get_precision_capabilities_reports_negative_nvfp4_software(+ monkeypatch,+):+ """NVFP4 software support must report false when the runtime gate is absent."""+ import types++ fake_torch = types.SimpleNamespace(+ cuda=types.SimpleNamespace(+ is_bf16_supported=lambda including_emulation=True: True,+ )+ )++ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_gpu_supported",+ lambda: False,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision._torchao_available",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision.is_blackwell_gpu",+ lambda: True,+ )+ fake_torchao = types.ModuleType("torchao")+ fake_quantization = types.ModuleType("torchao.quantization")+ fake_quantization.quantize_ = lambda *args, **kwargs: None+ fake_torchao.quantization = fake_quantization+ monkeypatch.setitem(sys.modules, "torchao", fake_torchao)+ monkeypatch.setitem(sys.modules, "torchao.quantization", fake_quantization)++ from soup_cli.commands.doctor import _get_precision_capabilities++ result = _get_precision_capabilities(fake_torch)++ assert result["NVFP4"] == (True, False)+++def test_is_nvfp4_software_supported_requires_nvfp4_training_config(monkeypatch):+ from tests.test_v07121 import _install_fake_torchao_quant++ _install_fake_torchao_quant(monkeypatch, {}, with_nvfp4=False)++ from soup_cli.utils.advanced_precision import is_nvfp4_software_supported++ assert is_nvfp4_software_supported() is False+++def test_is_nvfp4_software_supported_accepts_nvfp4_training_config(monkeypatch):+ from tests.test_v07121 import _install_fake_torchao_quant++ _install_fake_torchao_quant(monkeypatch, {})++ from soup_cli.utils.advanced_precision import is_nvfp4_software_supported++ assert is_nvfp4_software_supported() is True+++def test_is_nvfp4_software_supported_requires_quantize(monkeypatch):+ from tests.test_v07121 import _install_fake_torchao_quant++ _install_fake_torchao_quant(monkeypatch, {})++ fake_quantization = sys.modules["torchao.quantization"]+ del fake_quantization.quantize_++ from soup_cli.utils.advanced_precision import is_nvfp4_software_supported++ assert is_nvfp4_software_supported() is False+++def test_get_precision_capabilities_requires_torchao_for_fp8_attention(+ monkeypatch,+):+ """FP8 software support follows the torchao-specific attention gate."""+ import types++ fake_torch = types.SimpleNamespace(+ cuda=types.SimpleNamespace(+ is_bf16_supported=lambda including_emulation=True: True,+ )+ )++ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_gpu_supported",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision._torchao_available",+ lambda: False,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision.is_blackwell_gpu",+ lambda: False,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision.is_nvfp4_software_supported",+ lambda: False,+ )++ from soup_cli.commands.doctor import _get_precision_capabilities++ result = _get_precision_capabilities(fake_torch)++ assert result["FP8"] == (True, False)+++def test_get_precision_capabilities_reports_negative_bf16(monkeypatch):+ """BF16 hardware support must reflect the real Torch probe."""+ import importlib.machinery+ import types++ fake_cuda = types.SimpleNamespace(+ is_bf16_supported=lambda including_emulation=True: False,+ )+ fake_torch = types.SimpleNamespace(+ __spec__=importlib.machinery.ModuleSpec("torch", None),+ cuda=fake_cuda,+ )+ monkeypatch.setitem(sys.modules, "torch", fake_torch)++ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_gpu_supported",+ lambda: False,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision.is_blackwell_gpu",+ lambda: False,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision._torchao_available",+ lambda: False,+ )++ from soup_cli.commands.doctor import _get_precision_capabilities++ result = _get_precision_capabilities(fake_torch)++ assert result["BF16"] == (False, None)+++def test_get_precision_capabilities_bf16_matches_trainer_gate_on_pre_ampere(+ monkeypatch,+):+ """Doctor must match the trainer's non-emulated BF16 hardware gate."""+ import importlib.machinery+ import types++ def is_bf16_supported(including_emulation=True):+ return including_emulation++ fake_torch = types.SimpleNamespace(+ __spec__=importlib.machinery.ModuleSpec("torch", None),+ cuda=types.SimpleNamespace(+ is_available=lambda: True,+ get_device_capability=lambda idx=0: (7, 5),+ is_bf16_supported=is_bf16_supported,+ ),+ )+ monkeypatch.setitem(sys.modules, "torch", fake_torch)+ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_gpu_supported",+ lambda: False,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision.is_blackwell_gpu",+ lambda: False,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision._torchao_available",+ lambda: False,+ )++ from soup_cli.commands.doctor import _get_precision_capabilities+ from soup_cli.utils.gpu import cuda_supports_bf16++ assert cuda_supports_bf16() is False+ assert _get_precision_capabilities(fake_torch)["BF16"] == (False, None)+++def test_doctor_gpu_panel_warns_when_torch_lacks_gpu_arch(monkeypatch):+ """GPU panel warns when Torch does not include the detected GPU architecture."""+ import importlib.machinery+ import types++ fake_cuda = types.SimpleNamespace(+ is_available=lambda: True,+ device_count=lambda: 1,+ get_device_name=lambda idx: "NVIDIA GeForce RTX 5070 Laptop GPU",+ get_device_properties=lambda idx: types.SimpleNamespace(+ total_memory=8 * 1024**3+ ),+ get_device_capability=lambda idx: (12, 0),+ get_arch_list=lambda: ["sm_75", "sm_80", "sm_90"],+ is_bf16_supported=lambda including_emulation=True: True,+ )++ fake_torch = types.SimpleNamespace(+ __spec__=importlib.machinery.ModuleSpec("torch", None),+ cuda=fake_cuda,+ version=types.SimpleNamespace(cuda="13.0"),+ )++ monkeypatch.setitem(__import__("sys").modules, "torch", fake_torch)+ monkeypatch.setattr(+ "soup_cli.commands.doctor._installed_version_str",+ lambda import_name, pkg_name: None,+ )+ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_gpu_supported",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.fp8.is_fp8_available",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision.is_blackwell_gpu",+ lambda: True,+ )+ monkeypatch.setattr(+ "soup_cli.utils.advanced_precision._torchao_available",+ lambda: True,+ )++ result = runner.invoke(+ app,+ ["doctor"],+ env={"COLUMNS": "120", "FORCE_COLOR": "1"},+ )++ assert result.exit_code == 0+ normalized = _plain(result.output)+ assert "Torch build" in normalized+ assert "architecture" in normalizeddef test_doctor_shows_gpu_section():"""soup doctor shows GPU section."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "GPU" in result.output+ assert "GPU" in _strip_ansi(result.output)def test_doctor_shows_system_resources():"""soup doctor shows System Resources section."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "System Resources" in result.output- assert "RAM" in result.output- assert "Disk" in result.output+ output = _strip_ansi(result.output)+ assert "System Resources" in output+ assert "RAM" in output+ assert "Disk" in outputdef test_doctor_checks_torch():"""soup doctor checks for torch."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "torch" in result.output+ assert "torch" in _strip_ansi(result.output)def test_doctor_checks_pydantic():"""soup doctor checks for pydantic."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "pydantic" in result.output+ assert "pydantic" in _strip_ansi(result.output)def test_doctor_checks_optional_deps():"""soup doctor shows optional deps."""result = runner.invoke(app, ["doctor"])assert result.exit_code == 0- assert "optional" in result.output+ assert "optional" in _strip_ansi(result.output)def test_doctor_missing_dep():@@ -130,7 +606,7 @@ def test_doctor_missing_dep():):result = runner.invoke(app, ["doctor"])assert result.exit_code == 1- assert "MISSING" in result.output+ assert "MISSING" in _strip_ansi(result.output)def test_doctor_outdated_dep():@@ -460,7 +936,7 @@ def test_doctor_missing_core_dependency_exits_nonzero(monkeypatch):monkeypatch.setitem(sys.modules, "plotext", None)result = runner.invoke(app, ["doctor"])assert result.exit_code != 0- assert "MISSING" in result.output+ assert "MISSING" in _strip_ansi(result.output)def test_doctor_full_install_exits_zero():diff --git a/tests/test_v0530.py b/tests/test_v0530.pyindex ad4aa6f4..8b8821f1 100644--- a/tests/test_v0530.py+++ b/tests/test_v0530.py@@ -555,7 +555,9 @@ class TestNVFP4:"soup_cli.utils.advanced_precision.is_blackwell_gpu", lambda: True)monkeypatch.setitem(sys.modules, "torchao", None)- with pytest.raises(RuntimeError, match="requires torchao") as excinfo:+ with pytest.raises(+ RuntimeError, match="requires torchao"+ ) as excinfo:apply_nvfp4(_tiny_linear_model())assert "no Blackwell device detected" not in str(excinfo.value)