Skip to content

Commit 600f2db

Browse files
[MLIR][CI] Linux GPU MLIR / Graph Compiler workflow (#38744)
1 parent d42881a commit 600f2db

1 file changed

Lines changed: 346 additions & 0 deletions

File tree

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
name: Linux GPU MLIR / Graph Compiler ( Ubuntu 24.04 )
2+
3+
# Validates the MLIR / Graph-Compiler path of the GPU plugin:
4+
# * one build with -DENABLE_MLIR_FOR_GPU=ON (LLVM + Graph Compiler are built from source,
5+
# LLVM install tree is cached on /mount, the cache is saved on push only)
6+
# * all MLIR functional tests with MLIR enabled (OV_GPU_ENABLE_MLIR=1)
7+
#
8+
# `paths:` below narrows the trigger down to MLIR-related files.
9+
10+
on:
11+
workflow_dispatch:
12+
inputs:
13+
target-branch:
14+
description: 'Target branch for the build; taken from event context by default'
15+
type: string
16+
required: false
17+
graph-compiler-ref:
18+
description: 'Graph Compiler branch/tag/SHA; GRAPH_COMPILER_TAG from graph-compiler.cmake by default'
19+
type: string
20+
required: false
21+
pull_request:
22+
types:
23+
- opened
24+
- synchronize
25+
- reopened
26+
- ready_for_review
27+
paths: &mlir_paths
28+
- '.github/workflows/dev_gpu_linux_mlir.yml'
29+
- 'cmake/features.cmake'
30+
- 'src/plugins/intel_gpu/CMakeLists.txt'
31+
- 'src/plugins/intel_gpu/thirdparty/cmake/**'
32+
- 'src/plugins/intel_gpu/include/intel_gpu/op/mlir_op.hpp'
33+
- 'src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp'
34+
- 'src/plugins/intel_gpu/include/intel_gpu/primitives/mlir_primitive.hpp'
35+
- 'src/plugins/intel_gpu/include/intel_gpu/runtime/event.hpp'
36+
- 'src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp'
37+
- 'src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp'
38+
- 'src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl'
39+
- 'src/plugins/intel_gpu/include/intel_gpu/runtime/stream.hpp'
40+
- 'src/plugins/intel_gpu/src/graph/impls/common/mlir_primitive.*'
41+
- 'src/plugins/intel_gpu/src/graph/impls/common/register.*'
42+
- 'src/plugins/intel_gpu/src/graph/include/mlir_primitive_inst.h'
43+
- 'src/plugins/intel_gpu/src/graph/mlir_primitive.cpp'
44+
- 'src/plugins/intel_gpu/src/graph/registry/mlir_primitive_impls.cpp'
45+
- 'src/plugins/intel_gpu/src/graph/registry/registry.hpp'
46+
- 'src/plugins/intel_gpu/src/plugin/ops/mlir_op.cpp'
47+
- 'src/plugins/intel_gpu/src/plugin/transformations/mlir/**'
48+
- 'src/plugins/intel_gpu/src/plugin/transformations/op/mlir_op.cpp'
49+
- 'src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp'
50+
- 'src/plugins/intel_gpu/src/runtime/ocl/ocl_base_event.hpp'
51+
- 'src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.hpp'
52+
- 'src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.*'
53+
- 'src/plugins/intel_gpu/tests/functional/CMakeLists.txt'
54+
- 'src/plugins/intel_gpu/tests/functional/mlir_op/**'
55+
push:
56+
branches:
57+
- master
58+
- 'releases/**'
59+
paths: *mlir_paths
60+
61+
concurrency:
62+
# github.ref is not unique in post-commit
63+
group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-linux-gpu-mlir-dev
64+
cancel-in-progress: true
65+
66+
permissions: read-all
67+
68+
jobs:
69+
Smart_CI:
70+
runs-on: ubuntu-latest
71+
if: github.event.pull_request.draft == false || github.run_attempt > 1
72+
outputs:
73+
affected_components: "${{ steps.smart_ci.outputs.affected_components }}"
74+
changed_components: "${{ steps.smart_ci.outputs.changed_components }}"
75+
skip_workflow: "${{ steps.smart_ci.outputs.skip_workflow }}"
76+
steps:
77+
- name: checkout action
78+
uses: ababushk/checkout@dd591a6a2ac25618db4eda86e7e0d938f88cf01b # cherry_pick_retries
79+
timeout-minutes: 15
80+
with:
81+
sparse-checkout: .github/actions/smart-ci
82+
83+
- name: Get affected components
84+
id: smart_ci
85+
uses: ./.github/actions/smart-ci
86+
with:
87+
repository: ${{ github.repository }}
88+
pr: ${{ github.event.number }}
89+
commit_sha: ${{ github.sha }}
90+
ref_name: ${{ github.ref_name }}
91+
component_pattern: "category: (.*)"
92+
repo_token: ${{ secrets.GITHUB_TOKEN }}
93+
skip_when_only_listed_labels_set: 'docs'
94+
skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg,*/layer_tests_summary/*,*/conformance/*'
95+
96+
- name: Show affected components
97+
env:
98+
AFFECTED_COMPONENTS: ${{ toJSON(steps.smart_ci.outputs.affected_components) }}
99+
run: echo "${AFFECTED_COMPONENTS}"
100+
shell: bash
101+
102+
Docker:
103+
needs: Smart_CI
104+
runs-on: aks-linux-4-cores-16gb-docker-build
105+
container:
106+
image: openvinogithubactions.azurecr.io/docker_build:0.2
107+
volumes:
108+
- /mount:/mount
109+
outputs:
110+
images: "${{ steps.handle_docker.outputs.images && steps.handle_docker.outputs.images || steps.mock_image.outputs.images }}"
111+
steps:
112+
- name: Set mock output images if pipeline should be skipped
113+
if: ${{ needs.smart_ci.outputs.skip_workflow == 'True' }}
114+
id: mock_image
115+
run: echo "images={\"ov_test\":{\"ubuntu_24_04_x64_dgpu\":\"mock\"},\"ov_build\":{\"ubuntu_24_04_x64\":\"mock\"}}" >> "$GITHUB_OUTPUT"
116+
117+
- name: Checkout
118+
if: ${{ needs.smart_ci.outputs.skip_workflow != 'True' }}
119+
uses: ababushk/checkout@dd591a6a2ac25618db4eda86e7e0d938f88cf01b # cherry_pick_retries
120+
timeout-minutes: 15
121+
122+
- uses: ./.github/actions/handle_docker
123+
if: ${{ needs.smart_ci.outputs.skip_workflow != 'True' }}
124+
id: handle_docker
125+
with:
126+
images: |
127+
ov_build/ubuntu_24_04_x64
128+
ov_test/ubuntu_24_04_x64_dgpu
129+
registry: 'openvinogithubactions.azurecr.io'
130+
dockerfiles_root_dir: '.github/dockerfiles'
131+
changed_components: ${{ needs.smart_ci.outputs.changed_components }}
132+
133+
Build:
134+
name: Build (LLVM + Graph Compiler + OpenVINO)
135+
needs: [ Docker, Smart_CI ]
136+
if: "!needs.smart_ci.outputs.skip_workflow && fromJSON(needs.smart_ci.outputs.affected_components).GPU"
137+
timeout-minutes: 120
138+
defaults:
139+
run:
140+
shell: bash
141+
runs-on: aks-linux-16-cores-64gb
142+
container:
143+
image: ${{ fromJSON(needs.docker.outputs.images).ov_build.ubuntu_24_04_x64 }}
144+
volumes:
145+
- /mount:/mount
146+
- /home/runner/secrets/:/secrets:ro
147+
- ${{ github.workspace }}:${{ github.workspace }} # Needed as ${{ github.workspace }} is not working correctly when using Docker
148+
options: >-
149+
-e SCCACHE_AZURE_BLOB_CONTAINER
150+
env:
151+
CMAKE_BUILD_TYPE: 'Release'
152+
CMAKE_GENERATOR: 'Ninja'
153+
CMAKE_CXX_COMPILER_LAUNCHER: sccache
154+
CMAKE_C_COMPILER_LAUNCHER: sccache
155+
SCCACHE_IGNORE_SERVER_IO_ERROR: 1
156+
SCCACHE_SERVER_PORT: 35555
157+
SCCACHE_ERROR_LOG: ${{ github.workspace }}/sccache_log.txt
158+
SCCACHE_LOG: warn
159+
SCCACHE_AZURE_KEY_PREFIX: ubuntu_24_04_x86_64_mlir_Release
160+
# nproc does not respect Kubernetes pod CPU limits
161+
CMAKE_BUILD_PARALLEL_LEVEL: '15'
162+
OPENVINO_REPO: ${{ github.workspace }}/openvino
163+
BUILD_DIR: ${{ github.workspace }}/openvino_build
164+
INSTALL_DIR: ${{ github.workspace }}/openvino_install
165+
INSTALL_TEST_DIR: ${{ github.workspace }}/openvino_tests
166+
GC_REPO: ${{ github.workspace }}/graph-compiler
167+
# Graph Compiler `scripts/build.sh` inputs. With GITHUB_ACTIONS=true and
168+
# LLVM_BUILD_TARGET=install it skips the LLVM build when LLVM_INSTALL_DIR already
169+
# contains lib/cmake/mlir/MLIRConfig.cmake (i.e. on a cache hit).
170+
GC_BUILD_TYPE: 'Release'
171+
LLVM_BUILD_TYPE: 'Release'
172+
GC_DYLINK: 'OFF'
173+
LLVM_CMAKE_ARGS: '-DMLIR_ENABLE_BINDINGS_PYTHON=OFF'
174+
GC_CMAKE_ARGS: '-DGC_ENABLE_TEST=OFF -DGC_ENABLE_TOOLS=OFF -DGC_ENABLE_PYTHON_BINDINGS=OFF'
175+
LLVM_BUILD_TARGET: install
176+
LLVM_INSTALL_DIR: ${{ github.workspace }}/graph-compiler/externals/llvm/Release
177+
GC_INSTALL_DIR: ${{ github.workspace }}/graph-compiler/build/Release/install
178+
# TODO: move to a dedicated shared mount once the runners provide one.
179+
LLVM_CACHE_DIR: /mount/caches/ccache/graph-compiler/llvm/ubuntu_24_04_x86_64_Release
180+
181+
steps:
182+
- name: Load SCCACHE_AZURE_CONNECTION_STRING from file
183+
run: |
184+
SCCACHE_AZURE_CONNECTION_STRING="$(cat /secrets/sccache/connection-string)"
185+
# nosemgrep: yaml.github-actions.security.audit.unsafe-add-mask-workflow-command.unsafe-add-mask-workflow-command
186+
echo "::add-mask::${SCCACHE_AZURE_CONNECTION_STRING}"
187+
echo "SCCACHE_AZURE_CONNECTION_STRING=${SCCACHE_AZURE_CONNECTION_STRING}" >> "$GITHUB_ENV"
188+
189+
- name: Clone OpenVINO
190+
uses: ababushk/checkout@dd591a6a2ac25618db4eda86e7e0d938f88cf01b # cherry_pick_retries
191+
timeout-minutes: 15
192+
with:
193+
path: ${{ env.OPENVINO_REPO }}
194+
submodules: 'recursive'
195+
ref: ${{ inputs.target-branch }}
196+
197+
- name: Clone Graph Compiler
198+
env:
199+
GRAPH_COMPILER_REF: ${{ inputs.graph-compiler-ref }}
200+
run: |
201+
cmake_file="${OPENVINO_REPO}/src/plugins/intel_gpu/thirdparty/cmake/graph-compiler.cmake"
202+
ref="${GRAPH_COMPILER_REF:-$(sed -nE 's/.*GRAPH_COMPILER_TAG "([^"]+)".*/\1/p' "$cmake_file")}"
203+
repo="$(sed -nE 's/.*GRAPH_COMPILER_REPO "([^"]+)".*/\1/p' "$cmake_file")"
204+
[ -n "$ref" ] || { echo "Failed to resolve Graph Compiler ref"; exit 1; }
205+
[ -n "$repo" ] || { echo "Failed to resolve Graph Compiler repository"; exit 1; }
206+
git init "${GC_REPO}"
207+
git -C "${GC_REPO}" fetch --depth 1 "${repo}" "$ref"
208+
git -C "${GC_REPO}" checkout FETCH_HEAD
209+
echo "Graph Compiler $ref at $(git -C "${GC_REPO}" rev-parse HEAD)"
210+
211+
- name: Compute LLVM cache key
212+
id: cache_keys
213+
working-directory: ${{ env.GC_REPO }}
214+
run: |
215+
llvm_sha=$({ cat cmake/llvm-version.txt scripts/build.sh scripts/utils.sh patches/*.patch; c++ --version; echo "${LLVM_CMAKE_ARGS}"; } \
216+
| sha1sum | cut -d' ' -f1)
217+
echo "llvm-key=llvm-${LLVM_BUILD_TYPE}-dylink${GC_DYLINK}-${llvm_sha}" >> "$GITHUB_OUTPUT"
218+
# The restore action creates the target directory with a non-recursive mkdir
219+
mkdir -p "$(dirname "${LLVM_INSTALL_DIR}")"
220+
221+
- name: Setup LLVM cache
222+
id: llvm_cache
223+
uses: ./openvino/.github/actions/cache
224+
with:
225+
save-always: ${{ github.event_name == 'push' && 'true' || 'false' }}
226+
cache-path: ${{ env.LLVM_CACHE_DIR }}
227+
path: ${{ env.LLVM_INSTALL_DIR }}
228+
key: ${{ steps.cache_keys.outputs.llvm-key }}
229+
230+
- name: Clean up old LLVM caches
231+
if: github.event_name == 'push'
232+
uses: ./openvino/.github/actions/cache/cleanup
233+
with:
234+
cache-path: ${{ env.LLVM_CACHE_DIR }}
235+
key: ${{ steps.cache_keys.outputs.llvm-key }}
236+
restore-keys: llvm-${{ env.LLVM_BUILD_TYPE }}-dylink${{ env.GC_DYLINK }}-
237+
cache-size: 3
238+
max-cache-size: 6
239+
240+
- name: Clean sccache stats
241+
run: ${SCCACHE_PATH} --zero-stats
242+
243+
- name: Build LLVM and Graph Compiler
244+
working-directory: ${{ env.GC_REPO }}
245+
run: ./scripts/build.sh
246+
247+
- name: Show and clean sccache stats (LLVM + Graph Compiler)
248+
run: |
249+
${SCCACHE_PATH} --show-stats
250+
${SCCACHE_PATH} --zero-stats
251+
252+
- name: Shrink the LLVM install tree
253+
if: steps.llvm_cache.outputs.cache-hit != 'true'
254+
run: |
255+
# Unused by the GC and OV builds. Files referenced by the LLVM cmake config are
256+
# truncated rather than deleted, otherwise `find_package(LLVM)` fails on a cache hit.
257+
# lib/*.a must be kept: GC and OV link LLVM/MLIR statically.
258+
rm -rf "${LLVM_INSTALL_DIR}/share" "${LLVM_INSTALL_DIR}/python_packages" "${LLVM_INSTALL_DIR}/src"
259+
find "${LLVM_INSTALL_DIR}/bin/" -type f \
260+
! -name '*tblgen*' ! -name mlir-linalg-ods-yaml-gen ! -name mlir-pdll ! -name mlir-src-sharder \
261+
! -name FileCheck ! -name llvm-lit \
262+
-exec truncate -s 0 {} +
263+
du -sh "${LLVM_INSTALL_DIR}"
264+
265+
- name: Build OpenVINO
266+
run: |
267+
# ENABLE_DEBUG_CAPS is required: OV_GPU_ENABLE_MLIR is a debug-only option
268+
cmake -S "${OPENVINO_REPO}" -B "${BUILD_DIR}" \
269+
-DENABLE_MLIR_FOR_GPU=ON \
270+
-DENABLE_DEBUG_CAPS=ON \
271+
-DCMAKE_PREFIX_PATH="${GC_INSTALL_DIR};${LLVM_INSTALL_DIR}" \
272+
-DENABLE_ONEDNN_FOR_GPU=OFF \
273+
-DENABLE_TESTS=ON \
274+
-DENABLE_INTEL_CPU=OFF \
275+
-DENABLE_INTEL_NPU=OFF \
276+
-DENABLE_NCC_STYLE=OFF \
277+
-DENABLE_OV_ONNX_FRONTEND=OFF -DENABLE_OV_PADDLE_FRONTEND=OFF \
278+
-DENABLE_OV_TF_FRONTEND=OFF -DENABLE_OV_TF_LITE_FRONTEND=OFF \
279+
-DENABLE_OV_PYTORCH_FRONTEND=OFF -DENABLE_OV_JAX_FRONTEND=OFF \
280+
-DENABLE_PYTHON=OFF -DENABLE_SAMPLES=OFF \
281+
-DENABLE_STRICT_DEPENDENCIES=OFF \
282+
-DENABLE_SYSTEM_OPENCL=ON \
283+
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
284+
cmake --build "${BUILD_DIR}" --parallel "${CMAKE_BUILD_PARALLEL_LEVEL}" -- --quiet
285+
286+
- name: Show sccache stats (OpenVINO)
287+
run: ${SCCACHE_PATH} --show-stats
288+
289+
- name: Upload sccache log
290+
if: always()
291+
uses: ababushk/upload-artifact@ebc7d74ace101c08868aed05dba2aaf274b9a2c7 # main
292+
with:
293+
name: sccache_log
294+
path: ${{ env.SCCACHE_ERROR_LOG }}
295+
if-no-files-found: 'ignore'
296+
297+
- name: CMake install - OpenVINO
298+
run: |
299+
cmake --install "${BUILD_DIR}" --prefix "${INSTALL_DIR}"
300+
cmake --install "${BUILD_DIR}" --prefix "${INSTALL_TEST_DIR}" --component tests
301+
302+
- name: Pack openvino_package and openvino_tests
303+
run: |
304+
tar -I pigz -cf "${BUILD_DIR}/openvino_package.tar.gz" -C "${INSTALL_DIR}" .
305+
tar -I pigz -cf "${BUILD_DIR}/openvino_tests.tar.gz" -C "${INSTALL_TEST_DIR}" .
306+
307+
- name: Upload openvino package
308+
uses: ababushk/upload-artifact@ebc7d74ace101c08868aed05dba2aaf274b9a2c7 # main
309+
with:
310+
name: openvino_package
311+
path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz
312+
if-no-files-found: 'error'
313+
314+
- name: Upload openvino tests
315+
uses: ababushk/upload-artifact@ebc7d74ace101c08868aed05dba2aaf274b9a2c7 # main
316+
with:
317+
name: openvino_tests
318+
path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz
319+
if-no-files-found: 'error'
320+
321+
Test:
322+
name: Arc BMG dGPU MLIR Tests
323+
needs: [ Build, Docker ]
324+
uses: ./.github/workflows/job_gpu_tests.yml
325+
with:
326+
device: 'dgpu'
327+
test_type: 'func'
328+
runner: "[ 'self-hosted', 'dgpu', 'BMG-precommit', 'Linux' ]"
329+
runner-group: 'Intel-GPU'
330+
image: ${{ fromJSON(needs.docker.outputs.images).ov_test.ubuntu_24_04_x64_dgpu }}
331+
options: "--group-add 44 --group-add 993 --device /dev/dri/renderD129:/dev/dri/renderD129 -e OV_GPU_ENABLE_MLIR=1"
332+
test_filter: 'mlir_*'
333+
334+
Overall_Status:
335+
name: ci/gha_overall_status_dev_gpu_linux_mlir
336+
needs: [ Smart_CI, Docker, Build, Test ]
337+
if: ${{ always() }}
338+
runs-on: ubuntu-latest
339+
steps:
340+
- name: Check status of all jobs
341+
if: >-
342+
${{
343+
contains(needs.*.result, 'failure') ||
344+
contains(needs.*.result, 'cancelled')
345+
}}
346+
run: exit 1

0 commit comments

Comments
 (0)