Skip to content

Commit 670d0bd

Browse files
authored
Build ggml GPU targets in compatible CI modes
Summary: CI's default Linux configurations satisfy none of the CUDA, HIP or Metal ggml backend constraints, so CI only ever skipped the engine variants and runners that link them, and the CUDA and HIP op tests never ran in CI. These targets now take CI labels from `ggml_ci_labels`, loaded next to the ggml dependencies, which builds them where they are compatible. The open-source shim returns no labels, and the CPU variants keep the default configuration. The GPU engine variants and the Metal runner build for the host platform only, since their backends have no mobile flavors. Authored with Claude assistance. Differential Revision: D127883010 Pull Request resolved: #24223
1 parent a6390b4 commit 670d0bd

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎backends/native/examples/hf_llm/runtime/BUCK‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target")
2+
load("@fbsource//third-party/llama.cpp:ggml_ci.bzl", "ggml_ci_labels")
3+
load("@fbsource//tools/build_defs:default_platform_defs.bzl", "CXX")
24
load("@fbsource//xplat/executorch/backends/native/runtime/engine:targets.bzl", "CPU_COMPAT", "CUDA_COMPAT", "HIP_COMPAT", "METAL_COMPAT")
35
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
46

@@ -80,6 +82,7 @@ fbcode_target(
8082
# ggml's VMM pool calls the driver API, which //third-party/cuda:libcuda does not link on fbcode.
8183
("cuda", None, "cuda_driver_api-lazy"),
8284
],
85+
labels = ggml_ci_labels("cuda"),
8386
visibility = ["PUBLIC"],
8487
**CUDA_COMPAT
8588
)
@@ -93,6 +96,7 @@ fbcode_target(
9396
"//executorch/backends/native/runtime/engine:ggml_engine_hip",
9497
],
9598
external_deps = ["gflags"],
99+
labels = ggml_ci_labels("hip"),
96100
visibility = ["PUBLIC"],
97101
**HIP_COMPAT
98102
)
@@ -108,6 +112,9 @@ non_fbcode_target(
108112
"//executorch/backends/native/runtime/engine:ggml_engine_metal",
109113
],
110114
external_deps = ["gflags"],
115+
labels = ggml_ci_labels("metal"),
116+
# ggml-metal has no mobile flavors.
117+
platforms = [CXX],
111118
visibility = ["PUBLIC"],
112119
**METAL_COMPAT
113120
)

‎backends/native/runtime/engine/targets.bzl‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@fbsource//third-party/llama.cpp:ggml_ci.bzl", "ggml_ci_labels")
2+
load("@fbsource//tools/build_defs:default_platform_defs.bzl", "CXX")
13
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime")
24

35
# Platform constraints of the ggml backend sets. Targets that link one repeat
@@ -81,6 +83,9 @@ def define_common_targets():
8183
"//executorch/backends/native/runtime/graph:value",
8284
ggml_dep,
8385
],
86+
labels = ggml_ci_labels(variant),
87+
# The GPU sets have no mobile flavors.
88+
platforms = None if variant == "cpu" else [CXX],
8489
visibility = ["//executorch/backends/native/..."],
8590
**compat
8691
)

‎backends/native/test/runtime/ggml/BUCK‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target")
2+
load("@fbsource//third-party/llama.cpp:ggml_ci.bzl", "ggml_ci_labels")
23
load("@fbsource//xplat/executorch/backends/native/runtime/engine:targets.bzl", "CPU_COMPAT", "CUDA_COMPAT", "HIP_COMPAT")
34
load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils")
45
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
@@ -22,13 +23,15 @@ fbcode_target(
2223
)
2324

2425
# The op suite runs once per ggml backend set; only the engine variant, the
25-
# runner's --device, link deps and resources, and the test host differ.
26+
# runner's --device, link deps and resources, the test host, and the CI
27+
# configuration differ.
2628
_VARIANTS = [
2729
{"suffix": "", "engine": "ggml_engine_cpu", "compat": CPU_COMPAT, "device": "cpu"},
2830
{
2931
"suffix": "_cuda",
3032
"engine": "ggml_engine_cuda",
3133
"compat": CUDA_COMPAT,
34+
"labels": ggml_ci_labels("cuda"),
3235
"device": "gpu",
3336
"remote_execution": re_test_utils.remote_execution(
3437
platform = "gpu-remote-execution",
@@ -47,6 +50,7 @@ _VARIANTS = [
4750
"suffix": "_hip",
4851
"engine": "ggml_engine_hip",
4952
"compat": HIP_COMPAT,
53+
"labels": ggml_ci_labels("hip"),
5054
"device": "gpu",
5155
"remote_execution": re_test_utils.remote_execution(
5256
platform = "amd-gpu",
@@ -66,6 +70,7 @@ _VARIANTS = [
6670
"//executorch/backends/native/test/runtime:ptn_runner_main",
6771
] + v.get("deps", []),
6872
external_deps = ["gflags"] + v.get("external_deps", []),
73+
labels = v.get("labels", []),
6974
**v.get("compat", {})
7075
)
7176
for v in _VARIANTS
@@ -77,6 +82,7 @@ _VARIANTS = [
7782
name = "test_ggml_ops" + v["suffix"],
7883
srcs = ["test_ggml_ops.py"],
7984
env = {"GGML_PTN_DEVICE": v["device"]},
85+
labels = v.get("labels", []),
8086
remote_execution = v.get("remote_execution"),
8187
resources = {":ggml_ptn_runner" + v["suffix"]: "ggml_ptn_runner"} |
8288
v.get("resources", {}),
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Open-source builds have no Meta CI configuration, so targets that link a ggml
2+
# GPU backend set get no CI labels.
3+
def ggml_ci_labels(_backend):
4+
return []

0 commit comments

Comments
 (0)