Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions inferencex-e2e/infx/matrix/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,15 @@ def filter_exp_names(entries: list[dict], exp_names: list[str]) -> list[dict]:
return [entry for entry in entries if entry.get(Fields.EXP_NAME.value) in requested]


def filter_tp(entries: list[dict], tps: list[int]) -> list[dict]:
if any(Fields.TP.value not in entry for entry in entries):
raise ValueError("--tp filters single-node rows only")
missing = sorted(set(tps) - {entry[Fields.TP.value] for entry in entries})
if missing:
raise ValueError("TP value(s) not found: " + ", ".join(map(str, missing)))
return [entry for entry in entries if entry[Fields.TP.value] in tps]


def apply_node_type_defaults(args: argparse.Namespace) -> argparse.Namespace:
if (
hasattr(args, "single_node")
Expand Down Expand Up @@ -1666,6 +1675,13 @@ def main() -> list[dict]:
required=False,
help="Only include these concurrency values. Values must exist in the config conc-range/list.",
)
test_config_keys_parser.add_argument(
"--tp",
nargs="+",
type=int,
required=False,
help="Only include single-node rows with these TP sizes.",
)
test_config_keys_parser.add_argument(
"--exp-names",
nargs="+",
Expand Down Expand Up @@ -1711,6 +1727,12 @@ def main() -> list[dict]:
else:
parser.error(f"Unknown command: {args.command}")

if args.command == "test-config" and args.tp:
try:
matrix_values = filter_tp(matrix_values, args.tp)
except ValueError as error:
parser.error(str(error))

if args.command == "test-config" and args.exp_names:
try:
matrix_values = filter_exp_names(matrix_values, args.exp_names)
Expand Down
40 changes: 40 additions & 0 deletions inferencex-e2e/infx/tests/matrix/test_generate_sweep_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
apply_node_type_defaults,
expand_config_keys,
filter_exp_names,
filter_tp,
generate_full_sweep,
generate_test_config_sweep,
mark_all_eval_entries,
Expand Down Expand Up @@ -3222,6 +3223,45 @@ def test_rejects_missing_ambiguous_or_duplicate_names(



class TestFilterTp:
@pytest.mark.parametrize(
("entries", "message"),
(
([{"tp": 8}], "not found: 4"),
([{"prefill": {"tp": 4}, "decode": {"tp": 4}}], "single-node rows only"),
),
)
def test_rejects_absent_tp_or_multinode(self, entries, message):
with pytest.raises(ValueError, match=message):
filter_tp(entries, [4])

def test_test_config_keeps_only_requested_tp(
self, monkeypatch, sample_single_node_config, sample_runner_config
):
config = copy.deepcopy(sample_single_node_config)
sequence = config["dsr1-fp8-mi300x-sglang"]["scenarios"]["fixed-seq-len"][1]
sequence["search-space"] = [
{"tp": 8, "conc-start": 1, "conc-end": 4},
{"tp": 4, "conc-start": 1, "conc-end": 64},
]
monkeypatch.setattr(generate_sweep_configs, "load_config_files", lambda _: config)
monkeypatch.setattr(
generate_sweep_configs, "load_runner_file", lambda _: sample_runner_config
)
monkeypatch.setattr(sys, "argv", [
"generate_sweep_configs.py", "test-config",
"--config-files", "dummy.yaml",
"--config-keys", "dsr1-fp8-mi300x-sglang",
"--seq-lens", "8k1k", "--tp", "4", "--conc", "1", "2", "4", "--no-evals",
])

result = generate_sweep_configs.main()

assert sorted((entry["tp"], entry["conc"]) for entry in result) == [
(4, 1), (4, 2), (4, 4),
]


class TestExpandConfigKeys:

AVAILABLE = [
Expand Down
Loading