-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b92e3e6
commit 1c6d941
Showing
5 changed files
with
50 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,69 @@ | ||
import subprocess | ||
from glob import glob | ||
from tempfile import TemporaryDirectory | ||
|
||
import pandas as pd | ||
from huggingface_hub import create_repo, snapshot_download, upload_file | ||
from tqdm import tqdm | ||
|
||
from optimum_benchmark import Benchmark | ||
|
||
REPO_TYPE = "dataset" | ||
REPO_ID = "optimum-benchmark/llm-perf-leaderboard" | ||
|
||
PERF_REPO_ID = "optimum-benchmark/llm-perf-pytorch-cuda-{subset}-{machine}" | ||
|
||
PERF_DF = "perf-df-{subset}-{machine}.csv" | ||
LLM_DF = "llm-df.csv" | ||
|
||
|
||
def gather_benchmarks(subset: str, machine: str): | ||
pull_repo_id = f"optimum-benchmark/llm-perf-pytorch-cuda-{subset}-{machine}" | ||
snapshot = snapshot_download(repo_type="dataset", repo_id=pull_repo_id, allow_patterns=["**/benchmark.json"]) | ||
perf_repo_id = PERF_REPO_ID.format(subset=subset, machine=machine) | ||
snapshot = snapshot_download(repo_type=REPO_TYPE, repo_id=perf_repo_id, allow_patterns=["**/benchmark.json"]) | ||
|
||
dfs = [] | ||
for file in tqdm(glob(f"{snapshot}/**/benchmark.json", recursive=True)): | ||
dfs.append(Benchmark.from_json(file).to_dataframe()) | ||
benchmarks = pd.concat(dfs, ignore_index=True) | ||
|
||
tmp_dir = TemporaryDirectory() | ||
push_repo_id = "optimum-benchmark/llm-perf-leaderboard" | ||
file_name = f"llm-perf-leaderboard-{subset}-{machine}.csv" | ||
benchmarks.to_csv(f"{tmp_dir.name}/{file_name}", index=False) | ||
perf_df = PERF_DF.format(subset=subset, machine=machine) | ||
benchmarks.to_csv(perf_df, index=False) | ||
create_repo(repo_id=REPO_ID, repo_type=REPO_TYPE, private=False, exist_ok=True) | ||
upload_file( | ||
repo_id=REPO_ID, | ||
repo_type=REPO_TYPE, | ||
path_in_repo=perf_df, | ||
path_or_fileobj=perf_df, | ||
) | ||
|
||
|
||
def update_perf_dfs(): | ||
for subset in ["unquantized", "bnb", "awq", "gptq"]: | ||
for machine in ["1xA10", "1xA100"]: | ||
try: | ||
gather_benchmarks(subset, machine) | ||
except Exception: | ||
print(f"Subset {subset} for machine {machine} not found") | ||
|
||
|
||
scrapping_script = """ | ||
git clone https://github.com/Weyaxi/scrape-open-llm-leaderboard.git | ||
pip install -r scrape-open-llm-leaderboard/requirements.txt | ||
python scrape-open-llm-leaderboard/main.py | ||
rm -rf scrape-open-llm-leaderboard | ||
""" | ||
|
||
|
||
create_repo(repo_id=push_repo_id, repo_type="dataset", private=False, exist_ok=True) | ||
def update_llm_df(): | ||
subprocess.run(scrapping_script, shell=True) | ||
create_repo(repo_id=REPO_ID, repo_type=REPO_TYPE, exist_ok=True, private=False) | ||
upload_file( | ||
path_or_fileobj=f"{tmp_dir.name}/{file_name}", path_in_repo=file_name, repo_id=push_repo_id, repo_type="dataset" | ||
repo_id=REPO_ID, | ||
repo_type=REPO_TYPE, | ||
path_in_repo="llm-df.csv", | ||
path_or_fileobj="llm-df.csv", | ||
) | ||
tmp_dir.cleanup() | ||
|
||
|
||
for subset in ["unquantized", "bnb", "awq", "gptq"]: | ||
for machine in ["1xA10", "1xA100"]: | ||
try: | ||
gather_benchmarks(subset, machine) | ||
except Exception: | ||
print(f"Subset {subset} for machine {machine} not found") | ||
if __name__ == "__main__": | ||
update_llm_df() | ||
update_perf_dfs() |
This file was deleted.
Oops, something went wrong.