Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ notifiers/*
# This lab's own settings: what it runs, its models, its channels.
lab.yaml
litellm/config.yaml
# pixi environments
.pixi/*
!.pixi/config.toml
58 changes: 46 additions & 12 deletions campaigns/example-local-compression/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
BANDWIDTH_MB_S = 5.0
CORPUS_MB = 8

LOCAL_DESC = """
LOCAL_DESC = (
"""
Compress the benchmark corpus with one zlib configuration and return its timings.

Returns `total_seconds` -- encode time plus transmit time at
Expand All @@ -30,21 +31,45 @@

Each run rebuilds the same corpus from a fixed seed, so results are comparable across
jobs. A job takes a few seconds.
""" % BANDWIDTH_MB_S
"""
% BANDWIDTH_MB_S
)

LOCAL_SCHEMA = {"level": int, "strategy": str, "memlevel": int, "windowlog": int}

_STRATEGIES = {"default": "Z_DEFAULT_STRATEGY", "filtered": "Z_FILTERED",
"huffman_only": "Z_HUFFMAN_ONLY", "rle": "Z_RLE", "fixed": "Z_FIXED"}
_STRATEGIES = {
"default": "Z_DEFAULT_STRATEGY",
"filtered": "Z_FILTERED",
"huffman_only": "Z_HUFFMAN_ONLY",
"rle": "Z_RLE",
"fixed": "Z_FIXED",
}


def _corpus(mb):
"""Deterministic mixed-entropy corpus: mostly repeated vocabulary, some noise, so
that both match-finding and entropy coding have something to do."""
import random

rnd = random.Random(1234)
words = ["alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta",
"run", "job", "node", "rank", "queue", "kernel", "buffer", "stride"]
words = [
"alpha",
"beta",
"gamma",
"delta",
"epsilon",
"zeta",
"eta",
"theta",
"run",
"job",
"node",
"rank",
"queue",
"kernel",
"buffer",
"stride",
]
out, size, target = [], 0, mb * 1024 * 1024
while size < target:
if rnd.random() < 0.75:
Expand All @@ -68,8 +93,10 @@ def local_fn(args):
if not 1 <= level <= 9:
return {"error": f"level must be 1-9, got {level}", "args": args}
if strategy not in _STRATEGIES:
return {"error": f"strategy must be one of {sorted(_STRATEGIES)}, got {strategy!r}",
"args": args}
return {
"error": f"strategy must be one of {sorted(_STRATEGIES)}, got {strategy!r}",
"args": args,
}
if not 1 <= memlevel <= 9:
return {"error": f"memlevel must be 1-9, got {memlevel}", "args": args}
if not 9 <= windowlog <= 15:
Expand All @@ -85,15 +112,22 @@ def local_fn(args):

transmit_seconds = len(blob) / (BANDWIDTH_MB_S * 1024 * 1024)
return {
"args": {"level": level, "strategy": strategy,
"memlevel": memlevel, "windowlog": windowlog},
"args": {
"level": level,
"strategy": strategy,
"memlevel": memlevel,
"windowlog": windowlog,
},
"total_seconds": round(encode_seconds + transmit_seconds, 4),
"encode_seconds": round(encode_seconds, 4),
"transmit_seconds": round(transmit_seconds, 4),
"ratio": round(len(data) / len(blob), 3),
"encode_mb_s": round(len(data) / (1024 * 1024) / encode_seconds, 2),
"raw_bytes": len(data),
"compressed_bytes": len(blob),
"diagnostics": {"bandwidth_mb_s": BANDWIDTH_MB_S, "corpus_mb": CORPUS_MB,
"zlib_version": zlib.ZLIB_VERSION},
"diagnostics": {
"bandwidth_mb_s": BANDWIDTH_MB_S,
"corpus_mb": CORPUS_MB,
"zlib_version": zlib.ZLIB_VERSION,
},
}
28 changes: 16 additions & 12 deletions campaigns/example-quick-optimum/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

# What the agent is looking for, and never sees. Kept here rather than hidden away so
# whoever runs this can check the agent's conclusion against the truth afterwards.
TRUE_OPTIMUM = 3.4 # where the response is genuinely lowest
TRUE_FLOOR = 12.0 # the response there
CURVATURE = 1.7 # how sharply it rises either side
ASYMMETRY = 0.35 # rises faster above the optimum than below
NOISE_SD = 0.6 # spread of one reading, so nearby settings overlap
TRUE_OPTIMUM = 3.4 # where the response is genuinely lowest
TRUE_FLOOR = 12.0 # the response there
CURVATURE = 1.7 # how sharply it rises either side
ASYMMETRY = 0.35 # rises faster above the optimum than below
NOISE_SD = 0.6 # spread of one reading, so nearby settings overlap

LOCAL_DESC = """
Measure the response of the system at one setting.
Expand All @@ -46,7 +46,7 @@ def _response(setting, rnd):
offset = setting - TRUE_OPTIMUM
rise = CURVATURE * offset * offset
if offset > 0:
rise += ASYMMETRY * offset * offset * offset # steeper above the optimum
rise += ASYMMETRY * offset * offset * offset # steeper above the optimum
return TRUE_FLOOR + rise + rnd.gauss(0.0, NOISE_SD)


Expand All @@ -57,12 +57,17 @@ def local_fn(args):
try:
setting = float(args.get("setting"))
except (TypeError, ValueError):
return {"error": f"setting must be a number, got {args.get('setting')!r}",
"args": args}
return {
"error": f"setting must be a number, got {args.get('setting')!r}",
"args": args,
}
replicates = int(args.get("replicates", 1) or 1)

if not 0.0 <= setting <= 10.0:
return {"error": f"setting must be between 0 and 10, got {setting}", "args": args}
return {
"error": f"setting must be between 0 and 10, got {setting}",
"args": args,
}
if not 1 <= replicates <= 9:
return {"error": f"replicates must be 1-9, got {replicates}", "args": args}

Expand All @@ -71,7 +76,7 @@ def local_fn(args):
rnd = random.Random()
readings = []
for _ in range(replicates):
time.sleep(0.8) # a job is work, not an instant lookup
time.sleep(0.8) # a job is work, not an instant lookup
readings.append(round(_response(setting, rnd), 4))

mean = sum(readings) / len(readings)
Expand All @@ -81,6 +86,5 @@ def local_fn(args):
"response": round(mean, 4),
"noise_sd": round(spread, 4),
"readings": readings,
"diagnostics": {"replicates": replicates,
"single_reading_sd": NOISE_SD},
"diagnostics": {"replicates": replicates, "single_reading_sd": NOISE_SD},
}
115 changes: 82 additions & 33 deletions campaigns/example-vllm-inference-opt/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,39 @@ def remote_fn(args, target):
timeout = int(target.get("timeout", 5400))

os.makedirs(work_dir, exist_ok=True)
tag = (f"{bench_mode}_in{input_len}_out{output_len}_tp{tp}_{dtype}"
f"_eager{int(enforce_eager)}_seqs{max_num_seqs}_{int(time.time())}")
tag = (
f"{bench_mode}_in{input_len}_out{output_len}_tp{tp}_{dtype}"
f"_eager{int(enforce_eager)}_seqs{max_num_seqs}_{int(time.time())}"
)
log_path = os.path.join(work_dir, f"{tag}.log")

# --- environment ---
env = dict(os.environ)
for k, v in (target.get("env") or {}).items():
env[str(k)] = str(v)
for k, v in env_extra.items(): # agent's overrides win
for k, v in env_extra.items(): # agent's overrides win
env[str(k)] = str(v)

# --- build the vLLM command ---
cmd = ["vllm", "bench", bench_mode,
"--model", model,
"--input-len", str(input_len),
"--output-len", str(output_len),
"--dtype", dtype,
"--tensor-parallel-size", str(tp),
"--max-model-len", str(max_model_len),
"--max-num-seqs", str(max_num_seqs)]
cmd = [
"vllm",
"bench",
bench_mode,
"--model",
model,
"--input-len",
str(input_len),
"--output-len",
str(output_len),
"--dtype",
dtype,
"--tensor-parallel-size",
str(tp),
"--max-model-len",
str(max_model_len),
"--max-num-seqs",
str(max_num_seqs),
]
if bench_mode == "latency":
cmd += ["--batch-size", "1", "--num-iters-warmup", "2", "--num-iters", "2"]
else:
Expand All @@ -142,57 +155,93 @@ def remote_fn(args, target):
# The module load has to happen in the same shell as vllm, so go through bash.
setup = target.get("worker_setup", "")
shell_cmd = (setup + " && " if setup else "") + " ".join(
"'" + c + "'" if " " in c else c for c in cmd)
"'" + c + "'" if " " in c else c for c in cmd
)

started = time.time()
try:
proc = subprocess.run(["bash", "-lc", shell_cmd], capture_output=True,
text=True, timeout=timeout, env=env)
proc = subprocess.run(
["bash", "-lc", shell_cmd],
capture_output=True,
text=True,
timeout=timeout,
env=env,
)
except Exception as e:
return {"error": f"{type(e).__name__}: {e}", "cmd": shell_cmd, "key_env": env_extra}
return {
"error": f"{type(e).__name__}: {e}",
"cmd": shell_cmd,
"key_env": env_extra,
}

out = (proc.stdout or "") + "\n" + (proc.stderr or "")

# Always keep the full log. The existing benchmark discards these, and the vLLM
# startup banner is the most informative artefact available.
try:
with open(log_path, "w") as f:
f.write("$ " + shell_cmd + "\n\nENV_EXTRA: " + json.dumps(env_extra) + "\n\n" + out)
f.write(
"$ "
+ shell_cmd
+ "\n\nENV_EXTRA: "
+ json.dumps(env_extra)
+ "\n\n"
+ out
)
except Exception:
pass

# --- startup diagnostics: what did vLLM actually do? ---
diagnostics = {}
patterns = {
"platform": r"[Pp]latform[:\s]+(\S+)",
"platform": r"[Pp]latform[:\s]+(\S+)",
"attention_backend": r"[Uu]sing (\S+) backend",
"graph_capture": r"(?i)(graph capturing finished|CUDA graphs|Capturing.*graph|enforce_eager)",
"kv_cache_blocks": r"(?i)GPU KV cache size[:\s]+([\d,]+)",
"num_devices": r"(?i)(?:world_size|tensor.parallel.size)[=:\s]+(\d+)",
"vllm_version": r"(?i)vLLM (?:API server )?version[:\s]+(\S+)",
"graph_capture": r"(?i)(graph capturing finished|CUDA graphs|Capturing.*graph|enforce_eager)",
"kv_cache_blocks": r"(?i)GPU KV cache size[:\s]+([\d,]+)",
"num_devices": r"(?i)(?:world_size|tensor.parallel.size)[=:\s]+(\d+)",
"vllm_version": r"(?i)vLLM (?:API server )?version[:\s]+(\S+)",
}
for name, pat in patterns.items():
m = re.search(pat, out)
if m:
diagnostics[name] = m.group(1) if m.groups() else m.group(0)
warn = [l.strip() for l in out.splitlines()
if re.search(r"(?i)\b(warning|fallback|not supported|disabled)\b", l)]
warn = [
l.strip()
for l in out.splitlines()
if re.search(r"(?i)\b(warning|fallback|not supported|disabled)\b", l)
]
if warn:
diagnostics["warnings"] = warn[:15]

if proc.returncode != 0:
return {"error": out[-3000:], "cmd": shell_cmd, "log": log_path,
"diagnostics": diagnostics, "key_env": env_extra}
return {
"error": out[-3000:],
"cmd": shell_cmd,
"log": log_path,
"diagnostics": diagnostics,
"key_env": env_extra,
}

# --- metrics ---
result = {"bench_mode": bench_mode, "model": model, "input_len": input_len,
"output_len": output_len, "tensor_parallel_size": tp, "dtype": dtype,
"enforce_eager": enforce_eager, "max_num_seqs": max_num_seqs,
"max_model_len": max_model_len, "env_extra": env_extra,
"wall_seconds": round(time.time() - started, 1),
"log": log_path, "diagnostics": diagnostics}

m = re.search(r"Throughput:\s*([\d.]+)\s*requests/s,\s*([\d.]+)\s*(?:total\s+)?tokens/s", out)
result = {
"bench_mode": bench_mode,
"model": model,
"input_len": input_len,
"output_len": output_len,
"tensor_parallel_size": tp,
"dtype": dtype,
"enforce_eager": enforce_eager,
"max_num_seqs": max_num_seqs,
"max_model_len": max_model_len,
"env_extra": env_extra,
"wall_seconds": round(time.time() - started, 1),
"log": log_path,
"diagnostics": diagnostics,
}

m = re.search(
r"Throughput:\s*([\d.]+)\s*requests/s,\s*([\d.]+)\s*(?:total\s+)?tokens/s", out
)
if m:
result["requests_per_sec"] = float(m.group(1))
result["throughput_tokens_per_sec"] = float(m.group(2))
Expand Down
Loading