File size: 1,387 Bytes
745627a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/bin/bash
# HF Jobs entrypoint. Expects the dataset repo mounted at /profile (read-only) and HF_TOKEN set.
set -euo pipefail
REPO_ID=${REPO_ID:-trl-internal-testing/ci-profile}
export TQDM_DISABLE=1 PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True PYTORCH_ALLOC_CONF=expandable_segments:True
apt-get update && apt-get install -y git
pip install uv
git clone --depth 1 https://github.com/huggingface/trl.git /trl
cd /trl
uv venv --python 3.12
source .venv/bin/activate
uv pip install ".[dev]"
SHA=$(git rev-parse HEAD)
DATE=$(date -u +%Y-%m-%d)
NAME="${DATE}_${SHA:0:8}"
export PROFILE_OUT=/tmp/$NAME.jsonl
export PROFILE_META=$(python -c "
import json, torch, transformers
print(json.dumps({'date': '$DATE', 'sha': '$SHA', 'torch': torch.__version__,
'transformers': transformers.__version__, 'gpu': torch.cuda.get_device_name()}))")
export PYTHONPATH=/profile/scripts
# Serial on purpose: parallel workers share the GPU and distort per-test timings.
pytest -p profile_plugin -m "not slow and not low_priority" -v -p no:cacheprovider tests || true
python /profile/scripts/report.py "$PROFILE_OUT" /profile/data > /tmp/$NAME.md
cat /tmp/$NAME.md
hf upload "$REPO_ID" "$PROFILE_OUT" "data/$NAME.jsonl" --repo-type dataset --commit-message "Profile $NAME"
hf upload "$REPO_ID" /tmp/$NAME.md "summaries/$NAME.md" --repo-type dataset --commit-message "Summary $NAME"
|