MCPcopy Index your code
hub / github.com/NVIDIA/TensorRT-LLM / generate_tests

Function generate_tests

scripts/generate_config_database_tests.py:178–234  ·  view source on GitHub ↗
(test_list_path: Path = TEST_LIST_PATH, test_config_dir: Path = PERF_SANITY_DIR)

Source from the content-addressed store, hash-verified

176
177
178def generate_tests(test_list_path: Path = TEST_LIST_PATH, test_config_dir: Path = PERF_SANITY_DIR):
179 test_list_path.parent.mkdir(parents=True, exist_ok=True)
180
181 all_recipes = RecipeList.from_yaml(DATABASE_LIST_PATH)
182 recipes = filter_to_key_recipes(all_recipes)
183 print(f"Selected {len(recipes)} key recipes from {len(all_recipes)} total")
184
185 gpu_groups = group_recipes_by_gpu(recipes)
186 condition_entries = []
187 config_files = {}
188
189 for gpu_name in sorted(gpu_groups.keys()):
190 gpu_recipes = gpu_groups[gpu_name]
191 config_name = f"config_database_{gpu_name.lower()}"
192 config_path = test_config_dir / f"{config_name}.yaml"
193
194 aggr_config = generate_aggr_config(gpu_recipes)
195 config_content = yaml.dump(
196 aggr_config, default_flow_style=False, sort_keys=False, width=120
197 )
198
199 with open(config_path, "w", encoding="utf-8") as f:
200 f.write(config_content)
201 print(f"Generated {config_path}")
202
203 config_files[config_path] = config_content
204
205 # Generate condition entries grouped by num_gpus
206 num_gpus_groups = group_recipes_by_num_gpus(gpu_recipes)
207 for num_gpus in sorted(num_gpus_groups.keys()):
208 server_names = [generate_server_name(r) for r in num_gpus_groups[num_gpus]]
209 entry = generate_condition_entry(gpu_name, num_gpus, config_name, server_names)
210 condition_entries.append(entry)
211
212 test_list = {
213 "version": "0.0.1",
214 "llm_config_database": condition_entries,
215 }
216
217 header = """# ===============================================================================
218# Config Database Performance Tests (AUTO-GENERATED)
219# ===============================================================================
220# Generated by: scripts/generate_config_database_tests.py
221#
222# These tests use scenario-only matching (match_mode: scenario) for baselines.
223# Baselines are matched by (model, gpu, isl, osl, concurrency, num_gpus) instead
224# of full config fields, allowing configs to evolve while maintaining comparison.
225#
226# To regenerate:
227# python scripts/generate_config_database_tests.py
228# ===============================================================================
229
230"""
231 with open(test_list_path, "w", encoding="utf-8") as f:
232 f.write(header)
233 yaml.dump(test_list, f, default_flow_style=False, sort_keys=False, width=120)
234 print(f"Generated {test_list_path}")
235

Calls 9

filter_to_key_recipesFunction · 0.85
group_recipes_by_gpuFunction · 0.85
generate_aggr_configFunction · 0.85
generate_server_nameFunction · 0.85
generate_condition_entryFunction · 0.85
from_yamlMethod · 0.80
keysMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected