|
| 1 | +from common.config_model import ( |
| 2 | + BenchmarkApiSource, |
| 3 | + BenchmarkConfig, |
| 4 | + BenchmarkRegressionConfigBook, |
| 5 | + DayRangeWindow, |
| 6 | + Frequency, |
| 7 | + Policy, |
| 8 | + RangeConfig, |
| 9 | + RegressionPolicy, |
| 10 | +) |
| 11 | + |
| 12 | + |
| 13 | +# Compiler benchmark regression config |
| 14 | +# todo(elainewy): eventually each team should configure |
| 15 | +# their own benchmark regression config, currenlty place |
| 16 | +# here for lambda |
| 17 | + |
| 18 | + |
| 19 | +COMPILER_BENCHMARK_CONFIG = BenchmarkConfig( |
| 20 | + name="Compiler Benchmark Regression", |
| 21 | + id="compiler_regression", |
| 22 | + source=BenchmarkApiSource( |
| 23 | + api_query_url="https://hud.pytorch.org/api/benchmark/get_time_series", |
| 24 | + type="benchmark_time_series_api", |
| 25 | + # currently we only detect the regression for h100 with dtype bfloat16, and mode inference |
| 26 | + # we can extend this to other devices, dtypes and mode in the future |
| 27 | + api_endpoint_params_template=""" |
| 28 | + { |
| 29 | + "name": "compiler_precompute", |
| 30 | + "query_params": { |
| 31 | + "commits": [], |
| 32 | + "compilers": [], |
| 33 | + "arch": "h100", |
| 34 | + "device": "cuda", |
| 35 | + "dtype": "bfloat16", |
| 36 | + "granularity": "hour", |
| 37 | + "mode": "inference", |
| 38 | + "startTime": "{{ startTime }}", |
| 39 | + "stopTime": "{{ stopTime }}", |
| 40 | + "suites": ["torchbench", "huggingface", "timm_models"], |
| 41 | + "workflowId": 0, |
| 42 | + "branches": ["main"] |
| 43 | + } |
| 44 | + } |
| 45 | + """, |
| 46 | + ), |
| 47 | + # set baseline from past 7 days using avg, and compare with the last 1 day |
| 48 | + policy=Policy( |
| 49 | + frequency=Frequency(value=1, unit="days"), |
| 50 | + range=RangeConfig( |
| 51 | + baseline=DayRangeWindow(value=7), |
| 52 | + comparison=DayRangeWindow(value=2), |
| 53 | + ), |
| 54 | + metrics={ |
| 55 | + "passrate": RegressionPolicy( |
| 56 | + name="passrate", |
| 57 | + condition="greater_equal", |
| 58 | + threshold=0.9, |
| 59 | + baseline_aggregation="max", |
| 60 | + ), |
| 61 | + "geomean": RegressionPolicy( |
| 62 | + name="geomean", |
| 63 | + condition="greater_equal", |
| 64 | + threshold=0.95, |
| 65 | + baseline_aggregation="max", |
| 66 | + ), |
| 67 | + "compression_ratio": RegressionPolicy( |
| 68 | + name="compression_ratio", |
| 69 | + condition="greater_equal", |
| 70 | + threshold=0.9, |
| 71 | + baseline_aggregation="max", |
| 72 | + ), |
| 73 | + }, |
| 74 | + notification_config={ |
| 75 | + "type": "github", |
| 76 | + "repo": "pytorch/test-infra", |
| 77 | + "issue": "7081", |
| 78 | + }, |
| 79 | + ), |
| 80 | +) |
| 81 | + |
| 82 | +BENCHMARK_REGRESSION_CONFIG = BenchmarkRegressionConfigBook( |
| 83 | + configs={ |
| 84 | + "compiler_regression": COMPILER_BENCHMARK_CONFIG, |
| 85 | + } |
| 86 | +) |
| 87 | + |
| 88 | + |
| 89 | +def get_benchmark_regression_config(config_id: str) -> BenchmarkConfig: |
| 90 | + """Get benchmark regression config by config id""" |
| 91 | + try: |
| 92 | + return BENCHMARK_REGRESSION_CONFIG[config_id] |
| 93 | + except KeyError: |
| 94 | + raise ValueError(f"Invalid config id: {config_id}") |
0 commit comments