Skip to content

Rename candle's moe_gemm_wmma → candle_moe_gemm_wmma to avoid symbol collision with mistralrs-core#13

Merged
lukekim merged 1 commit into
spiceaifrom
lukim/rename-moe-gemm-wmma
Apr 17, 2026
Merged

Rename candle's moe_gemm_wmma → candle_moe_gemm_wmma to avoid symbol collision with mistralrs-core#13
lukekim merged 1 commit into
spiceaifrom
lukim/rename-moe-gemm-wmma

Conversation

@lukekim
Copy link
Copy Markdown

@lukekim lukekim commented Apr 17, 2026

Problem

Linking spiced with --features cuda,models fails with:

ld.lld: error: duplicate symbol: moe_gemm_wmma
  >>> defined in candle-kernels/out/libmoe.a (moe_wmma.cu)
  >>> defined in mistralrs-core/out/libmistralrscuda.a (moe_gemm_wmma.cu)

Both crates independently adapted the MoE WMMA kernel from guoqingbao/attention.rs and export it with the same extern "C" name. When both crates are linked into the same binary (Spice.ai runtime uses candle for embeddings/TEI and mistral.rs for LLM inference), ld.lld rejects the duplicate symbol.

Fix

Prefix the candle side of the symbol with candle_ so both kernels can coexist at link time:

  • candle-kernels/src/moe/moe_wmma.cu: extern "C" void moe_gemm_wmmaextern "C" void candle_moe_gemm_wmma
  • candle-kernels/src/ffi.rs: FFI declaration updated to match
  • candle-nn/src/moe.rs: call site updated to match

The mistralrs-core copy (which also has a moe_gemm_wmma_transposed variant unique to it) keeps its original name.

Scope

  • No semantic change to the kernel implementation
  • Only candle's own crates call candle-kernels::ffi::moe_gemm_wmma; no external callers affected
  • The human-readable error string in candle-nn/src/moe.rs and the upstream-URL comment in moe_wmma.cu intentionally preserve the original moe_gemm_wmma name (they refer to the upstream author's name, not our symbol).

Verification

Local build of spiced --features cuda,models on CUDA 12.6 / sm_90 (H100) links cleanly after this change is applied via workspace [patch]. Will re-verify with the merged SHA once this lands.

… collision with mistralrs-core

Both candle-kernels and mistralrs-core define an extern "C" void moe_gemm_wmma
kernel with the same signature but incompatible implementations. When both
crates are linked into the same binary (e.g. spiced with cuda + models
features), ld.lld rejects the duplicate symbol.

Prefix the candle side with 'candle_' so both can coexist; the mistralrs-core
copy keeps the original name and call sites.
@lukekim lukekim self-assigned this Apr 17, 2026
lukekim added a commit to spiceai/mistral.rs that referenced this pull request Apr 17, 2026
…ollision)

Picks up spiceai/candle#13 which renames candle-kernels' moe_gemm_wmma
-> candle_moe_gemm_wmma so it no longer collides with mistralrs-core's
identically-named but semantically divergent kernel when both crates
are linked together (e.g. in spiced --features cuda,models).
lukekim added a commit to spiceai/text-embeddings-inference that referenced this pull request Apr 17, 2026
Picks up spiceai/candle#13 which renames candle-kernels' moe_gemm_wmma
-> candle_moe_gemm_wmma so it no longer collides with mistralrs-core's
identically-named but semantically divergent kernel when both crates
are linked together (e.g. in spiced --features cuda,models).
@lukekim lukekim closed this Apr 17, 2026
@lukekim lukekim reopened this Apr 17, 2026
@lukekim lukekim merged commit 6ee27a4 into spiceai Apr 17, 2026
23 checks passed
lukekim added a commit to spiceai/spiceai that referenced this pull request Apr 17, 2026
Resolves ld.lld duplicate-symbol link error when building spiced with
cuda + models features:

    ld.lld: error: duplicate symbol: moe_gemm_wmma
      >>> defined in libmoe.a (candle-kernels)
      >>> defined in libmistralrscuda.a (mistralrs-core)

Three coordinated fork PRs:
 - spiceai/candle#13: rename moe_gemm_wmma -> candle_moe_gemm_wmma
   in candle-kernels so it no longer collides with mistralrs-core's
   identically-named but semantically divergent kernel.
 - spiceai/mistral.rs#34: bump candle rev to 7de0d9fd.
 - spiceai/text-embeddings-inference#22: bump candle rev to 7de0d9fd.

New workspace pins:
 - candle           fab4da81 -> 7de0d9fd
 - mistralrs        9b475876 -> b93f7600
 - text-embeddings  b958dca5 -> bd66a55d

Verified with make install-cuda on CUDA 12.6 / sm_90 (H100): links
and installs cleanly in 18m51s.
lukekim added a commit to spiceai/mistral.rs that referenced this pull request Apr 17, 2026
…ollision)

Picks up spiceai/candle#13 which renames candle-kernels' moe_gemm_wmma
-> candle_moe_gemm_wmma so it no longer collides with mistralrs-core's
identically-named but semantically divergent kernel when both crates
are linked together (e.g. in spiced --features cuda,models).
lukekim added a commit to spiceai/text-embeddings-inference that referenced this pull request Apr 17, 2026
Picks up spiceai/candle#13 which renames candle-kernels' moe_gemm_wmma
-> candle_moe_gemm_wmma so it no longer collides with mistralrs-core's
identically-named but semantically divergent kernel when both crates
are linked together (e.g. in spiced --features cuda,models).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant