Repository: vllm-project/aibrix
File: benchmarks/generator/workload_generator.py (Python)

Code before:
        current_value = round(trend + noise)
        if pattern_config['only_rise']:
            current_value = max(prev_value, current_value)
            prev_value = current_value
        return current_value, prev_value

    assert duration_ms is not None and interval_ms is not None, \
        "duration_ms and interval_ms must be specified."
    length = int(duration_ms // interval_ms) + 1
    workload = []
    t = 0
    previous_concurrency = -1
    previous_input_len = -1
    previous_output_len = -1
    ts = 0
    
    rps_dist = []
    input_token_len_dist = []
    output_token_len_dist = []
    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_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
        rps_dist.append(current_concurrency)
        input_token_len_dist.append(current_input_len)
        output_token_len_dist.append(current_output_len)
        ts += interval_ms
        t += 1
        
    workload = generate_synthetic_from_dist(
        prompt_file_path = prompt_file_path,
        tokenizer = tokenizer,
        duration_ms =  duration_ms,
        rps_dist = rps_dist,
        input_token_len_dist = input_token_len_dist,
        output_token_len_dist = output_token_len_dist,
        qps_scale = 1.0,
        input_scale = 1.0,
        output_scale = 1.0,
    )
    workload = make_serializable(workload)
    save_workload(workload, output_file, use_jsonl=to_jsonl)
    return workload


def generate_from_azure_csv(file_path: str,
                            prompt_file_path: str,
                            duration_ms: int,
                            tokenizer: PreTrainedTokenizerBase,

Review comment (suggestion):
Concurrency could be the misleading term here. As far as I know, concurrency or concurrent requests usually means (the number of) requests that are concurrently running in the system. For example, concurrency control is controlling that. By that definition, workload generator can't control concurrency. So what it meant was maybe a certain number of request per unit time? (RPS if it is second)

Code after:
        current_value = round(trend + noise)
        if pattern_config['only_rise']:
            current_value = max(prev_value, current_value)
            prev_value = current_value
        return current_value, prev_value

    assert duration_ms is not None and interval_ms is not None, \
        "duration_ms and interval_ms must be specified."
    num_intervals = int(duration_ms // interval_ms) + 1
    workload = []
    interval = 0
    previous_rate = -1
    previous_input_len = -1
    previous_output_len = -1
    ts = 0
    
    rps_dist = []
    input_token_len_dist = []
    output_token_len_dist = []
    while interval < num_intervals:
        current_rate, previous_rate = math_function(interval, qps_pattern_config, num_intervals, previous_rate)
        current_input_len, previous_input_len = math_function(interval, input_pattern_config, num_intervals, previous_input_len) 
        current_output_len, previous_output_len = math_function(interval, output_pattern_config, num_intervals, 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
        rps_dist.append(current_rate)
        input_token_len_dist.append(current_input_len)
        output_token_len_dist.append(current_output_len)
        ts += interval_ms
        interval += 1
        
    workload = generate_synthetic_from_dist(
        prompt_file_path = prompt_file_path,
        tokenizer = tokenizer,
        duration_ms =  duration_ms,
        rps_dist = rps_dist,
        input_token_len_dist = input_token_len_dist,
        output_token_len_dist = output_token_len_dist,
        qps_scale = 1.0,
        input_scale = 1.0,
        output_scale = 1.0,
    )
    workload = make_serializable(workload)
    save_workload(workload, output_file, use_jsonl=to_jsonl)
    return workload


def generate_from_azure_csv(file_path: str,
                            prompt_file_path: str,
                            duration_ms: int,
                            tokenizer: PreTrainedTokenizerBase,