File size: 859 Bytes
f1a4107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from __future__ import annotations

import json
import os
import subprocess
import sys
from pathlib import Path

import pytest

pytest.importorskip("jax")

ROOT = Path(__file__).resolve().parents[1]


def test_tiny_sharding_probe_on_two_cpu_devices() -> None:
    env = os.environ.copy()
    env["FORCE_2_CPU"] = "1"
    result = subprocess.run(
        [sys.executable, str(ROOT / "scripts" / "tiny_sharding_probe.py")],
        cwd=ROOT,
        env=env,
        text=True,
        capture_output=True,
        check=False,
    )
    assert result.returncode == 0, result.stdout + result.stderr
    report = json.loads(result.stdout)
    assert report["ok"] is True
    assert len(report["devices"]) == 2
    names = {case["name"] for case in report["cases"]}
    assert names == {"column_sharded_matmul", "row_sharded_matmul", "replicated_reshard_matmul"}