@@ -2,134 +2,68 @@ name: NVIDIA PyTorch/CUDA Job
22on :
33 workflow_dispatch :
44 inputs :
5- script_content :
6- description : ' Content of Python/CUDA script (.py or .cu file) '
5+ payload :
6+ description : ' Content of the user submission, as json string '
77 required : true
88 type : string
9- filename :
10- description : ' Name of script (supports .py or .cu)'
11- required : true
12- type : string
13- reference_content :
14- description : ' Content of the reference code script (optional)'
15- required : false
16- type : string
17- reference_filename :
18- description : ' Name of reference script (supports .py or .cu)'
19- required : false
20- type : string
21- eval_content :
22- description : ' Content of the outer eval code script (optional)'
23- required : false
24- type : string
25- eval_filename :
26- description : ' Name of outer eval script (supports .py or .cu)'
9+ requirements :
10+ description : ' Contents for a requirements.txt file'
2711 required : false
2812 type : string
2913
3014jobs :
31- train :
15+ run :
3216 runs-on : [gpumode-nvidia-arc]
3317 timeout-minutes : 10
3418 container :
3519 image : nvidia/cuda:12.4.0-devel-ubuntu22.04
3620 steps :
37- - name : Setup Python
38- uses : actions/setup-python@v5
39- with :
40- python-version : ' 3.10'
41-
42- - name : Install uv
43- uses : astral-sh/setup-uv@v3
44- with :
45- version : " latest"
46-
47- - name : Setup Python environment
48- run : |
49- uv venv .venv
50- echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
51- echo "$PWD/.venv/bin" >> $GITHUB_PATH
52-
53- - name : Create script file
54- shell : bash
55- run : |
56- cat << 'EOL' > ${{ github.event.inputs.filename }}
57- ${{ github.event.inputs.script_content }}
58- EOL
59- cat ${{ github.event.inputs.filename }} # Debug: show file contents
21+ - uses : actions/checkout@v3
22+
23+ - name : Setup Python
24+ uses : actions/setup-python@v5
25+ with :
26+ python-version : ' 3.10'
27+
28+ - name : Create input files
29+ shell : bash
30+ run : |
31+ cat > "payload.json" <<'EOL'
32+ ${{ github.event.inputs.payload }}
33+ EOL
6034
61- - name : Create reference scripts if provided
62- shell : bash
63- run : |
64- if [[ -n "${{ github.event.inputs.reference_filename }}" ]]; then
65- echo "Creating reference script..."
66- cat > "${{ github.event.inputs.reference_filename }}" <<EOL
67- ${{ github.event.inputs.reference_content }}
68- EOL
69- cat "${{ github.event.inputs.reference_filename }}" # Debug: Show file contents
70- else
71- echo "No reference content provided."
72- fi
35+ - name : Install uv
36+ uses : astral-sh/setup-uv@v3
37+ with :
38+ version : " latest"
7339
74- - name : Create eval scripts if provided
75- shell : bash
76- run : |
77- if [[ -n "${{ github.event.inputs.eval_filename }}" ]]; then
78- echo "Creating eval script..."
79- cat > "${{ github.event.inputs.eval_filename }}" <<EOL
80- ${{ github.event.inputs.eval_content }}
81- EOL
82- cat "${{ github.event.inputs.eval_filename }}" # Debug: Show file contents
83- else
84- echo "No eval content provided."
85- fi
40+ - name : Setup Python environment
41+ shell : bash
42+ run : |
43+ uv venv .venv
44+ echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
45+ echo "$PWD/.venv/bin" >> $GITHUB_PATH
8646
87- - name : Install dependencies
88- run : |
89- if grep -rE "(import torch|from torch)" "${{ github.event.inputs.filename }}"; then
90- echo "PyTorch detected, installing torch"
91- uv pip install numpy torch setuptools ninja
92- fi
93- if grep -rE "(import triton|from triton)" "${{ github.event.inputs.filename }}"; then
94- echo "Triton detected, installing triton"
95- uv pip install triton
96- fi
47+ if [[ -n "${{ github.event.inputs.requirements }}" ]]; then
48+ cat > "requirements.txt" <<'EOL'
49+ ${{ github.event.inputs.requirements }}
50+ EOL
51+ uv pip install -r "requirements.txt"
52+ fi
9753
98- - name : Run script
99- shell : bash
100- run : |
101- # Check if eval content exists without trying to evaluate it
102- if [ -f "${{ github.event.inputs.eval_filename }}" ]; then
103- if [[ "${{ github.event.inputs.eval_filename }}" == *.cu ]]; then
104- echo "Compiling and running CUDA files..."
105- CUDA_FILES="${{ github.event.inputs.eval_filename }}"
106- echo "Compiling: $CUDA_FILES"
107- nvcc $CUDA_FILES -o cuda_program
108- ./cuda_program > training.log 2>&1
109- else
110- echo "Running Python file..."
111- python3 "${{ github.event.inputs.eval_filename }}" > training.log 2>&1
112- fi
113- else
114- if [[ "${{ github.event.inputs.filename }}" == *.cu ]]; then
115- echo "Compiling and running CUDA file..."
116- nvcc "${{ github.event.inputs.filename }}" -o cuda_program
117- ./cuda_program > training.log 2>&1
118- else
119- echo "Running Python file..."
120- python3 "${{ github.event.inputs.filename }}" > training.log 2>&1
121- fi
122- fi
123- cat training.log # Debug: show output
54+ - name : Run script
55+ shell : bash
56+ run : |
57+ python .github/workflows/runner.py
58+ cat result.json # Debug: show output
12459
125- - name : Upload training artifacts
126- uses : actions/upload-artifact@v4
127- if : always()
128- with :
129- name : training-artifacts
130- path : |
131- training.log
132- ${{ github.event.inputs.filename }}
60+ - name : Upload training artifacts
61+ uses : actions/upload-artifact@v4
62+ if : always()
63+ with :
64+ name : run-result
65+ path : |
66+ result.json
13367
13468 env :
13569 CUDA_VISIBLE_DEVICES : 0
0 commit comments