forked from huggingface/trl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmark CI (actual) (huggingface#754)
* refactor and benchmark * update code * Add accelerate logging * logs * quick fix * update config * precommit * modify training example * fix multi-gpu all_reduce error `Tensors must be CUDA and dense` * support more models and benchmark * update * add changes * upload benchmark * precommit * add tyro as a dependency * add tyro * pre-commit * precommit * weird... * lol typo * precommit * sigh * push changes * Update benchmark/README.md Co-authored-by: Leandro von Werra <[email protected]> * Add experiments * upload image to tag specific folder * add openrlbenchmark documentation * rename * remove unused field * precommit * update slurm template * add dependency * update dependency * .. * . * quick change * push changes * update * update * remove wandb tag code * quick change * precommit * update test * update dependency * update test * update benchmark dependency --------- Co-authored-by: Leandro von Werra <[email protected]>
- Loading branch information
1 parent
c55f2a0
commit 912a183
Showing
10 changed files
with
165 additions
and
65 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 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
echo PATH is $PATH | ||
echo PYTHONPATH is $PYTHONPATH | ||
echo whcih python is $(which python) | ||
|
||
export WANDB_ENTITY=huggingface | ||
|
||
bash benchmark/benchmark_core.sh > output.txt | ||
|
||
# Extract Job IDs into an array | ||
job_ids=($(grep "Job ID:" output.txt | awk '{print $3}')) | ||
|
||
# Extract WANDB_TAGS into an array | ||
WANDB_TAGS=($(grep "WANDB_TAGS:" output.txt | awk '{print $2}')) | ||
WANDB_TAGS=($(echo $WANDB_TAGS | tr "," "\n")) | ||
|
||
# Print to verify | ||
echo "Job IDs: ${job_ids[@]}" | ||
echo "WANDB_TAGS: ${WANDB_TAGS[@]}" | ||
|
||
TAGS_STRING="?tag=${WANDB_TAGS[0]}" | ||
FOLDER_STRING="${WANDB_TAGS[0]}" | ||
for tag in "${WANDB_TAGS[@]:1}"; do | ||
TAGS_STRING+="&tag=$tag" | ||
FOLDER_STRING+="_$tag" | ||
done | ||
|
||
echo "TAGS_STRING: $TAGS_STRING" | ||
echo "FOLDER_STRING: $FOLDER_STRING" | ||
|
||
TAGS_STRING=$TAGS_STRING FOLDER_STRING=$FOLDER_STRING sbatch --dependency=afterany:$job_ids benchmark/post_github.ghproxy.topment.sbatch |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# pip install openrlbenchmark==0.2.1a5 | ||
# see https://github.com/openrlbenchmark/openrlbenchmark#get-started for documentation | ||
echo "we deal with $TAGS_STRING" | ||
|
||
# "sentiment_tuning_gpt2xl_grad_accu$TAGS_STRING" \ | ||
|
||
python -m openrlbenchmark.rlops_multi_metrics \ | ||
--filters '?we=huggingface&wpn=trl&xaxis=_step&ceik=trl_ppo_trainer_config.value.reward_model&cen=trl_ppo_trainer_config.value.exp_name&metrics=env/reward_mean&metrics=objective/kl' \ | ||
"sentiment_tuning$TAGS_STRING" \ | ||
--env-ids sentiment-analysis:lvwerra/distilbert-imdb \ | ||
--no-check-empty-runs \ | ||
--pc.ncols 2 \ | ||
--pc.ncols-legend 1 \ | ||
--output-filename benchmark/trl/$FOLDER_STRING/different_models \ | ||
--scan-history | ||
|
||
|
||
python benchmark/upload_benchmark.py \ | ||
--folder_path="benchmark/trl/$FOLDER_STRING" \ | ||
--path_in_repo="images/benchmark/$FOLDER_STRING" \ | ||
--repo_id="trl-internal-testing/example-images" \ | ||
--repo_type="dataset" | ||
|
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import json | ||
import os | ||
|
||
from ghapi.all import GhApi | ||
|
||
|
||
FOLDER_STRING = os.environ.get("FOLDER_STRING", "") | ||
folder = f"benchmark/trl/{FOLDER_STRING}" | ||
host_url = f"https://huggingface.co/datasets/trl-internal-testing/example-images/resolve/main/images/benchmark/{FOLDER_STRING}" | ||
|
||
# Create a GitHub API instance | ||
github_context = json.loads(os.environ["GITHUB_CONTEXT"]) | ||
token = os.environ["PERSONAL_ACCESS_TOKEN_GITHUB"] # this needs to refreshed every 12 months | ||
status_message = "**[COSTA BENCHMARK BOT]**: Here are the results" | ||
body = status_message | ||
repo = github_context["repository"] | ||
owner, repo = repo.split("/") | ||
api = GhApi(owner=owner, repo=repo, token=token) | ||
|
||
# for each `.png` file in the folder, add it to the comment | ||
for file in os.listdir(folder): | ||
if file.endswith(".png"): | ||
body += f"\n" | ||
|
||
# Create a comment on the issue | ||
api.issues.create_comment(issue_number=github_context["event"]["issue"]["number"], body=body) |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
#SBATCH --job-name=trl | ||
#SBATCH --partition=production-cluster | ||
#SBATCH --ntasks=1 | ||
#SBATCH --output=slurm/logs/%x_%j.out | ||
|
||
sleep 2m | ||
bash benchmark/plot_core.sh | ||
srun python benchmark/post_github.ghproxy.topment.py |
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,16 +1,16 @@ | ||
#!/bin/bash | ||
#SBATCH --partition=dev-cluster | ||
#SBATCH --job-name=trl | ||
#SBATCH --partition=production-cluster | ||
#SBATCH --gpus-per-task={{gpus_per_task}} | ||
#SBATCH --cpus-per-gpu={{cpus_per_gpu}} | ||
#SBATCH --ntasks={{ntasks}} | ||
#SBATCH --mem-per-cpu=11G | ||
#SBATCH --output=slurm/logs/%x_%j.out | ||
#SBATCH --array={{array}} | ||
|
||
#SBATCH --exclude=ip-26-0-156-239,ip-26-0-148-151,ip-26-0-146-212,ip-26-0-145-137,ip-26-0-146-249,ip-26-0-146-149,ip-26-0-147-233,ip-26-0-145-154,ip-26-0-144-35,ip-26-0-144-189,ip-26-0-146-183,ip-26-0-147-120,ip-26-0-144-95,ip-26-0-145-193 | ||
{{nodes}} | ||
|
||
seeds={{seeds}} | ||
seed=${seeds[$SLURM_ARRAY_TASK_ID % {{len_seeds}}]} | ||
|
||
echo "Running task $SLURM_ARRAY_TASK_ID with seed: $seed" | ||
srun {{command}} --seed $seed | ||
srun {{command}} --ppo_config.seed $seed |
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