Repository navigation
fix: CPU-only Linux build fails to link kv_inplace_write #2108
Description
Problem
src/lib/mlxcel-core/build.rs:143 compiles ../mlx-cpp/turbo/kv_inplace_write.cpp (#1959/#1961) for every backend. Its InplaceSliceWrite::eval_gpu (kv_inplace_write.cpp:43-65) calls mx::copy_gpu_inplace at line 55, which MLX defines only when a GPU backend is built. A Linux build with no cuda/metal/rocm feature therefore fails at link time, e.g. cargo test --release --lib. Found while validating #2093, which needed a linker wrapper with --unresolved-symbols=ignore-in-object-files. Not re-run for this issue (cold MLX build).
No CI job catches it: the ubuntu-latest jobs only lint, every GB10 job passes --features cuda, and ci.yml:1072 is cargo check, which does not link.
Proposed fix
- In
build.rs, next toMLXCEL_BRIDGE_METAL_BACKEND(~172) andMLXCEL_BRIDGE_ROCM_BACKEND(~181), defineMLXCEL_BRIDGE_GPU_BACKENDwhen the resolvedmetal_backendbool (not the cargo feature, see the comment at ~167-170) orCARGO_FEATURE_CUDAorCARGO_FEATURE_ROCMholds. - In
kv_inplace_write.cpp, guard the<mlx/backend/gpu/copy.h>include and theeval_gpubody on that define; without it,eval_gputhrowsstd::runtime_errorlikeeval_cpu(lines 38-41) does, keeping that explicit error. - Rejected: dropping the
.file()line.cpp/mlx_cxx_ext.cpp:12includes the header and the FFI symbol must still link; at runtimecache.rs:1043-1047already skips the call whendefault_device_is_gpu()is false. - CI: add a CPU-only
cargo test -p mlxcel-core --profile test-fast --lib --no-runstep on GB10 with its own persistent target dir (pattern atci.yml:657-661). If the warm runtime is too high, put the local command indocs/installation.mdinstead and say so in the PR.
Acceptance Criteria
- With no GPU feature on Linux,
cargo build --releaseandcargo test -p mlxcel-core --profile test-fast --lib --no-runlink (they fail on 33c4505). -
--features cudabuild and lib tests unchanged; Metal and ROCm builds compile (CI or a maintainer run). CUDA part done in PR fix: gate kv_inplace_write GPU copy on a GPU backend build #2113 (server build, mlxcel-coreinplace/cache::filters); Metal and ROCm still need a maintainer run. - The CPU link check is in CI, or documented with the reason it is not. Documented in
docs/installation.md; the CI step is deferred to fix: WebUI Activity gate collides with host GPU work and stale incremental cache #2111, which ownsci.ymlin this run.
Do it in one PR, run the checks once at the end, and push as few times as possible.
Verification
cargo test -p mlxcel-core --profile test-fast --lib --no-run
cargo test -p mlxcel-core --profile test-fast --features cuda --lib -- --test-threads=1
Activity
fix: gate kv_inplace_write GPU copy on a GPU backend build
docs: add technical report for issue #2108
fix: gate kv_inplace_write GPU copy on a GPU backend build (#2113)
fix(ci): wait for host gpu-lock in WebUI gate and link CPU-only build (…