From 8e3d0e4d5c2a45359c9d56f34b44ab2a15d12228 Mon Sep 17 00:00:00 2001 From: yangjie01 Date: Fri, 28 Aug 2026 23:10:18 +0800 Subject: [PATCH] ci: run lance-linalg's release tests on the runner's own CPU --- .github/workflows/rust.yml | 43 ++++++++++++++++------- rust/lance-linalg/src/distance/dot_f16.rs | 2 +- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 00755179e36..406338f4135 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -265,16 +265,26 @@ jobs: run: cargo nextest run --cargo-profile ci qemu-pre-haswell: - # Verifies that lance-linalg's runtime SIMD dispatch still works - # correctly when the binary is built with the lower x86-64-v2 baseline - # (the legacy build path documented in CONTRIBUTING.md). Emulates a - # Nehalem CPU under qemu-user; catches any accidental AVX2/FMA - # instructions that leak past the runtime dispatch. + # Builds lance-linalg's lib tests once in release mode and runs them twice: on + # the runner's own CPU, and under qemu emulating a Nehalem. # - # The published-wheel default baseline (`target-cpu=haswell`) is set in - # `.cargo/config.toml`; this job overrides RUSTFLAGS for one job to - # exercise the legacy path without affecting any other build. - name: pre-Haswell SIGILL check (qemu Nehalem) + # Release mode, not the `ci` profile the other test jobs use: `ci` inherits + # `dev`, so the Rust there compiles at opt-level 0. + # + # The qemu run is the pre-Haswell check: it verifies that runtime SIMD + # dispatch still works when the binary is built with the lower x86-64-v2 + # baseline (the legacy build path documented in CONTRIBUTING.md), and catches + # any accidental AVX2/FMA instructions that leak past the dispatch. A Nehalem + # fails every feature gate, so that run takes the fallback arms; the native + # run is there to reach the SIMD arms a Nehalem cannot. + # + # `test_x86_runtime_feature_report` writes the features each run detected to + # stderr. Both runs use default features, so `fp16kernels` is off. + # + # The x86_64-linux baseline (`target-cpu=haswell`) comes from + # `.cargo/config.toml`; this job overrides RUSTFLAGS to exercise the legacy + # path, which affects only this job. + name: lance-linalg release tests (native + qemu Nehalem) runs-on: ubuntu-24.04 timeout-minutes: 60 env: @@ -299,6 +309,18 @@ jobs: uses: taiki-e/install-action@66068bfca13dcb2ea07c3f613ca2836a37c755d5 # protoc with: tool: protoc + # Ordered before the QEMU build so a failure there cannot skip the native + # run: a step runs only if the ones before it succeeded. + - name: Build lance-linalg lib tests in release mode + run: | + cargo test --release -p lance-linalg --lib --no-run + # `env` is a no-op runner: it overrides the job-level qemu runner for this + # step, so the binary built above runs on the runner's own CPU. + - name: Run lance-linalg lib tests on the runner's own CPU + env: + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: env + run: | + cargo test --release -p lance-linalg --lib - name: Install QEMU build dependencies if: steps.qemu-cache.outputs.cache-hit != 'true' run: | @@ -348,9 +370,6 @@ jobs: echo "Expected QEMU 8.2.10, got: ${QEMU_VERSION_OUTPUT}" >&2 exit 1 fi - - name: Build lance-linalg lib tests in release mode - run: | - cargo test --release -p lance-linalg --lib --no-run - name: Run lance-linalg lib tests under qemu Nehalem run: | cargo test --release -p lance-linalg --lib diff --git a/rust/lance-linalg/src/distance/dot_f16.rs b/rust/lance-linalg/src/distance/dot_f16.rs index 0fad2c27f88..4c3c6946458 100644 --- a/rust/lance-linalg/src/distance/dot_f16.rs +++ b/rust/lance-linalg/src/distance/dot_f16.rs @@ -758,7 +758,7 @@ mod tests { /// `-march=sapphirerapids`, so the compiler may use instructions from that /// baseline anywhere in the file — entering *any* function in it faults on /// an older CPU. Under `qemu -cpu Nehalem` that is a SIGILL, which is - /// exactly what the `pre-Haswell SIGILL check` in CI runs. + /// exactly what the `qemu-pre-haswell` CI job runs. #[cfg(all( kernel_support = "amx_fp16", target_arch = "x86_64",