Datasets:
Download export.py from axjns/llmfit-benchmarks: direct link, hf CLI and curl.
- Browser
- Download file 8.01 kB
-
https://huggingface.co/datasets/axjns/llmfit-benchmarks/resolve/main/export.py
- Command line
-
hf download hf://datasets/axjns/llmfit-benchmarks/export.py
-
curl -L -o export.py https://huggingface.co/datasets/axjns/llmfit-benchmarks/resolve/main/export.py
8.01 kB
| #!/usr/bin/env python3 | |
| import argparse | |
| import datetime | |
| import hashlib | |
| import json | |
| import re | |
| from pathlib import Path | |
| import pyarrow as pa | |
| import pyarrow.parquet as pq | |
| def iso_from_unix(timestamp): | |
| return datetime.datetime.fromtimestamp(timestamp, datetime.UTC).isoformat().replace("+00:00", "Z") | |
| def public_text(value): | |
| if value is None: | |
| return None | |
| private_source_name = "local" + "maxxing" | |
| return re.sub(private_source_name, "external source", value, flags=re.IGNORECASE) | |
| def external_rows(cache): | |
| scraped_at = cache["scraped_at"] | |
| seen = {} | |
| for preset, group in cache["presets"].items(): | |
| for row in group["rows"]: | |
| previous = seen.get(row["id"]) | |
| if previous is not None: | |
| if previous != row: | |
| raise ValueError(f"conflicting external rows for {row['id']}") | |
| continue | |
| seen[row["id"]] = row | |
| model = row["model"] | |
| hardware = row["hardware"] | |
| engine = row["engine"] | |
| flags = row.get("engineFlags") or {} | |
| user = row.get("user") or {} | |
| yield { | |
| "benchmark_id": f"external-community:{row['id']}", | |
| "source": "external-community", | |
| "source_record_id": row["id"], | |
| "source_snapshot_at": scraped_at, | |
| "measured_at": row.get("createdAt"), | |
| "schema_version": 1, | |
| "model_id": model.get("hfId"), | |
| "model_revision": row.get("modelRevision"), | |
| "model_display_name": model.get("displayName"), | |
| "base_model_id": (model.get("baseModel") or {}).get("hfId"), | |
| "model_family": model.get("family"), | |
| "model_params_billion": model.get("params"), | |
| "model_active_params_billion": model.get("activeParams"), | |
| "model_is_moe": model.get("isMoE"), | |
| "runtime": engine.get("engineName"), | |
| "runtime_version": engine.get("engineVersion"), | |
| "backend": engine.get("backend"), | |
| "quantization": engine.get("quantization"), | |
| "hardware_label": row.get("hardwareGroupLabel") or preset, | |
| "hardware_class": hardware.get("hwClass"), | |
| "accelerator": hardware.get("gpuName"), | |
| "accelerator_count": hardware.get("gpuCount"), | |
| "vram_gb": hardware.get("vramGb"), | |
| "unified_memory_gb": hardware.get("unifiedMemoryGb"), | |
| "ram_gb": None, | |
| "cpu": hardware.get("cpu"), | |
| "cpu_cores": None, | |
| "os": hardware.get("os"), | |
| "prompt_tokens": row.get("promptTokens"), | |
| "output_tokens": row.get("outputTokens"), | |
| "context_length": row.get("contextLength"), | |
| "batch_size": row.get("batchSize"), | |
| "num_runs": None, | |
| "ttft_ms": row.get("ttftMs"), | |
| "output_tps": row.get("tokSOut"), | |
| "prefill_tps": row.get("tokSPrefill"), | |
| "total_tps": row.get("tokSTotal"), | |
| "min_tps": None, | |
| "max_tps": None, | |
| "total_time_ms": None, | |
| "peak_vram_gb": row.get("peakVramGb"), | |
| "gpu_power_watts": row.get("gpuPowerWatts") or [], | |
| "total_power_watts": row.get("totalPowerWatts"), | |
| "tensor_parallel": flags.get("tensorParallel"), | |
| "gpu_layers": flags.get("gpuLayers"), | |
| "kv_cache_dtype": flags.get("kvCacheDtype"), | |
| "attention_backend": flags.get("attentionBackend"), | |
| "flash_attention": flags.get("flashAttn"), | |
| "speculative_decoding": flags.get("specDecoding"), | |
| "mtp_enabled": flags.get("mtpEnabled"), | |
| "submitter": user.get("username"), | |
| "submitter_verified": user.get("verified"), | |
| "notes": public_text(row.get("notes")), | |
| } | |
| def community_rows(community_dir): | |
| for path in sorted(community_dir.glob("*/*.json")): | |
| submission = json.loads(path.read_text()) | |
| hardware = submission["hardware"] | |
| relative = path.relative_to(community_dir).as_posix() | |
| measured_at = iso_from_unix(submission["submittedAtUnix"]) | |
| for index, result in enumerate(submission["results"]): | |
| record_id = f"{relative}#{index}" | |
| digest = hashlib.sha256(record_id.encode()).hexdigest()[:24] | |
| yield { | |
| "benchmark_id": f"llmfit-community:{digest}", | |
| "source": "llmfit-community", | |
| "source_record_id": record_id, | |
| "source_snapshot_at": None, | |
| "measured_at": measured_at, | |
| "schema_version": submission["schemaVersion"], | |
| "model_id": result["model"], | |
| "model_revision": None, | |
| "model_display_name": None, | |
| "base_model_id": None, | |
| "model_family": None, | |
| "model_params_billion": None, | |
| "model_active_params_billion": None, | |
| "model_is_moe": None, | |
| "runtime": result["provider"], | |
| "runtime_version": submission["tool"].get("version"), | |
| "backend": None, | |
| "quantization": None, | |
| "hardware_label": hardware["hardwareName"], | |
| "hardware_class": hardware["hwClass"], | |
| "accelerator": hardware["hardwareName"], | |
| "accelerator_count": hardware["gpuCount"], | |
| "vram_gb": hardware["vramGb"], | |
| "unified_memory_gb": hardware["memTierGb"] if hardware["unifiedMemory"] else None, | |
| "ram_gb": hardware["ramGb"], | |
| "cpu": hardware["cpu"], | |
| "cpu_cores": hardware["cpuCores"], | |
| "os": hardware["os"], | |
| "prompt_tokens": None, | |
| "output_tokens": result["avgOutputTokens"], | |
| "context_length": None, | |
| "batch_size": None, | |
| "num_runs": result["numRuns"], | |
| "ttft_ms": result["avgTtftMs"], | |
| "output_tps": result["avgTps"], | |
| "prefill_tps": None, | |
| "total_tps": None, | |
| "min_tps": result["minTps"], | |
| "max_tps": result["maxTps"], | |
| "total_time_ms": result["avgTotalMs"], | |
| "peak_vram_gb": None, | |
| "gpu_power_watts": [], | |
| "total_power_watts": None, | |
| "tensor_parallel": None, | |
| "gpu_layers": None, | |
| "kv_cache_dtype": None, | |
| "attention_backend": None, | |
| "flash_attention": None, | |
| "speculative_decoding": None, | |
| "mtp_enabled": None, | |
| "submitter": None, | |
| "submitter_verified": None, | |
| "notes": None, | |
| } | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("llmfit", type=Path) | |
| parser.add_argument("output", type=Path) | |
| args = parser.parse_args() | |
| data_dir = args.llmfit / "llmfit-core" / "data" | |
| cache = json.loads((data_dir / "benchmark_cache.json").read_text()) | |
| rows = list(external_rows(cache)) + list(community_rows(data_dir / "community")) | |
| rows.sort(key=lambda row: (row["measured_at"] or "", row["benchmark_id"])) | |
| ids = [row["benchmark_id"] for row in rows] | |
| if len(ids) != len(set(ids)): | |
| raise SystemExit("duplicate benchmark_id") | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| table = pa.Table.from_pylist(rows) | |
| pq.write_table(table, args.output, compression="zstd") | |
| by_source = {} | |
| for row in rows: | |
| by_source[row["source"]] = by_source.get(row["source"], 0) + 1 | |
| print(json.dumps({"rows": len(rows), "sources": by_source}, sort_keys=True)) | |
| if __name__ == "__main__": | |
| main() | |