44 push :
55 branches : [ main ]
66
7- env :
8- OUTPUT_SLACK_CHANNEL_ID : " C06L2SGMEEA"
9- HF_HUB_READ_TOKEN : ${{ secrets.HF_HUB_READ_TOKEN }}
10- HF_HOME : /mnt/cache
11- TRANSFORMERS_IS_CI : yes
12- OMP_NUM_THREADS : 8
13- MKL_NUM_THREADS : 8
14- RUN_SLOW : yes # For gated repositories, we still need to agree to share information on the Hub repo. page in order to get access. # This token is created under the bot `hf-transformers-bot`.
15- SIGOPT_API_TOKEN : ${{ secrets.SIGOPT_API_TOKEN }}
16- TF_FORCE_GPU_ALLOW_GROWTH : true
17-
187jobs :
198 get_modified_models :
209 name : " Get all modified files"
@@ -25,111 +14,143 @@ jobs:
2514 - name : Check out code
2615 uses : actions/checkout@v4
2716
28- - name : Get changed files
29- id : changed-files
30- uses : tj- actions/changed-files@1c8e6069583811afb28f97afeaf8e7da80c6be5c
17+ - name : Get changed files using `actions/github-script`
18+ id : get- changed-files
19+ uses : actions/github-script@v7
3120 with :
32- files : src/transformers/models/**
33-
34- - name : Run step if only the files listed above change
35- if : steps.changed-files.outputs.any_changed == 'true'
36- id : set-matrix
21+ script : |
22+ let files = [];
23+
24+ // Only handle push events
25+ if (context.eventName === 'push') {
26+ const afterSha = context.payload.after;
27+ const branchName = context.payload.ref.replace('refs/heads/', '');
28+
29+ let baseSha;
30+
31+ if (branchName === 'main') {
32+ console.log('Push to main branch, comparing to parent commit');
33+ // Get the parent commit of the pushed commit
34+ const { data: commit } = await github.rest.repos.getCommit({
35+ owner: context.repo.owner,
36+ repo: context.repo.repo,
37+ ref: afterSha
38+ });
39+ baseSha = commit.parents[0]?.sha;
40+ if (!baseSha) {
41+ throw new Error('No parent commit found for the pushed commit');
42+ }
43+ } else {
44+ console.log(`Push to branch ${branchName}, comparing to main`);
45+ baseSha = 'main';
46+ }
47+
48+ const { data: comparison } = await github.rest.repos.compareCommits({
49+ owner: context.repo.owner,
50+ repo: context.repo.repo,
51+ base: baseSha,
52+ head: afterSha
53+ });
54+
55+ // Include added, modified, and renamed files
56+ files = comparison.files
57+ .filter(file => file.status === 'added' || file.status === 'modified' || file.status === 'renamed')
58+ .map(file => file.filename);
59+ }
60+
61+ // Include all files under src/transformers/ (not just models subdirectory)
62+ const filteredFiles = files.filter(file =>
63+ file.startsWith('src/transformers/')
64+ );
65+
66+ core.setOutput('changed_files', filteredFiles.join(' '));
67+ core.setOutput('any_changed', filteredFiles.length > 0 ? 'true' : 'false');
68+
69+ - name : Parse changed files with Python
70+ if : steps.get-changed-files.outputs.any_changed == 'true'
3771 env :
38- ALL_CHANGED_FILES : ${{ steps.changed-files.outputs.all_changed_files }}
72+ CHANGED_FILES : ${{ steps.get-changed-files.outputs.changed_files }}
73+ id : set-matrix
3974 run : |
40- model_arrays=()
41- for file in $ALL_CHANGED_FILES; do
42- model_path="${file#*models/}"
43- model_path="models/${model_path%%/*}"
44- if grep -qFx "$model_path" utils/important_models.txt; then
45- # Append the file to the matrix string
46- model_arrays+=("$model_path")
47- fi
48- done
49- matrix_string=$(printf '"%s", ' "${model_arrays[@]}" | sed 's/, $//')
50- echo "matrix=[$matrix_string]" >> $GITHUB_OUTPUT
51- test_modified_files :
75+ python3 - << 'EOF'
76+ import os
77+ import sys
78+ import json
79+
80+ # Add the utils directory to Python path
81+ sys.path.insert(0, 'utils')
82+
83+ # Import the important models list
84+ from important_files import IMPORTANT_MODELS
85+
86+ print(f"Important models: {IMPORTANT_MODELS}")
87+
88+ # Get the changed files from the previous step
89+ changed_files_str = os.environ.get('CHANGED_FILES', '')
90+ changed_files = changed_files_str.split() if changed_files_str else []
91+
92+ # Filter to only Python files
93+ python_files = [f for f in changed_files if f.endswith('.py')]
94+ print(f"Python files changed: {python_files}")
95+
96+ result_models = set()
97+
98+ # Specific files that trigger all models
99+ transformers_utils_files = [
100+ 'modeling_utils.py',
101+ 'modeling_rope_utils.py',
102+ 'modeling_flash_attention_utils.py',
103+ 'modeling_attn_mask_utils.py',
104+ 'cache_utils.py',
105+ 'masking_utils.py',
106+ 'pytorch_utils.py'
107+ ]
108+
109+ # Single loop through all Python files
110+ for file in python_files:
111+ # Check for files under src/transformers/models/
112+ if file.startswith('src/transformers/models/'):
113+ remaining_path = file[len('src/transformers/models/'):]
114+ if '/' in remaining_path:
115+ model_dir = remaining_path.split('/')[0]
116+ if model_dir in IMPORTANT_MODELS:
117+ result_models.add(model_dir)
118+ print(f"Added model directory: {model_dir}")
119+
120+ # Check for specific files under src/transformers/ or src/transformers/generation/ files
121+ elif file.startswith('src/transformers/generation/') or \
122+ (file.startswith('src/transformers/') and os.path.basename(file) in transformers_utils_files):
123+ print(f"Found core file: {file} - including all important models")
124+ result_models.update(IMPORTANT_MODELS)
125+ break # No need to continue once we include all models
126+
127+ # Convert to sorted list and create matrix
128+ result_list = sorted(list(result_models))
129+ print(f"Final model list: {result_list}")
130+
131+ if result_list:
132+ matrix_json = json.dumps(result_list)
133+ print(f"matrix={matrix_json}")
134+
135+ # Write to GITHUB_OUTPUT
136+ with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
137+ f.write(f"matrix={matrix_json}\n")
138+ else:
139+ print("matrix=[]")
140+ with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
141+ f.write("matrix=[]\n")
142+ EOF
143+
144+ model-ci :
145+ name : Model CI
146+ uses : ./.github/workflows/self-scheduled.yml
52147 needs : get_modified_models
53- name : Slow & FA2 tests
54- runs-on :
55- group : aws-g5-4xlarge-cache
56- container :
57- image : huggingface/transformers-all-latest-gpu
58- options : --gpus all --privileged --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/
59- if : ${{ needs.get_modified_models.outputs.matrix != '[]' && needs.get_modified_models.outputs.matrix != '' && fromJson(needs.get_modified_models.outputs.matrix)[0] != null }}
60- strategy :
61- fail-fast : false
62- matrix :
63- model-name : ${{ fromJson(needs.get_modified_models.outputs.matrix) }}
64-
65- steps :
66- - name : Check out code
67- uses : actions/checkout@v4
68-
69- - name : Install locally transformers & other libs
70- run : |
71- apt install sudo
72- sudo -H pip install --upgrade pip
73- sudo -H pip uninstall -y transformers
74- sudo -H pip install -U -e ".[testing]"
75- MAX_JOBS=4 pip install flash-attn --no-build-isolation
76- pip install bitsandbytes
77-
78- - name : NVIDIA-SMI
79- run : |
80- nvidia-smi
81-
82- - name : Show installed libraries and their versions
83- run : pip freeze
84-
85- - name : Run FA2 tests
86- id : run_fa2_tests
87- run :
88- pytest -rsfE -m "flash_attn_test" --make-reports=${{ matrix.model-name }}_fa2_tests/ tests/${{ matrix.model-name }}/test_modeling_*
89-
90- - name : " Test suite reports artifacts: ${{ matrix.model-name }}_fa2_tests"
91- if : ${{ always() }}
92- uses : actions/upload-artifact@v4
93- with :
94- name : ${{ matrix.model-name }}_fa2_tests
95- path : /transformers/reports/${{ matrix.model-name }}_fa2_tests
96-
97- - name : Post to Slack
98- if : always()
99- uses : huggingface/hf-workflows/.github/actions/post-slack@main
100- with :
101- slack_channel : ${{ env.OUTPUT_SLACK_CHANNEL_ID }}
102- title : 🤗 Results of the FA2 tests - ${{ matrix.model-name }}
103- status : ${{ steps.run_fa2_tests.conclusion}}
104- slack_token : ${{ secrets.CI_SLACK_BOT_TOKEN }}
105-
106- - name : Run integration tests
107- id : run_integration_tests
108- if : always()
109- run :
110- pytest -rsfE -k "IntegrationTest" --make-reports=tests_integration_${{ matrix.model-name }} tests/${{ matrix.model-name }}/test_modeling_*
111-
112- - name : " Test suite reports artifacts: tests_integration_${{ matrix.model-name }}"
113- if : ${{ always() }}
114- uses : actions/upload-artifact@v4
115- with :
116- name : tests_integration_${{ matrix.model-name }}
117- path : /transformers/reports/tests_integration_${{ matrix.model-name }}
118-
119- - name : Post to Slack
120- if : always()
121- uses : huggingface/hf-workflows/.github/actions/post-slack@main
122- with :
123- slack_channel : ${{ env.OUTPUT_SLACK_CHANNEL_ID }}
124- title : 🤗 Results of the Integration tests - ${{ matrix.model-name }}
125- status : ${{ steps.run_integration_tests.conclusion}}
126- slack_token : ${{ secrets.CI_SLACK_BOT_TOKEN }}
127-
128- - name : Tailscale # In order to be able to SSH when a test fails
129- if : ${{ runner.debug == '1'}}
130- uses : huggingface/tailscale-action@v1
131- with :
132- authkey : ${{ secrets.TAILSCALE_SSH_AUTHKEY }}
133- slackChannel : ${{ secrets.SLACK_CIFEEDBACK_CHANNEL }}
134- slackToken : ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }}
135- waitForSSH : true
148+ with :
149+ job : run_models_gpu
150+ slack_report_channel : " #transformers-ci-push"
151+ docker : huggingface/transformers-all-latest-gpu
152+ ci_event : push
153+ report_repo_id : hf-internal-testing/transformers_ci_push
154+ commit_sha : ${{ github.sha }}
155+ models : ${{ needs.get_modified_models.outputs.matrix }}
156+ secrets : inherit
0 commit comments