h2loop-bench 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: h2loop-bench
3
+ Version: 0.1.0
4
+ Summary: H2Loop inference contest benchmark submission tool
5
+ Requires-Python: >=3.8
6
+ Requires-Dist: requests>=2.28.0
@@ -0,0 +1,3 @@
1
+ from ._core import result
2
+
3
+ __all__ = ["result"]
@@ -0,0 +1,155 @@
1
+ import json
2
+ import os
3
+ import shutil
4
+ import subprocess
5
+ import requests
6
+
7
+ _SUBMIT_URL = "https://inference-contest-airtable-629464143743.asia-south1.run.app/"
8
+
9
+
10
+ def _run_benchmark(port: int) -> None:
11
+ os.makedirs("results", exist_ok=True)
12
+
13
+ cmd = [
14
+ "vllm", "bench", "serve",
15
+ "--backend", "openai",
16
+ "--base-url", f"http://localhost:{port}/v1",
17
+ "--endpoint", "/completions",
18
+ "--model", "Qwen/Qwen2.5-0.5B",
19
+ "--tokenizer", "Qwen/Qwen2.5-0.5B",
20
+ "--max-concurrency", "50",
21
+ "--num-prompts", "200",
22
+ "--ignore-eos",
23
+ "--random-input-len", "512",
24
+ "--random-output-len", "512",
25
+ "--save-result",
26
+ "--result-dir", "./results",
27
+ "--result-filename", "baseline.json",
28
+ "--label", "baseline",
29
+ ]
30
+
31
+ if not shutil.which("vllm"):
32
+ raise RuntimeError(
33
+ "'vllm' is not installed or not on PATH. "
34
+ "Install it with: pip install vllm"
35
+ )
36
+
37
+ print(f"Running benchmark against http://localhost:{port}/v1 ...")
38
+ result = subprocess.run(cmd)
39
+
40
+ if result.returncode != 0:
41
+ raise RuntimeError(
42
+ f"Benchmark failed with exit code {result.returncode}. "
43
+ f"Make sure your vLLM server is running on port {port} and is healthy."
44
+ )
45
+
46
+
47
+ def _load_results(path: str = "results/baseline.json") -> dict:
48
+ if not os.path.exists(path):
49
+ raise FileNotFoundError(
50
+ f"Results file not found at '{path}'. "
51
+ "The benchmark may not have completed successfully."
52
+ )
53
+
54
+ with open(path) as f:
55
+ data = json.load(f)
56
+
57
+ total = data["completed"] + data.get("failed", 0)
58
+
59
+ print("=" * 60)
60
+ print("BASELINE RESULTS")
61
+ print("=" * 60)
62
+ print(f" Output throughput: {data['output_throughput']:.2f} tok/s")
63
+ print(f" Mean TPOT: {data['mean_tpot_ms']:.2f} ms")
64
+ print(f" P99 TPOT: {data['p99_tpot_ms']:.2f} ms (limit: 50 ms)")
65
+ print(f" Mean TTFT: {data['mean_ttft_ms']:.2f} ms")
66
+ print(f" P99 TTFT: {data['p99_ttft_ms']:.2f} ms (limit: 2000 ms)")
67
+ print(f" Completed requests: {data['completed']}/{total}")
68
+ print(f" Failed requests: {data.get('failed', 0)}")
69
+ print("=" * 60)
70
+
71
+ return data
72
+
73
+
74
+ def _collect_gpu_info() -> list | None:
75
+ if not shutil.which("nvidia-smi"):
76
+ return None
77
+ try:
78
+ proc = subprocess.run(
79
+ [
80
+ "nvidia-smi",
81
+ "--query-gpu=name,memory.total,memory.used,utilization.gpu",
82
+ "--format=csv,noheader,nounits",
83
+ ],
84
+ capture_output=True,
85
+ text=True,
86
+ check=True,
87
+ )
88
+ gpus = []
89
+ for line in proc.stdout.strip().split("\n"):
90
+ name, mem_total, mem_used, util = [x.strip() for x in line.split(",")]
91
+ gpus.append(
92
+ {
93
+ "name": name,
94
+ "memory_total_mb": int(mem_total),
95
+ "memory_used_mb": int(mem_used),
96
+ "utilization_percent": int(util),
97
+ }
98
+ )
99
+ return gpus
100
+ except Exception:
101
+ return None
102
+
103
+
104
+ def _submit(
105
+ name: str,
106
+ email: str,
107
+ contact_number: str,
108
+ colab_link: str,
109
+ data: dict,
110
+ ) -> None:
111
+ gpu_info = _collect_gpu_info()
112
+ gpu_str = ""
113
+ if gpu_info:
114
+ gpu_str = ", ".join(
115
+ f"{g['name']} ({g['memory_total_mb']} MB)" for g in gpu_info
116
+ )
117
+
118
+ payload = {
119
+ "fields": {
120
+ "Name": name,
121
+ "Email": email,
122
+ "Contact number": contact_number,
123
+ "Colab_Link": colab_link,
124
+ "Output Throughput (tok/s)": data["output_throughput"],
125
+ "99 TPOT (ms)": data["p99_tpot_ms"],
126
+ "P99 TTFT (ms)": data["p99_ttft_ms"],
127
+ "GPU Info": gpu_str,
128
+ }
129
+ }
130
+
131
+ print("\nSubmitting results to H2Loop...")
132
+ try:
133
+ response = requests.post(_SUBMIT_URL, json=payload)
134
+ response.raise_for_status()
135
+ except requests.exceptions.ConnectionError:
136
+ raise ConnectionError("Could not connect to submission server. Check your internet connection.")
137
+ except requests.exceptions.Timeout:
138
+ raise TimeoutError("Submission request timed out.")
139
+ except requests.exceptions.HTTPError as e:
140
+ raise RuntimeError(f"Submission failed: {e.response.status_code} {e.response.text}")
141
+
142
+ record_id = response.json()["record_id"]
143
+ print(f"Submission successful! Record ID: {record_id}")
144
+
145
+
146
+ def result(
147
+ name: str,
148
+ email: str,
149
+ contact_number: str,
150
+ colab_link: str,
151
+ port: int,
152
+ ) -> None:
153
+ _run_benchmark(port)
154
+ data = _load_results()
155
+ _submit(name, email, contact_number, colab_link, data)
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: h2loop-bench
3
+ Version: 0.1.0
4
+ Summary: H2Loop inference contest benchmark submission tool
5
+ Requires-Python: >=3.8
6
+ Requires-Dist: requests>=2.28.0
@@ -0,0 +1,8 @@
1
+ pyproject.toml
2
+ h2loop_bench/__init__.py
3
+ h2loop_bench/_core.py
4
+ h2loop_bench.egg-info/PKG-INFO
5
+ h2loop_bench.egg-info/SOURCES.txt
6
+ h2loop_bench.egg-info/dependency_links.txt
7
+ h2loop_bench.egg-info/requires.txt
8
+ h2loop_bench.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.28.0
@@ -0,0 +1 @@
1
+ h2loop_bench
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "h2loop-bench"
7
+ version = "0.1.0"
8
+ description = "H2Loop inference contest benchmark submission tool"
9
+ requires-python = ">=3.8"
10
+ dependencies = [
11
+ "requests>=2.28.0",
12
+ ]
13
+
14
+ [tool.setuptools.packages.find]
15
+ where = ["."]
16
+ include = ["h2loop_bench*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+