Skip to content

Commit

Permalink
new write_config to only update instead of completely overwrite config
Browse files Browse the repository at this point in the history
  • Loading branch information
renxida committed Dec 10, 2024
1 parent 2550f4f commit defd4da
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
30 changes: 26 additions & 4 deletions app_tests/benchmark_tests/llm/sglang_benchmarks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,39 @@ def pre_process_model(request, tmp_path_factory):


@pytest.fixture(scope="module")
def write_config(request, pre_process_model):
def write_config(request, model_test_dir):
batch_sizes = request.param["batch_sizes"]
prefix_sharing_algorithm = request.param["prefix_sharing_algorithm"]

logger.info("Writing config file..." + start_log_group("Writing config file"))

# Construct the new config filename
config_path = (
pre_process_model
model_test_dir
/ f"{'_'.join(str(bs) for bs in batch_sizes)}_{prefix_sharing_algorithm}.json"
)

# Read the base config file
base_config_path = model_test_dir / "config.json"
with open(base_config_path, "r") as f:
config = json.load(f)

# Override specific fields
config.update(
{
"prefill_batch_sizes": batch_sizes,
"decode_batch_sizes": batch_sizes,
"paged_kv_cache": {
**config.get(
"paged_kv_cache", {}
), # Preserve other paged_kv_cache settings
"prefix_sharing_algorithm": prefix_sharing_algorithm,
},
}
)

logger.info(f"Saving edited config to: {config_path}\n")
logger.info(f"Config: {json.dumps(config, indent=2)}")
with open(config_path, "w") as f:
json.dump(config, f)
yield config_path


Expand Down
25 changes: 25 additions & 0 deletions app_tests/integration_tests/llm/shortfin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,35 @@ def write_config(request, model_test_dir):
batch_sizes = request.param["batch_sizes"]
prefix_sharing_algorithm = request.param["prefix_sharing_algorithm"]

# Construct the new config filename
config_path = (
model_test_dir
/ f"{'_'.join(str(bs) for bs in batch_sizes)}_{prefix_sharing_algorithm}.json"
)

# Read the base config file
base_config_path = model_test_dir / "config.json"
with open(base_config_path, "r") as f:
config = json.load(f)

# Override specific fields
config.update(
{
"prefill_batch_sizes": batch_sizes,
"decode_batch_sizes": batch_sizes,
"paged_kv_cache": {
**config.get(
"paged_kv_cache", {}
), # Preserve other paged_kv_cache settings
"prefix_sharing_algorithm": prefix_sharing_algorithm,
},
}
)
logger.info(f"Saving edited config to: {config_path}\n")
logger.info(f"Config: {json.dumps(config, indent=2)}")
with open(config_path, "w") as f:
json.dump(config, f)

yield config_path


Expand Down

0 comments on commit defd4da

Please sign in to comment.