Repository navigation
fix: gate kv_inplace_write GPU copy on a GPU backend build - #2113
Merged
Merged
Conversation
2 of 3 tasks
A Linux build with no cuda, metal or rocm feature failed to link: InplaceSliceWrite::eval_gpu in kv_inplace_write.cpp calls mlx::core::copy_gpu_inplace, which MLX defines only when it builds a GPU backend. No CI job links that configuration. build.rs now defines MLXCEL_BRIDGE_GPU_BACKEND when the resolved Metal backend, the cuda feature or the rocm feature holds (gpu_backend_enabled in build_support, with unit tests). The copy.h include and the eval_gpu body sit behind it; without it eval_gpu throws like eval_cpu. Every Rust caller already requires a GPU default device, so the throw is unreachable. GPU builds compile the same source as before. docs/installation.md documents the CPU-only link check command and its measured cost. Refs #2108
inureyes
force-pushed
the
fix/issue-2108-cpu-link-kv-inplace
branch
from
October 5, 2026 11:29
1d32937 to
925881a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kv_inplace_write.cppis compiled for every backend, but itseval_gpucallsmlx::core::copy_gpu_inplace, which MLX only defines when it builds a GPU backend, so a Linux build with no GPU feature failed to link.build.rsnow definesMLXCEL_BRIDGE_GPU_BACKENDwhen the resolved Metal backend, thecudafeature or therocmfeature holds (gpu_backend_enabledinbuild_support/metal_backend.rs, with unit tests). Thecopy.hinclude and theeval_gpubody sit behind it; without iteval_gputhrows likeeval_cpu. That throw is unreachable: every Rust caller andinplace_slice_writeitself already require a GPU default device. The existing Metal and ROCm defines were not reused because the condition is their union and CUDA had none. macOS withMLXCEL_BUILD_METAL=OFFhad the same failure and is covered by one of the new tests.Validation (GB10)
target/cpu:cargo test -p mlxcel-core --profile test-fast --lib --no-runlinks (2m24s cold, run beside a sibling CUDA build; 6s warm). Restoring main's.cppreproduces the failure: twoundefined reference to copy_gpu_inplace, nothing else.cargo build --releaselinks (9m48s cold).inplace(4) and build-policy (7) tests pass.cargo build --release --features cuda --bin mlxcel-serverbuilds. Under gpu-lock with--test-threads=1, mlxcel-core lib filtersinplace(4),cache::(541) andmetal_backend_build_policy(7) pass; the full lib suite was not run. The CUDAkv_inplace_write.ostill referencescopy_gpu_inplaceand lacks the CPU-only error string; the CPU-only object is the reverse.cargo clippy --release --features cuda --lib --tests -- -D warningsandcargo fmt --checkare clean.CI
ci.ymlis untouched because #2111 edits it in the same run. Recommended for #2111: a GB10 step with its own persistent target dir (pattern atci.yml:657-661) runningcargo test -p mlxcel-core --profile test-fast --lib --no-run, about 2.5 min cold and 6s warm. Until then the command is indocs/installation.md("CPU-only link check").Closes #2108