Skip to content

Commit defd4da

Browse files
committed
new write_config to only update instead of completely overwrite config
1 parent 2550f4f commit defd4da

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

app_tests/benchmark_tests/llm/sglang_benchmarks/conftest.py

+26-4
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,39 @@ def pre_process_model(request, tmp_path_factory):
6464

6565

6666
@pytest.fixture(scope="module")
67-
def write_config(request, pre_process_model):
67+
def write_config(request, model_test_dir):
6868
batch_sizes = request.param["batch_sizes"]
6969
prefix_sharing_algorithm = request.param["prefix_sharing_algorithm"]
7070

71-
logger.info("Writing config file..." + start_log_group("Writing config file"))
72-
71+
# Construct the new config filename
7372
config_path = (
74-
pre_process_model
73+
model_test_dir
7574
/ f"{'_'.join(str(bs) for bs in batch_sizes)}_{prefix_sharing_algorithm}.json"
7675
)
7776

77+
# Read the base config file
78+
base_config_path = model_test_dir / "config.json"
79+
with open(base_config_path, "r") as f:
80+
config = json.load(f)
81+
82+
# Override specific fields
83+
config.update(
84+
{
85+
"prefill_batch_sizes": batch_sizes,
86+
"decode_batch_sizes": batch_sizes,
87+
"paged_kv_cache": {
88+
**config.get(
89+
"paged_kv_cache", {}
90+
), # Preserve other paged_kv_cache settings
91+
"prefix_sharing_algorithm": prefix_sharing_algorithm,
92+
},
93+
}
94+
)
95+
96+
logger.info(f"Saving edited config to: {config_path}\n")
97+
logger.info(f"Config: {json.dumps(config, indent=2)}")
98+
with open(config_path, "w") as f:
99+
json.dump(config, f)
78100
yield config_path
79101

80102

app_tests/integration_tests/llm/shortfin/conftest.py

+25
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,35 @@ def write_config(request, model_test_dir):
8787
batch_sizes = request.param["batch_sizes"]
8888
prefix_sharing_algorithm = request.param["prefix_sharing_algorithm"]
8989

90+
# Construct the new config filename
9091
config_path = (
9192
model_test_dir
9293
/ f"{'_'.join(str(bs) for bs in batch_sizes)}_{prefix_sharing_algorithm}.json"
9394
)
95+
96+
# Read the base config file
97+
base_config_path = model_test_dir / "config.json"
98+
with open(base_config_path, "r") as f:
99+
config = json.load(f)
100+
101+
# Override specific fields
102+
config.update(
103+
{
104+
"prefill_batch_sizes": batch_sizes,
105+
"decode_batch_sizes": batch_sizes,
106+
"paged_kv_cache": {
107+
**config.get(
108+
"paged_kv_cache", {}
109+
), # Preserve other paged_kv_cache settings
110+
"prefix_sharing_algorithm": prefix_sharing_algorithm,
111+
},
112+
}
113+
)
114+
logger.info(f"Saving edited config to: {config_path}\n")
115+
logger.info(f"Config: {json.dumps(config, indent=2)}")
116+
with open(config_path, "w") as f:
117+
json.dump(config, f)
118+
94119
yield config_path
95120

96121

0 commit comments

Comments
 (0)