Skip to content

Commit f69f8d2

Browse files
committed
update
Signed-off-by: Chenfei Zhang <[email protected]>
1 parent d70aedd commit f69f8d2

File tree

2 files changed

+58
-26
lines changed

2 files changed

+58
-26
lines changed

jenkins/scripts/open_search_db.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
JOB_MACHINE_PROJECT_NAME = f"{PROJECT_ROOT}-ci-{MODE}-job_machine_info"
5252
FAILED_STEP_PROJECT_NAME = f"{PROJECT_ROOT}-ci-{MODE}-failed_step_info"
5353
PR_PROJECT_NAME = f"{PROJECT_ROOT}-ci-{MODE}-pr_info"
54+
PERF_SANITY_PROJECT_NAME = f"{PROJECT_ROOT}-ci-{MODE}-perf_sanity_info"
5455

5556
READ_ACCESS_PROJECT_NAME = [
5657
JOB_PROJECT_NAME,
@@ -59,6 +60,7 @@
5960
JOB_MACHINE_PROJECT_NAME,
6061
FAILED_STEP_PROJECT_NAME,
6162
PR_PROJECT_NAME,
63+
PERF_SANITY_PROJECT_NAME,
6264
]
6365

6466
WRITE_ACCESS_PROJECT_NAME = []

tests/integration/defs/perf/open_search_db_utils.py

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@
2929
os.path.join(os.path.dirname(__file__), '../../../..'))
3030
if _project_root not in sys.path:
3131
sys.path.insert(0, _project_root)
32-
from jenkins.scripts.open_search_db import OpenSearchDB
32+
from jenkins.scripts.open_search_db import OpenSearchDB, PERF_SANITY_PROJECT_NAME
3333

34-
PROJECT_ROOT = "sandbox-temp-trtllm-ci-perf-v1" # "sandbox-trtllm-ci-perf"
35-
TEST_INFO_PROJECT_NAME = f"{PROJECT_ROOT}-test_info"
36-
PRE_MERGE_THRESHOLD = 0.1
37-
POST_MERGE_THRESHOLD = 0.05
34+
POC_PROJECT_NAME = "sandbox-temp-trtllm-ci-perf-v1-test_info"
35+
USE_POC_DB = os.environ.get("USE_POC_DB", "false").lower() == "true"
36+
TEST_INFO_PROJECT_NAME = POC_PROJECT_NAME if USE_POC_DB else PERF_SANITY_PROJECT_NAME
3837

3938
# Metrics where larger is better
4039
MAXIMIZE_METRICS = [
@@ -431,23 +430,22 @@ def prepare_regressive_test_cases(history_baseline_dict, new_data_dict):
431430
Set it as regressive.
432431
"""
433432
regressive_data_list = []
434-
cmd_idxs = new_data_dict.keys()
435433
# Find regressive test cases
436-
for cmd_idx in cmd_idxs:
434+
for cmd_idx in new_data_dict:
437435
if history_baseline_dict[cmd_idx] is None:
438436
continue
439437

440-
baseline_data = history_baseline_dict[cmd_idx]
438+
history_baseline = history_baseline_dict[cmd_idx]
441439
new_data = new_data_dict[cmd_idx]
442440
is_regressive = False
443441
regressive_metrics = []
444442

445443
# Check MAXIMIZE_METRICS (new should be >= baseline * (1 - threshold))
446444
for metric in MAXIMIZE_METRICS:
447-
if metric not in new_data or metric not in baseline_data:
445+
if metric not in new_data or metric not in history_baseline:
448446
continue
449-
threshold = get_threshold(baseline_data, metric)
450-
baseline_value = baseline_data[metric]
447+
threshold = get_threshold(history_baseline, metric)
448+
baseline_value = history_baseline[metric]
451449
new_value = new_data[metric]
452450
# Regressive if new_value < baseline_value * (1 - threshold)
453451
if new_value < baseline_value * (1 - threshold):
@@ -456,10 +454,10 @@ def prepare_regressive_test_cases(history_baseline_dict, new_data_dict):
456454

457455
# Check MINIMIZE_METRICS (new should be <= baseline * (1 + threshold))
458456
for metric in MINIMIZE_METRICS:
459-
if metric not in new_data or metric not in baseline_data:
457+
if metric not in new_data or metric not in history_baseline:
460458
continue
461-
threshold = get_threshold(baseline_data, metric)
462-
baseline_value = baseline_data[metric]
459+
threshold = get_threshold(history_baseline, metric)
460+
baseline_value = history_baseline[metric]
463461
new_value = new_data[metric]
464462
# Regressive if new_value > baseline_value * (1 + threshold)
465463
if new_value > baseline_value * (1 + threshold):
@@ -471,9 +469,9 @@ def prepare_regressive_test_cases(history_baseline_dict, new_data_dict):
471469
regressive_data = new_data.copy()
472470
# Add baseline values and thresholds for all metrics
473471
for metric in MAXIMIZE_METRICS + MINIMIZE_METRICS:
474-
if metric in baseline_data:
472+
if metric in history_baseline:
475473
baseline_key = f"d_baseline_{metric[2:]}"
476-
regressive_data[baseline_key] = baseline_data[metric]
474+
regressive_data[baseline_key] = history_baseline[metric]
477475

478476
# Copy all threshold keys from baseline
479477
metric_suffix = metric[2:]
@@ -482,8 +480,8 @@ def prepare_regressive_test_cases(history_baseline_dict, new_data_dict):
482480
f"d_threshold_post_merge_{metric_suffix}",
483481
f"d_threshold_pre_merge_{metric_suffix}"
484482
]:
485-
if threshold_key in baseline_data:
486-
regressive_data[threshold_key] = baseline_data[
483+
if threshold_key in history_baseline:
484+
regressive_data[threshold_key] = history_baseline[
487485
threshold_key]
488486

489487
# Add regression info string
@@ -495,7 +493,15 @@ def prepare_regressive_test_cases(history_baseline_dict, new_data_dict):
495493
return regressive_data_list
496494

497495

498-
def prepare_baseline_data(history_data_dict, new_data_dict):
496+
def _is_valid_baseline(baseline_data):
497+
"""Check if baseline data is valid (non-empty dict)."""
498+
if isinstance(baseline_data, dict) and len(baseline_data) > 0:
499+
return True
500+
return False
501+
502+
503+
def prepare_baseline_data(history_baseline_dict, history_data_dict,
504+
new_data_dict):
499505
"""
500506
Calculate new baseline from history post-merge data and new data.
501507
Then return new baseline data.
@@ -507,18 +513,42 @@ def prepare_baseline_data(history_data_dict, new_data_dict):
507513
# Calculate best metrics from history post-merge data and new data
508514
best_metrics = calculate_best_perf_result(history_data_dict[cmd_idx],
509515
new_data_dict[cmd_idx])
516+
517+
# Create new_baseline_data from new_data_dict and set b_is_baseline
510518
new_baseline_data = new_data_dict[cmd_idx].copy()
511519
new_baseline_data["b_is_baseline"] = True
512-
# Add or update baseline metrics and thresholds
513-
for metric, value in best_metrics.items():
514-
new_baseline_data[metric] = value
520+
521+
# Initialize metric_threshold_dict with default thresholds for all metrics
522+
metric_threshold_dict = {}
523+
for metric in MAXIMIZE_METRICS + MINIMIZE_METRICS:
515524
metric_suffix = metric[2:]
516525
post_merge_key = f"d_threshold_post_merge_{metric_suffix}"
517526
pre_merge_key = f"d_threshold_pre_merge_{metric_suffix}"
518-
new_baseline_data[post_merge_key] = new_baseline_data.get(
519-
post_merge_key, POST_MERGE_THRESHOLD)
520-
new_baseline_data[pre_merge_key] = new_baseline_data.get(
521-
pre_merge_key, PRE_MERGE_THRESHOLD)
527+
metric_threshold_dict[post_merge_key] = POST_MERGE_THRESHOLD
528+
metric_threshold_dict[pre_merge_key] = PRE_MERGE_THRESHOLD
529+
530+
# If history baseline is valid, extract thresholds and update metric_threshold_dict
531+
history_baseline = history_baseline_dict[cmd_idx]
532+
if _is_valid_baseline(history_baseline):
533+
for metric in MAXIMIZE_METRICS + MINIMIZE_METRICS:
534+
metric_suffix = metric[2:]
535+
post_merge_key = f"d_threshold_post_merge_{metric_suffix}"
536+
pre_merge_key = f"d_threshold_pre_merge_{metric_suffix}"
537+
if post_merge_key in history_baseline:
538+
metric_threshold_dict[post_merge_key] = history_baseline[
539+
post_merge_key]
540+
if pre_merge_key in history_baseline:
541+
metric_threshold_dict[pre_merge_key] = history_baseline[
542+
pre_merge_key]
543+
544+
# Update new_baseline_data with best_metrics values
545+
for metric, value in best_metrics.items():
546+
new_baseline_data[metric] = value
547+
548+
# Add all thresholds to new_baseline_data
549+
for threshold_key, threshold_value in metric_threshold_dict.items():
550+
new_baseline_data[threshold_key] = threshold_value
551+
522552
add_id(new_baseline_data)
523553
new_baseline_data_dict[cmd_idx] = new_baseline_data
524554

0 commit comments

Comments
 (0)