Spaces:
Running
Running
Download tests/test_research.py from ArchitSharma/InferScale-Sim: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/ArchitSharma/InferScale-Sim/resolve/main/tests/test_research.py
- Command line
-
hf download hf://spaces/ArchitSharma/InferScale-Sim/tests/test_research.py
-
curl -L -o test_research.py https://huggingface.co/spaces/ArchitSharma/InferScale-Sim/resolve/main/tests/test_research.py
1.42 kB
| from inferscale import paired_study, robustness_study | |
| BASE = { | |
| "model": "Qwen2.5-3B", | |
| "accelerator": "L4", | |
| "quantization": "int8", | |
| "duration_s": 8, | |
| "request_rate_rps": 2.5, | |
| "prompt_tokens_mean": 256, | |
| "output_tokens_mean": 32, | |
| "shared_prefix_tokens": 128, | |
| "prefix_reuse_fraction": 0.75, | |
| "prefill_accelerator": "L4", | |
| "decode_accelerator": "L4", | |
| } | |
| def test_paired_study_uses_common_seeds_and_returns_ci(): | |
| result = paired_study(BASE, "prefix_cache", repetitions=4, bootstrap_samples=100) | |
| assert result["protocol"] == "paired-common-random-numbers" | |
| assert len(result["pairs"]) == 4 | |
| assert all(row["seed"] == BASE.get("seed", 7) + idx * 1009 for idx, row in enumerate(result["pairs"])) | |
| assert {row["metric"] for row in result["metrics"]} == { | |
| "goodput_rps", "p95_ttft_ms", "p95_e2e_ms", "slo_attainment" | |
| } | |
| assert all("delta_ci95_low" in row for row in result["metrics"]) | |
| def test_robustness_study_perturbs_reference_model(): | |
| result = robustness_study(BASE, "pd_vs_colocated", samples=6, uncertainty=0.15) | |
| assert result["samples"] == 6 | |
| assert result["method"] == "shared-multiplicative-latency-perturbation" | |
| assert len(result["rows"]) == 6 | |
| for row in result["rows"]: | |
| assert 0.85 <= row["prefill_scale"] <= 1.15 | |
| assert 0.85 <= row["decode_scale"] <= 1.15 | |
| assert 0.85 <= row["transfer_scale"] <= 1.15 | |