Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
de96bfb
fix(ci): align public Rust schema contract (#78) (#79)
jasonqinzhou Sep 2, 2026
d597fd7
fix(compliance): address OSRB filing requirements (#81) (#92)
saturley-hall Sep 2, 2026
0d536d0
fix(generator): serialize attention backend before save (#88) (#93)
jasonqinzhou Sep 3, 2026
4df5522
fix(generator): preserve Sweeper KV capacity [6738325] (#127) (#133)
jasonqinzhou Sep 9, 2026
87e8471
fix(generator): render SGLang candidate token limits [6738246] (#128)…
jasonqinzhou Sep 9, 2026
2078c89
fix(compliance): complete third-party license notices (#95) (#148)
saturley-hall Sep 9, 2026
6ae796a
chore: canonicalize repository governance files (#106) (#149)
saturley-hall Sep 9, 2026
b7972ba
Harden SPDX checks and correct 50 Jinja license headers (#146) (#150)
saturley-hall Sep 9, 2026
e7bcf0d
fix(cli): preserve whole-model FPM FMHA identity [6745146] (#151) (#154)
jasonqinzhou Sep 10, 2026
40daf5e
fix(generator): omit unspecified SGLang KV-cache dtype [6745807] (#15…
jasonqinzhou Sep 10, 2026
1f72853
fix(packaging): backport manylinux 2.28 wheel repair (#205)
saturley-hall Sep 15, 2026
9cd81ab
fix(cli): resolve prediction backend versions on 0.12.0
jasonqinzhou Sep 18, 2026
63f3ce0
fix(replay): adapt current-version capacity lookup to main
jasonqinzhou Sep 18, 2026
ef8feed
fix(replay): apply authored versions before capacity estimation
jasonqinzhou Sep 18, 2026
fad6989
Merge main into codex/fix-release-backend-version-defaults
jasonqinzhou Sep 18, 2026
d2bcd85
fix(replay): preserve null aliases and custom version roots
jasonqinzhou Sep 18, 2026
854519d
fix(replay): align capacity systems root
jasonqinzhou Sep 18, 2026
c6a21d0
style: format custom-root regression
jasonqinzhou Sep 18, 2026
23d5c94
fix(epd): resolve omitted backend versions
jasonqinzhou Sep 18, 2026
6749d4d
Merge remote-tracking branch 'origin/main' into codex/pr291-main-inte…
jasonqinzhou Sep 18, 2026
2607508
test(epd): cover version lookup boundaries
jasonqinzhou Sep 18, 2026
b4075b1
Merge origin/main into codex/fix-release-backend-version-defaults
jasonqinzhou Sep 19, 2026
ad520d9
Merge origin/main into codex/fix-release-backend-version-defaults
jasonqinzhou Sep 19, 2026
371cfc6
Merge current main for replay version validation
jasonqinzhou Sep 19, 2026
af45f23
fix(replay): retain the canonical timing database root
jasonqinzhou Sep 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions python/aisimulate/src/aisimulate/capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ def estimate_num_gpu_blocks(
estimate_num_gpu_blocks as aic_estimate_num_gpu_blocks,
)

if backend_version is None:
from aisimulate_core.sdk.perf_database import get_latest_database_version

# Use the maintained current slot (or the latest version in a custom
# legacy root), matching the database used for this capacity estimate.
backend_version = get_latest_database_version(system, backend_name, systems_paths=systems_path)
Comment thread
jasonqinzhou marked this conversation as resolved.
Resolved
if backend_version is None:
raise ValueError(f"no perf database for system={system!r}, backend={backend_name!r}")

if backend_name == "trtllm":
memory_fraction_kind = "of_free"
memory_fraction_value = (
Expand All @@ -253,9 +262,7 @@ def estimate_num_gpu_blocks(
model_path,
system,
backend_name,
backend_version=(
backend_version if backend_version is not None else DEFAULT_BACKEND_VERSIONS[backend_name]
),
backend_version=backend_version,
scheduler_block_size=block_size,
max_num_tokens=max_num_batched_tokens,
max_batch_size=max_num_sequences,
Expand Down
105 changes: 103 additions & 2 deletions tests/test_aic.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ def estimate(*args, **kwargs):
calls.append((args, kwargs))
return 123

from aisimulate_core.sdk import memory
from aisimulate_core.sdk import memory, perf_database

monkeypatch.setattr(memory, "estimate_num_gpu_blocks", estimate)
version_calls = []

def latest(system, backend, *, systems_paths):
version_calls.append((system, backend, systems_paths))
return "test-current"

monkeypatch.setattr(perf_database, "get_latest_database_version", latest)
blocks = aic.estimate_num_gpu_blocks(
backend_name="vllm",
system="h200_sxm",
Expand All @@ -81,7 +88,8 @@ def estimate(*args, **kwargs):
assert blocks == 123
args, kwargs = calls[0]
assert args == ("test-model", "h200_sxm", "vllm")
assert kwargs["backend_version"] == "0.19.0"
assert kwargs["backend_version"] == "test-current"
assert version_calls == [("h200_sxm", "vllm", "/tmp/custom-systems.yaml")]
assert kwargs["memory_fraction_kind"] == "of_total"
assert kwargs["memory_fraction_value"] == 0.9
assert kwargs["pp_size"] == 3
Expand Down Expand Up @@ -137,3 +145,96 @@ def estimate(**kwargs):
assert calls[0]["gpu_memory_utilization"] == 0.0
assert calls[0]["mem_fraction_static"] == 0.0
assert calls[0]["free_gpu_memory_fraction"] == 0.0


@pytest.mark.parametrize("backend", ["vllm", "sglang", "trtllm"])
@pytest.mark.parametrize("timing", ["default", "fixed", "polynomial"])
def test_prediction_omitted_version_uses_current_database_for_capacity(monkeypatch, backend, timing):
from aisimulate.compiler import prediction_to_replay_spec
from aisimulate.config import CorePredictionConfig
from aisimulate_core.sdk import perf_database

expected = perf_database.get_version_slots("h200_sxm", backend)["current"]
get_database = perf_database.get_database
versions = []

def recorded_database(*args, **kwargs):
database = get_database(*args, **kwargs)
versions.append(database.version)
return database

monkeypatch.setattr(perf_database, "get_database", recorded_database)
timing_config = {"type": timing}
if timing == "fixed":
timing_config.update(prefill_ms=1, decode_ms=1)
config = CorePredictionConfig.model_validate(
{
"engine": {
"model": "Qwen/Qwen3-32B-FP8",
"hardware": "h200_sxm",
"backend": backend,
"context_length": 4096,
"workers": {"aggregated": {"parallelism": {"tensor": 2}, "timing": timing_config}},
}
}
)
deployment = prediction_to_replay_spec(config).backend_deployment
args = aic.materialize_aic_num_gpu_blocks(deployment.agg_engine_args)
assert args["num_gpu_blocks"] > 0
assert versions and set(versions) == {expected}
assert config.engine.backend_version is None
if timing == "default":
assert args["timing_model"]["config"]["backend_version"] == expected
else:
assert args["timing_model"]["type"] == timing


@pytest.mark.parametrize("version", ["current", "next", "0.24.0", "0.19.0"])
def test_capacity_preserves_explicit_backend_version(monkeypatch, version):
from aisimulate_core.sdk import memory, perf_database

monkeypatch.setattr(
perf_database,
"get_latest_database_version",
lambda *_args, **_kwargs: pytest.fail("explicit versions must not be replaced"),
)
versions = []

def estimate(*args, **kwargs):
versions.append(kwargs["backend_version"])
return 128

monkeypatch.setattr(memory, "estimate_num_gpu_blocks", estimate)
assert (
aic.estimate_num_gpu_blocks(
backend_name="vllm",
backend_version=version,
system="h200_sxm",
model_path="test-model",
tp_size=1,
block_size=64,
max_num_batched_tokens=4096,
)
== 128
)
assert versions == [version]


def test_capacity_without_a_database_fails_before_estimation(monkeypatch):
from aisimulate_core.sdk import memory, perf_database

monkeypatch.setattr(perf_database, "get_latest_database_version", lambda *_args, **_kwargs: None)
monkeypatch.setattr(
memory,
"estimate_num_gpu_blocks",
lambda *_args, **_kwargs: pytest.fail("missing versions must fail before estimation"),
)
with pytest.raises(ValueError, match="no perf database.*unsupported-test-gpu.*vllm"):
aic.estimate_num_gpu_blocks(
backend_name="vllm",
system="unsupported-test-gpu",
model_path="test-model",
tp_size=1,
block_size=64,
max_num_batched_tokens=4096,
)
Loading