@@ -2,7 +2,18 @@ name: "Accuracy Tests"
2
2
3
3
on :
4
4
workflow_dispatch :
5
-
5
+ inputs :
6
+ MockRun :
7
+ description : " Array of test groups to run. If empty, all tests will be run."
8
+ required : false
9
+ default : " "
10
+ docker_tag :
11
+ description : ' Docker container tag to use'
12
+ required : false
13
+ type : string
14
+ default : ' ghcr.io/tenstorrent/pytorch2.0_ttnn/ubuntu-22.04-amd64:latest'
15
+ schedule :
16
+ - cron : " 0 21 * * 6" # Run every Saturday at 9:00 PM UTC
6
17
permissions :
7
18
actions : read
8
19
contents : write
@@ -11,30 +22,66 @@ permissions:
11
22
pull-requests : read
12
23
13
24
jobs :
14
- tools-tests :
25
+ count-test-files :
26
+ runs-on : ubuntu-latest
27
+ outputs :
28
+ matrix : ${{ steps.count-files.outputs.matrix }}
29
+ num_files : ${{ steps.count-files.outputs.num_files }}
15
30
env :
16
- pytest_verbosity : 2
17
- pytest_report_title : " ⭐️ Tools Tests"
18
- runs-on : ["in-service"]
31
+ MOCK_RUN : ${{ github.event.inputs.MockRun }}
32
+ steps :
33
+ - name : Checkout Code
34
+ uses : actions/checkout@v4
35
+
36
+ - name : Count Test Files
37
+ id : count-files
38
+ uses : ./.github/actions/count_test_files
39
+ with :
40
+ test_directory : ' tests/models/'
41
+ model-tests :
42
+ needs : [count-test-files]
43
+ runs-on : ["in-service", "nfs"]
19
44
container :
20
- image : ghcr.io/tenstorrent/pytorch2.0_ttnn/ubuntu-22.04-amd64:latest
45
+ image : ${{ inputs.docker_tag }}
21
46
credentials :
22
47
username : ${{ github.actor }}
23
48
password : ${{ secrets.GH_TOKEN }}
24
49
options : >-
25
50
--rm -v /dev/hugepages-1G:/dev/hugepages-1G --device /dev/tenstorrent
26
51
-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }}
27
- steps :
52
+ -v /mnt/tt-metal-pytorch-cache/.cache:/root/.cache
53
+ env :
54
+ pytest_verbosity : 0
55
+ TORCH_HOME : /mnt/tt-metal-pytorch-cache/.cache/torch
56
+ HF_HOME : /mnt/tt-metal-pytorch-cache/.cache/huggingface
57
+ strategy :
58
+ matrix :
59
+ group : ${{ fromJson(needs.count-test-files.outputs.matrix) }}
60
+ steps :
28
61
- uses : actions/checkout@v4
29
- - uses : ./.github/actions/common_repo_setup
30
- - name : Run Tools Tests
62
+ with :
63
+ lfs : true
64
+ fetch-depth : 0
65
+ - name : docker-cleanup
31
66
run : |
32
- python3 -m pytest --github-report tests/tools/ -s
67
+ docker system prune -a -f --volumes
68
+ df -h # Debug space
69
+ - uses : ./.github/actions/common_model_tests
70
+ with :
71
+ splits : ${{ needs.count-test-files.outputs.num_files }}
72
+ matrix_group : ${{ matrix.group }}
73
+ commit_report : ${{ github.event.inputs.commit_report }}
74
+ - name : Upload Accuracy Tests Artifact
75
+ uses : actions/upload-artifact@v4
76
+ with :
77
+ name : autogen-accuracy-tests-group-${{ matrix.group }}
78
+ path : tests/autogen_accuracy_tests/
33
79
34
80
gen-model-accuracy :
81
+ needs : [model-tests]
35
82
runs-on : ["in-service"]
36
83
container :
37
- image : ghcr.io/tenstorrent/pytorch2.0_ttnn/ubuntu-22.04-amd64:latest
84
+ image : ${{ inputs.docker_tag }}
38
85
credentials :
39
86
username : ${{ github.actor }}
40
87
password : ${{ secrets.GH_TOKEN }}
@@ -48,73 +95,68 @@ jobs:
48
95
steps :
49
96
- uses : actions/checkout@v4
50
97
- uses : ./.github/actions/common_repo_setup
51
-
98
+
52
99
- name : Download All Accuracy Tests and Inputs Artifacts
53
100
uses : actions/download-artifact@v4
54
101
with :
55
- pattern : model -accuracy-tests-group-*
102
+ pattern : autogen -accuracy-tests-group-*
56
103
merge-multiple : true
57
104
path : tests/autogen_accuracy_tests/
58
105
59
106
- name : Calculate Number of Groups
60
107
id : calculate-groups
61
108
run : |
62
109
# Count the number of test files
63
- num_files=$(find tests/autogen_accuracy_tests -type f -name "*.py" | wc -l)
64
-
65
- # Get the number of available CPUs (or set a default if not available)
66
- num_cpus=$(nproc || echo 4)
67
-
68
- # Calculate the number of groups (e.g., 1 group per CPU, or adjust as needed)
69
- num_groups=$((num_files < num_cpus ? num_files : num_cpus))
70
-
110
+ num_groups=$(find tests/autogen_accuracy_tests -type f -name "*.py" | wc -l)
71
111
# Ensure at least 1 group
72
112
num_groups=$((num_groups > 0 ? num_groups : 1))
73
-
74
113
# Generate the list of groups as JSON
75
- groups=$(seq 1 $num_groups | jq -c '.')
114
+ groups=$(seq 1 $num_groups | jq -c --slurp '.')
115
+ echo "Found: $groups"
76
116
echo "groups=$groups" >> $GITHUB_OUTPUT
77
- outputs :
78
- groups : ${{ steps.calculate-groups.outputs.groups }}
79
-
80
- - name : Upload Accuracy Tests Artifact
81
- uses : actions/upload-artifact@v4
82
- with :
83
- name : autogen-accuracy-tests
84
- path : tests/autogen_accuracy_tests/
85
117
86
118
test-model-accuracy :
87
119
needs : [gen-model-accuracy]
88
- runs-on : ["in-service"]
120
+ runs-on : ["in-service", "nfs" ]
89
121
container :
90
- image : ghcr.io/tenstorrent/pytorch2.0_ttnn/ubuntu-22.04-amd64:latest
122
+ image : ${{ inputs.docker_tag }}
91
123
credentials :
92
124
username : ${{ github.actor }}
93
125
password : ${{ secrets.GH_TOKEN }}
94
126
options : >-
95
127
--rm -v /dev/hugepages-1G:/dev/hugepages-1G --device /dev/tenstorrent
96
128
-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }}
129
+ -v /mnt/tt-metal-pytorch-cache/.cache:/root/.cache
97
130
env :
98
131
PYTHONPATH : ${{ github.workspace }}
132
+ TORCH_HOME : /mnt/tt-metal-pytorch-cache/.cache/torch
133
+ HF_HOME : /mnt/tt-metal-pytorch-cache/.cache/huggingface
99
134
strategy :
100
135
matrix :
101
136
group : ${{ fromJson(needs.gen-model-accuracy.outputs.groups) }}
102
137
steps :
103
138
- uses : actions/checkout@v4
104
139
- uses : ./.github/actions/common_repo_setup
105
-
140
+ - name : docker-cleanup
141
+ run : |
142
+ docker system prune -a -f --volumes
143
+ df -h # Debug space
106
144
- name : Download Accuracy Tests Artifact
107
145
uses : actions/download-artifact@v4
108
146
with :
109
- name : autogen-accuracy-tests
147
+ pattern : autogen-accuracy-tests-group-*
110
148
path : tests/autogen_accuracy_tests/
111
149
112
150
- name : Run Accuracy Tests
113
151
run : |
114
152
cd tests/autogen_accuracy_tests
115
- set +e
116
153
test_file=$(find . -type f -name "*.py" | sed -n "${{ matrix.group }}p")
117
154
python3 -m pytest $test_file -s
155
+ exit_code=$?
156
+ if [ $exit_code -ne 0 ]; then
157
+ echo "Tests failed with exit code $exit_code"
158
+ exit $exit_code
159
+ fi
118
160
exit 0;
119
161
shell : bash
120
162
0 commit comments