char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
da9b5d68c
char/aliceai-t5-moe
1name : "ccache-buckets" 2description : "Save/restore latest GitHub Actions ccache matching a key prefix to/from HF buckets" 3inputs : 4key : 5description : "Cache key prefix to match and load" 6required : true 7folder : 8description : "Bucket folder containing ccache files" 9required : true 10evict-old-files : 11description : "Corresponds to the ccache --evict-older-than AGE option, where AGE is the number of seconds or days followed by the 's' or 'd' suffix respectively." 12default : '' 13save : 14description : "Save ccache" 15required : false 16default : false 17type : boolean 18hf_bucket : 19description : 'Hugging Face buckets path' 20required : true 21 22runs : 23using : "composite" 24steps : 25- name : Install Hugging Face Hub CLI 26shell : bash 27run : | 28python3 -m venv .venv-hf 29.venv-hf/bin/pip install -U huggingface_hub==1.28.0 30 31- name : Restore ccache from buckets 32if : ${{ inputs.save != 'true' }} 33shell : bash 34run : | 35set +e -uo pipefail 36source .venv-hf/bin/activate 37CCACHE_DIR=$(ccache -k cache_dir) 38if [[ -d "$CCACHE_DIR" ]]; then 39CACHE_PATH=$(hf buckets list "hf://buckets/${{ inputs.hf_bucket }}/${{ inputs.folder }}" --json | jq -r '[.[] | select(.type == "file") | select(.path | startswith("${{ inputs.folder }}/${{ inputs.key }}") and endswith(".tar.gz"))] | sort_by(.path) | last | .path // ""') 40if [[ -n "$CACHE_PATH" ]]; then 41echo "Restoring ccache from '$CACHE_PATH'." 42hf buckets cp "hf://buckets/${{ inputs.hf_bucket }}/$CACHE_PATH" ccache_bucket.tar.gz 43mkdir -p ccache_bucket 44if tar -xzf ccache_bucket.tar.gz -C ccache_bucket; then 45rm -rf "$CCACHE_DIR" 46mv ccache_bucket "$CCACHE_DIR" 47ccache -z 48fi 49rm ccache_bucket.tar.gz 50else 51echo "No ccache found." 52fi 53else 54echo "'$CCACHE_DIR' not found." 55fi 56 57- name : Save ccache to buckets 58if : ${{ inputs.save == 'true' }} 59shell : bash 60run : | 61if [[ -n "$HF_TOKEN" ]]; then 62set +e -uo pipefail 63source .venv-hf/bin/activate 64CCACHE_DIR=$(ccache -k cache_dir) 65if [[ -d "$CCACHE_DIR" ]]; then 66ccache -s 67if [[ -n "${{ inputs.evict-old-files }}" ]]; then 68ccache --evict-older-than "${{ inputs.evict-old-files }}" 69fi 70DATESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ') 71CACHEFILE="${{ inputs.key }}-$DATESTAMP.tar.gz" 72if tar -czf ccache_bucket.tar.gz -C "$CCACHE_DIR" .; then 73hf buckets cp ccache_bucket.tar.gz "hf://buckets/${{ inputs.hf_bucket }}/${{ inputs.folder }}/$CACHEFILE" 74fi 75rm ccache_bucket.tar.gz 76else 77echo "'$CCACHE_DIR' not found." 78fi 79fi 80 81- name : Remove old ccache files from buckets 82if : ${{ inputs.save == 'true' }} 83shell : bash 84run : | 85 if [[ -n "$HF_TOKEN" ]]; then 86 set +e -uo pipefail 87 source .venv-hf/bin/activate 88 CACHE_FILES=$(hf buckets list "hf://buckets/${{ inputs.hf_bucket }}/${{ inputs.folder }}" --json | jq -r '[.[] | select(.type == "file") | select((.uploaded_at | .[:19]+"Z" | fromdateiso8601) < (now - 5 * 60)) | select(.path | startswith("${{ inputs.folder }}/${{ inputs.key }}") and endswith(".tar.gz"))] | sort_by(.path)[:-1] | .[] | [.path // ""] | @tsv') 89 if [[ -n "$CACHE_FILES" ]]; then 90 echo "Removing old ccache files..." 91 while IFS=$'\t' read -r CACHE_PATH; do 92 hf buckets rm "hf://buckets/${{ inputs.hf_bucket }}/$CACHE_PATH" -y 93 done <<< "$CACHE_FILES" 94 fi 95 fi