[CI][RFC] Replace black-jupyter with ruff-format (#37210)
Co-authored-by: Alison Shao <a.shao@wustl.edu>
This commit is contained in:
co-authored by
Alison Shao
parent
2641e427be
commit
28262c20df
@@ -124,7 +124,6 @@ def batch(video_dir, save_dir, cur_chunk, num_chunks, num_frames=16, batch_size=
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
url = "https://raw.githubusercontent.com/EvolvingLMMs-Lab/sglang/dev/onevision_local/assets/jobs.mp4"
|
||||
|
||||
cache_dir = os.path.expanduser("~/.cache")
|
||||
|
||||
@@ -31,7 +31,7 @@ def tip_suggestion(s):
|
||||
|
||||
forks = s.fork(2)
|
||||
for i, f in enumerate(forks):
|
||||
f += f"Now, expand tip {i+1} into a paragraph:\n"
|
||||
f += f"Now, expand tip {i + 1} into a paragraph:\n"
|
||||
f += sgl.gen(f"detailed_tip", max_tokens=256, stop="\n\n")
|
||||
|
||||
s += "Tip 1:" + forks[0]["detailed_tip"] + "\n"
|
||||
|
||||
@@ -86,7 +86,7 @@ class GPUTrace2Graph:
|
||||
# Update current_end for overlapping intervals
|
||||
for i in range(1, len(df)):
|
||||
if i % display_units == 0:
|
||||
print(f"processing trace: {int(i/len(df) * 100)} %", end="\r")
|
||||
print(f"processing trace: {int(i / len(df) * 100)} %", end="\r")
|
||||
if starts[i] <= current_end:
|
||||
if ends[i] > current_end:
|
||||
# Partial overlap
|
||||
@@ -182,9 +182,9 @@ class GPUTrace2Graph:
|
||||
|
||||
def is_valid_file(self, base_file):
|
||||
"""asserts if base_file is non-existent or is empty"""
|
||||
assert (
|
||||
os.path.isfile(base_file) and os.path.getsize(base_file) > 0
|
||||
), f"{base_file} doesn't exist or is empty"
|
||||
assert os.path.isfile(base_file) and os.path.getsize(base_file) > 0, (
|
||||
f"{base_file} doesn't exist or is empty"
|
||||
)
|
||||
|
||||
def should_gen_file(self, new_file, base_file):
|
||||
"""figure out if new file should be generated from base_file"""
|
||||
|
||||
@@ -130,7 +130,7 @@ def send_requests(server_url, prompts, max_new_tokens, temperature):
|
||||
"""Sends generation requests to the running server for a list of prompts."""
|
||||
# Iterate through prompts and send requests
|
||||
for i, prompt in enumerate(prompts):
|
||||
print(f"\n[{i+1}/{len(prompts)}] Sending prompt: '{prompt}'")
|
||||
print(f"\n[{i + 1}/{len(prompts)}] Sending prompt: '{prompt}'")
|
||||
payload = {
|
||||
"prompt": prompt,
|
||||
"max_new_tokens": max_new_tokens,
|
||||
|
||||
@@ -17,8 +17,7 @@ def load_prompt() -> str:
|
||||
# https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2.5-1M/test-data/1m.txt
|
||||
|
||||
with urlopen(
|
||||
"https://qianwen-res.oss-cn-beijing.aliyuncs.com"
|
||||
"/Qwen2.5-1M/test-data/64k.txt",
|
||||
"https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2.5-1M/test-data/64k.txt",
|
||||
timeout=5,
|
||||
) as response:
|
||||
prompt = response.read().decode("utf-8")
|
||||
@@ -41,9 +40,7 @@ def process_requests(llm: sgl.Engine, prompts: list[str]) -> None:
|
||||
for output in outputs:
|
||||
prompt_token_ids = output["meta_info"]["prompt_tokens"]
|
||||
generated_text = output["text"]
|
||||
print(
|
||||
f"Prompt length: {prompt_token_ids}, " f"Generated text: {generated_text!r}"
|
||||
)
|
||||
print(f"Prompt length: {prompt_token_ids}, Generated text: {generated_text!r}")
|
||||
|
||||
|
||||
# Create an LLM.
|
||||
|
||||
@@ -44,7 +44,7 @@ def rerank_text_only():
|
||||
|
||||
print("Results (sorted by relevance):")
|
||||
for i, result in enumerate(results):
|
||||
print(f" {i+1}. Score: {result['score']:.4f} - {result['document'][:60]}...")
|
||||
print(f" {i + 1}. Score: {result['score']:.4f} - {result['document'][:60]}...")
|
||||
print()
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ def rerank_with_images():
|
||||
|
||||
print("Results (sorted by relevance):")
|
||||
for i, result in enumerate(results):
|
||||
print(f" {i+1}. Index: {result['index']}, Score: {result['score']:.4f}")
|
||||
print(f" {i + 1}. Index: {result['index']}, Score: {result['score']:.4f}")
|
||||
print()
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ def rerank_multimodal_query():
|
||||
|
||||
print("Results (sorted by relevance):")
|
||||
for i, result in enumerate(results):
|
||||
print(f" {i+1}. Index: {result['index']}, Score: {result['score']:.4f}")
|
||||
print(f" {i + 1}. Index: {result['index']}, Score: {result['score']:.4f}")
|
||||
print()
|
||||
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ def deploy_exported_model(
|
||||
outputs = llm.generate(prompts, sampling_params)
|
||||
|
||||
for i, output in enumerate(outputs):
|
||||
print(f"Prompt {i+1}: {prompts[i]}")
|
||||
print(f"Prompt {i + 1}: {prompts[i]}")
|
||||
print(f"Output: {output['text']}")
|
||||
print()
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ def report(manifest: TraceManifest) -> None:
|
||||
print(f" decode tokens : {manifest.num_decode_tokens}")
|
||||
print(f" total tokens : {total}")
|
||||
print(f" decode share : {decode_share:.1%}")
|
||||
print(f" wall clock : {manifest.elapsed_seconds/60:.1f} min")
|
||||
print(f" wall clock : {manifest.elapsed_seconds / 60:.1f} min")
|
||||
if manifest.calibration_mode == "rac":
|
||||
print(
|
||||
"\nThe decode share is the activation mass that prompt-only "
|
||||
|
||||
@@ -209,7 +209,7 @@ def report(results: List[EvalResult]) -> None:
|
||||
f"{result.model_path:<{width}} "
|
||||
f"{result.accuracy:>7.3f} "
|
||||
f"{result.mean_completion_tokens:>16.0f} "
|
||||
f"{result.elapsed_seconds/60:>10.1f}m"
|
||||
f"{result.elapsed_seconds / 60:>10.1f}m"
|
||||
)
|
||||
|
||||
if len(results) > 1:
|
||||
|
||||
Reference in New Issue
Block a user