Skip to content

Commit

Permalink
convert user specified patterns to synthetic patterns
Browse files Browse the repository at this point in the history
Signed-off-by: Le Xu <[email protected]>
  • Loading branch information
Le Xu committed Mar 1, 2025
1 parent 20c3355 commit 2b00555
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 29 deletions.
8 changes: 0 additions & 8 deletions benchmarks/generator/config/completion-len-config.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 8,
"mean": 169,
"noise": 0.1,
"period_len_ms": 300000,
"only_rise": false
}
7 changes: 7 additions & 0 deletions benchmarks/generator/config/examples/prompt-len-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 15,
"mean": 309,
"noise": 0.1,
"period_len_ms": 300000,
"only_rise": false
}
7 changes: 7 additions & 0 deletions benchmarks/generator/config/examples/traffic-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 2,
"mean": 6,
"noise": 0.1,
"period_len_ms": 300000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 86,
"mean": 43,
"noise": 0.1,
"period_len_ms": 120000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 86,
"mean": 43,
"noise": 0.1,
"period_len_ms": 4230000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 7.1,
"mean": 43,
"noise": 0.1,
"period_len_ms": 120000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 7.1,
"mean": 43,
"noise": 0.1,
"period_len_ms": 4230000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 2048,
"mean": 1024,
"noise": 0.1,
"period_len_ms": 90000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 2048,
"mean": 1024,
"noise": 0.1,
"period_len_ms": 210000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 174,
"mean": 1024,
"noise": 0.1,
"period_len_ms": 90000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 174,
"mean": 1024,
"noise": 0.1,
"period_len_ms": 210000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 3.6,
"mean": 6,
"noise": 0.1,
"period_len_ms": 120000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 3.6,
"mean": 6,
"noise": 0.1,
"period_len_ms": 1200000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 0.6,
"mean": 6,
"noise": 0.1,
"period_len_ms": 120000,
"only_rise": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fluctuate": 0.6,
"mean": 6,
"noise": 0.1,
"period_len_ms": 1200000,
"only_rise": false
}
8 changes: 0 additions & 8 deletions benchmarks/generator/config/prompt-len-config.json

This file was deleted.

8 changes: 0 additions & 8 deletions benchmarks/generator/config/traffic-config.json

This file was deleted.

14 changes: 13 additions & 1 deletion benchmarks/generator/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,16 @@ def to_fluctuate_pattern_config(config_type: str,
'omega': None,
'only_rise': False}
else:
raise ValueError(f"Unknown config type: {config_type}")
raise ValueError(f"Unknown config type: {config_type}")


def user_to_synthetic_config(user_config: Dict,
duration_ms: int,):
return {
'A': float(user_config['fluctuate']),
'B': float(user_config['mean']),
'sigma': float(user_config['noise']),
'period': duration_ms/float(user_config['period_len_ms']),
'omega': None,
'only_rise': user_config['only_rise'],
}
11 changes: 7 additions & 4 deletions benchmarks/generator/workload_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from distribution import (generate_poisson_dist,
generate_token_len_from_percentiles,
to_fluctuate_pattern_config,
user_to_synthetic_config,
)

from utils import (convert_to_stat_df,
Expand Down Expand Up @@ -240,8 +241,10 @@ def math_function(t, pattern_config, length, prev_value):
sharegpt_df = load_requests(dataset_path=prompt_file_path, tokenizer=tokenizer)
while t < length:
current_concurrency, previous_concurrency = math_function(t, qps_pattern_config, length, previous_concurrency)
current_input_len, previous_input_len = math_function(t, input_pattern_config, length, previous_input_len)
current_input_len, previous_input_len = math_function(t, input_pattern_config, length, previous_input_len)
current_output_len, previous_output_len = math_function(t, output_pattern_config, length, previous_output_len)
current_input_len = current_input_len if current_input_len > 0 else 1
current_output_len = current_output_len if current_output_len > 0 else 1
current_concurrency_pois = generate_poisson_dist(target = current_concurrency, sample_size = 1)
current_input_len_pois = generate_poisson_dist(target = current_input_len, sample_size = 1)
current_output_len_pois = generate_poisson_dist(target = current_output_len, sample_size = 1)
Expand Down Expand Up @@ -426,9 +429,9 @@ def pair_requests_with_prompts_round_robin(workload: List[List[Any]],
elif args.traffic_pattern_config and args.prompt_len_pattern_config and args.completion_len_pattern_config:
logging.info(f"Generating synthetic workload with traffic pattern config: {args.traffic_pattern_config}, prompt length pattern config: {args.prompt_len_pattern_config}, completion length pattern config: {args.completion_len_pattern_config}")
comp_pattern_type = f"synthetic_manual_config"
qps_pattern_config = load_config(args.traffic_pattern_config)
input_pattern_config = load_config(args.prompt_len_pattern_config)
output_pattern_config = load_config(args.completion_len_pattern_config)
qps_pattern_config = user_to_synthetic_config(user_config = load_config(args.traffic_pattern_config), duration_ms = args.duration_ms)
input_pattern_config = user_to_synthetic_config(user_config = load_config(args.prompt_len_pattern_config), duration_ms = args.duration_ms)
output_pattern_config = user_to_synthetic_config(user_config = load_config(args.completion_len_pattern_config), duration_ms = args.duration_ms)
logging.debug(f"qps_pattern_config {qps_pattern_config}")
logging.debug(f"input_pattern_config {input_pattern_config}")
logging.debug(f"output_pattern_config {output_pattern_config}")
Expand Down

0 comments on commit 2b00555

Please sign in to comment.