Download offload/bg_prefill/tests/test_simulate.py from ProprietaryLegal/dsv41-offload: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/ProprietaryLegal/dsv41-offload/resolve/main/offload/bg_prefill/tests/test_simulate.py
- Command line
-
hf download hf://ProprietaryLegal/dsv41-offload/offload/bg_prefill/tests/test_simulate.py
-
curl -L -o test_simulate.py https://huggingface.co/ProprietaryLegal/dsv41-offload/resolve/main/offload/bg_prefill/tests/test_simulate.py
1.2 kB
| """Conserved work and honest cost-model accounting, not a speedup acceptance test.""" | |
| from __future__ import annotations | |
| import pytest | |
| from offload.bg_prefill.simulate import Cost, simulate | |
| def test_equal_full_work_and_reported_fairness_cost(backgrounds: int, priority: int) -> None: | |
| control = simulate(backgrounds, priority, False) | |
| candidate = simulate(backgrounds, priority, True) | |
| for row in (control, candidate): | |
| assert row['background_prompt_tokens_total'] == backgrounds * 60000 | |
| assert row['estimated_foreground_tokens'] == 600 | |
| # Additive model: all work has the same exact cost, regardless of scheduling. | |
| assert row['all_work_s'] == pytest.approx(300 * .039 + backgrounds * 60000 / 2200) | |
| assert candidate['background_tokens_at_foreground_end'] == backgrounds * 12 * 32 | |
| assert candidate['max_background_service_gap_calls_during_overlap'] == 24 | |
| def test_simulation_refuses_invalid_costs_and_workloads() -> None: | |
| with pytest.raises(ValueError): | |
| Cost(decode_ms=0) | |
| with pytest.raises(ValueError): | |
| simulate(3, 0, True) | |