Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the port_args in bench_latency #1597

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions python/sglang/bench_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@ def from_cli_args(cls, args: argparse.Namespace):
)


def load_model(server_args, tp_rank):
def load_model(server_args, port_args, tp_rank):
suppress_other_loggers()
rank_print = print if tp_rank == 0 else lambda *args, **kwargs: None

port_args = PortArgs.init_new(server_args)
model_config = ModelConfig(
server_args.model_path,
server_args.trust_remote_code,
Expand Down Expand Up @@ -248,13 +247,14 @@ def decode(input_token_ids, batch, model_runner):
@torch.inference_mode()
def correctness_test(
server_args,
port_args,
bench_args,
tp_rank,
):
rank_print = print if tp_rank == 0 else lambda *args, **kwargs: None

# Load the model
model_runner, tokenizer = load_model(server_args, tp_rank)
model_runner, tokenizer = load_model(server_args, port_args, tp_rank)

# Prepare inputs
input_ids, reqs = prepare_inputs_for_correctness_test(bench_args, tokenizer)
Expand Down Expand Up @@ -362,14 +362,15 @@ def latency_test_run_once(

def latency_test(
server_args,
port_args,
bench_args,
tp_rank,
):
configure_logger(server_args, prefix=f" TP{tp_rank}")
rank_print = print if tp_rank == 0 else lambda *args, **kwargs: None

# Load the model
model_runner, tokenizer = load_model(server_args, tp_rank)
model_runner, tokenizer = load_model(server_args, port_args, tp_rank)

# Prepare inputs for warm up
reqs = prepare_synthetic_inputs_for_latency_test(
Expand Down Expand Up @@ -487,15 +488,18 @@ def main(server_args, bench_args):
"provide --result-filename for plotting the results"
)

port_args = PortArgs.init_new(server_args)

if server_args.tp_size == 1:
work_func(server_args, bench_args, 0)
work_func(server_args, port_args, bench_args, 0)
else:
workers = []
for tp_rank in range(server_args.tp_size):
proc = multiprocessing.Process(
target=work_func,
args=(
server_args,
port_args,
bench_args,
tp_rank,
),
Expand Down
Loading