[CI] Emit a kernel symbol map from the csrc build (opt-in, for test selection) (#58097)
Signed-off-by: khluu <khluu000@gmail.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
f92b78f6ef
commit
64a48b19b4
@@ -79,6 +79,54 @@ setup_buildx_builder() {
|
||||
docker buildx ls | grep -E '^\*|^NAME' || docker buildx ls
|
||||
}
|
||||
|
||||
download_ci_hcl() {
|
||||
# Returns non-zero instead of exiting: the optional export path must be
|
||||
# able to give up without failing a build whose image already exists.
|
||||
echo "--- :arrow_down: Downloading ci.hcl"
|
||||
curl -sSfL -o "${CI_HCL_PATH}" "${CI_HCL_URL}" || return $?
|
||||
echo "Downloaded to ${CI_HCL_PATH}"
|
||||
|
||||
if [[ ! -f "${CI_HCL_PATH}" ]]; then
|
||||
echo "Error: ci.hcl not found at ${CI_HCL_PATH}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
export_kernel_symbol_map_from_cache() {
|
||||
# The existing-image path: everything here is best effort. Called as
|
||||
# `... || echo`, so errexit is suspended inside and any failure just
|
||||
# returns; the build keeps the image it already has.
|
||||
local rc=0
|
||||
download_ci_hcl \
|
||||
&& setup_buildx_builder \
|
||||
&& resolve_parent_commit \
|
||||
&& export PARENT_COMMIT \
|
||||
&& BUILD_TMP_DIR="$(mktemp -d)" \
|
||||
&& export_kernel_symbol_map || rc=$?
|
||||
rm -rf -- "${BUILD_TMP_DIR:-}"
|
||||
return "${rc}"
|
||||
}
|
||||
|
||||
export_kernel_symbol_map() {
|
||||
# Only when the build asked for it (nightly/post-merge). The map was
|
||||
# produced inside the csrc-build stage during the main bake; this second
|
||||
# bake of the scratch stage is a cache hit that just writes the file out.
|
||||
if [[ "${VLLM_KERNEL_SYMBOL_MAP:-0}" != "1" ]]; then
|
||||
return 0
|
||||
fi
|
||||
echo "--- :world_map: Exporting kernel symbol map"
|
||||
local out_dir="${BUILD_TMP_DIR}/kernel-symbol-map"
|
||||
mkdir -p "${out_dir}"
|
||||
if docker buildx bake -f "${VLLM_BAKE_FILE_PATH}" -f "${CI_HCL_PATH}" --progress plain \
|
||||
--set "kernel-symbol-map.output=type=local,dest=${out_dir}" kernel-symbol-map \
|
||||
&& [[ -s "${out_dir}/kernel_symbol_map.json.gz" ]]; then
|
||||
ls -la "${out_dir}"
|
||||
(cd "${out_dir}" && buildkite-agent artifact upload "kernel_symbol_map.json.gz")
|
||||
else
|
||||
echo "kernel symbol map export failed; continuing without it" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
annotate_image_tags() {
|
||||
.buildkite/scripts/annotate-image-build.sh \
|
||||
"${IMAGE_TAG:-}" "${IMAGE_TAG_LATEST:-}"
|
||||
@@ -90,6 +138,15 @@ check_and_skip_if_image_exists() {
|
||||
if docker manifest inspect "${IMAGE_TAG}" >/dev/null 2>&1; then
|
||||
echo "Image already exists: ${IMAGE_TAG}"
|
||||
echo "Skipping build"
|
||||
if [[ "${VLLM_KERNEL_SYMBOL_MAP:-0}" == "1" ]]; then
|
||||
# The image is reused, but the symbol map is an artifact of
|
||||
# this build. Bake just the export target: its layers come
|
||||
# from the registry cache, and the map step itself reruns
|
||||
# if the cached image was built without the arg. Never
|
||||
# fails the build: the image is already there.
|
||||
export_kernel_symbol_map_from_cache \
|
||||
|| echo "kernel symbol map: export from the cached image failed; continuing" >&2
|
||||
fi
|
||||
annotate_image_tags
|
||||
exit 0
|
||||
fi
|
||||
@@ -290,14 +347,7 @@ if [[ ! -f "${VLLM_BAKE_FILE_PATH}" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "--- :arrow_down: Downloading ci.hcl"
|
||||
curl -sSfL -o "${CI_HCL_PATH}" "${CI_HCL_URL}"
|
||||
echo "Downloaded to ${CI_HCL_PATH}"
|
||||
|
||||
if [[ ! -f "${CI_HCL_PATH}" ]]; then
|
||||
echo "Error: ci.hcl not found at ${CI_HCL_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
download_ci_hcl || exit 1
|
||||
|
||||
setup_buildx_builder
|
||||
|
||||
@@ -321,5 +371,6 @@ if [[ "${BUILD_STATUS}" -ne 0 ]]; then
|
||||
fi
|
||||
|
||||
echo "--- :white_check_mark: Build complete"
|
||||
export_kernel_symbol_map || true
|
||||
|
||||
annotate_image_tags
|
||||
|
||||
Reference in New Issue
Block a user