Written by Claude Opus 5.5.
Problem #
All CUDA sources sit in the root kernels/: 26 files, prefixed per engine (dsv41_*, inkling_*, qwen36.cu, smollm3.cu), plus shared headers (firecrest_common.cuh, gguf_*.cuh, sample.cu). firecrest-kernels compiles every file into one image, whichever engines are enabled. As a result:
- A build with only one engine still compiles every engine's kernels.
- A kernel file that doesn't compile breaks every build.
- A kernel lives far from the Rust code that launches it, although AGENTS.md wants both sides changed in one commit.
Proposal #
- Each engine's kernels move into the engine, for example
engines/qwen3.6/gpu/kernels/. That crate's build script compiles them into its own image, using a build helper. firecrest-kernelsbecomes that helper and the home of shared code:- nvcc discovery and the
FIRECREST_CUDA_*options; - the registry codegen;
- the shared headers in
crates/firecrest-kernels/include/, passed with-I; - the generated launchers (#10), once they land.
- nvcc discovery and the
- Code used by several engines (
sample.cu, the GGUF matmul ingguf_gemm.cuh) stays infirecrest-kernels. Moving SmolLM3's matmul into a shared header in #5 is an example. firecrest-cudastays engine-agnostic (driver bindings only), so kernels don't go there.- Docs: AGENTS.md (layout, the "check a kernel file on its own" command),
docs/operations.md(build), and the crate READMEs.
Open question #
One image per engine changes how modules are loaded (Kernels::module(name) today looks names up in one registry). Is that fine, or should the per-engine images still be linked into one registry?