[CI][RFC] Replace black-jupyter with ruff-format (#37210)

Co-authored-by: Alison Shao <a.shao@wustl.edu>
This commit is contained in:
Alex Nails
2026-09-02 19:46:08 -07:00
committed by GitHub
co-authored by Alison Shao
parent 2641e427be
commit 28262c20df
1411 changed files with 7766 additions and 8176 deletions
@@ -687,8 +687,7 @@ def run_one_round(
rank_rows = fetch_rank_rows(base_url=context.base_url)
if len(rank_rows) != len(watermarks):
raise RuntimeError(
f"DP rank count changed mid-profile: {len(watermarks)} -> "
f"{len(rank_rows)}."
f"DP rank count changed mid-profile: {len(watermarks)} -> {len(rank_rows)}."
)
new_rank_rows = [
[row for row in rows if row.forward_ct > watermark]
@@ -136,13 +136,13 @@ class BenchArgs:
"--gsp-system-prompt-len",
type=int,
default=BenchArgs.gsp_system_prompt_len,
help="System prompt length, used" "only for generate-shared-prefix",
help="System prompt length, usedonly for generate-shared-prefix",
)
parser.add_argument(
"--gsp-question-len",
type=int,
default=BenchArgs.gsp_question_len,
help="Question length, used" "only for generate-shared-prefix",
help="Question length, usedonly for generate-shared-prefix",
)
parser.add_argument(
"--gsp-output-len",
@@ -259,9 +259,9 @@ def throughput_test_once(
]
if profile:
assert (
"SGLANG_TORCH_PROFILER_DIR" in os.environ
), "Please set SGLANG_TORCH_PROFILER_DIR."
assert "SGLANG_TORCH_PROFILER_DIR" in os.environ, (
"Please set SGLANG_TORCH_PROFILER_DIR."
)
os.makedirs(os.environ["SGLANG_TORCH_PROFILER_DIR"], exist_ok=True)
known_files = None
backend.start_profile(
+8 -8
View File
@@ -486,7 +486,7 @@ def _warmup_cache(
return
print(
f"Warming up cache with {cache_hit_rate*100:.1f}% hit rate "
f"Warming up cache with {cache_hit_rate * 100:.1f}% hit rate "
f"({cached_token_len} tokens per request)"
)
# Create prefix input_ids for cache warming
@@ -1024,7 +1024,7 @@ def get_report_summary(
f"\nInput lens: {bench_args.input_len}. Output lens: {bench_args.output_len}."
)
if bench_args.cache_hit_rate > 0.0:
summary += f" Cache hit rate: {bench_args.cache_hit_rate*100:.1f}%."
summary += f" Cache hit rate: {bench_args.cache_hit_rate * 100:.1f}%."
summary += "\n"
if is_blackwell():
@@ -1241,9 +1241,9 @@ def run_benchmark_internal(
skip_max_running_requests_threshold = float("inf")
skip_token_capacity_threshold = float("inf")
else:
assert (
max_running_requests_per_dp > 0
), f"effective_max_running_requests_per_dp is not set, {max_running_requests_per_dp=}"
assert max_running_requests_per_dp > 0, (
f"effective_max_running_requests_per_dp is not set, {max_running_requests_per_dp=}"
)
skip_max_running_requests_threshold = max_running_requests_per_dp * dp_size
print(f"{max_running_requests_per_dp=}")
@@ -1288,9 +1288,9 @@ def run_benchmark_internal(
"--lora-request-distribution=distinct/skewed requires more than "
"one adapter via --lora-name."
)
assert (
bench_args.lora_zipf_alpha > 1
), f"--lora-zipf-alpha must be > 1, got {bench_args.lora_zipf_alpha}"
assert bench_args.lora_zipf_alpha > 1, (
f"--lora-zipf-alpha must be > 1, got {bench_args.lora_zipf_alpha}"
)
if bench_args.apply_chat_template and not (
bench_args.fixed_prompt_file or bench_args.dataset_name in REPLAY_TEXT_DATASETS
+26 -26
View File
@@ -261,9 +261,9 @@ async def async_request_openai_completions(
pbar: Optional[tqdm] = None,
) -> RequestFuncOutput:
api_url = request_func_input.api_url
assert api_url.endswith(
"completions"
), "OpenAI Completions API URL must end with 'completions'."
assert api_url.endswith("completions"), (
"OpenAI Completions API URL must end with 'completions'."
)
prompt = request_func_input.prompt
@@ -392,9 +392,9 @@ async def async_request_openai_chat_completions(
latency, TTFT, ITL, and success status.
"""
api_url = request_func_input.api_url
assert api_url.endswith(
"chat/completions"
), "OpenAI Chat Completions API URL must end with 'chat/completions'."
assert api_url.endswith("chat/completions"), (
"OpenAI Chat Completions API URL must end with 'chat/completions'."
)
# TODO put it to other functions when `pbar` logic is refactored
if getattr(args, "print_requests", False):
@@ -1296,9 +1296,9 @@ def _normalize_round_messages(turn: Any) -> Optional[List[Dict[str, str]]]:
def wrap_multi_turn_request_func(request_func: Callable, backend: str) -> Callable:
assert (
backend in MULTI_TURN_BACKENDS
), f"Multi-turn only supports chat backends: {MULTI_TURN_BACKENDS}, got {backend}"
assert backend in MULTI_TURN_BACKENDS, (
f"Multi-turn only supports chat backends: {MULTI_TURN_BACKENDS}, got {backend}"
)
async def f(
request_func_input: RequestFuncInput,
@@ -1534,9 +1534,9 @@ async def benchmark(
lora_name = lora_names[lora_idx]
lora_idx = (lora_idx + 1) % len(lora_names)
else:
assert (
lora_request_distribution == "skewed"
), f"Unexpected lora_request_distribution: {lora_request_distribution}. Expected 'skewed'."
assert lora_request_distribution == "skewed", (
f"Unexpected lora_request_distribution: {lora_request_distribution}. Expected 'skewed'."
)
lora_name = np.random.choice(lora_names, p=lora_probs)
else:
@@ -2000,9 +2000,9 @@ def run_benchmark(args_: argparse.Namespace):
extra_request_body["bootstrap_room"] = 0
if args.tokenize_prompt:
assert (
args.backend == "sglang"
), "`--tokenize-prompt` only compatible with `--backend sglang` currently"
assert args.backend == "sglang", (
"`--tokenize-prompt` only compatible with `--backend sglang` currently"
)
# Set url
if args.port is None:
@@ -2079,18 +2079,18 @@ def run_benchmark(args_: argparse.Namespace):
if args.dataset_name in ["image", "mmmu"]:
args.apply_chat_template = True
assert (
not args.tokenize_prompt
), "`--tokenize-prompt` not compatible with image dataset"
assert not args.tokenize_prompt, (
"`--tokenize-prompt` not compatible with image dataset"
)
if args.lora_request_distribution in ["distinct", "skewed"]:
assert (
args.lora_name is not None and len(args.lora_name) > 1
), "More than 1 LoRA adapter must be specified via --lora-name to use 'distinct' or 'skewed' request distribution."
assert args.lora_name is not None and len(args.lora_name) > 1, (
"More than 1 LoRA adapter must be specified via --lora-name to use 'distinct' or 'skewed' request distribution."
)
assert (
args.lora_zipf_alpha > 1
), f"Got invalid value for --lora-zipf-alpha of {args.lora_zipf_alpha}. It must be greater than 1."
assert args.lora_zipf_alpha > 1, (
f"Got invalid value for --lora-zipf-alpha of {args.lora_zipf_alpha}. It must be greater than 1."
)
print(f"{args}\n")
@@ -2364,13 +2364,13 @@ def cli_main():
"--image-format",
type=str,
default="jpeg",
help=("Format of images for image dataset. " "Supports jpeg and png."),
help=("Format of images for image dataset. Supports jpeg and png."),
)
parser.add_argument(
"--image-content",
type=str,
default="random",
help=("Content for images for image dataset. " "Supports random and blank."),
help=("Content for images for image dataset. Supports random and blank."),
)
parser.add_argument(
"--request-rate",