engine-cuda: native CUDA mining engine behind MinerEngine #16
Reference in New Issue
Block a user
Delete Branch "cuda/engine-skeleton"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements #3 steps 1 through 3 in one go: crate, straight port of the kernel, and the
__umul64hifield multiply. Nothing inengine-gpuis touched.What changed
crates/engine-cuda(lair-owned):CudaEnginebehindMinerEngine, same batch loop, cancellation, thread-local device assignment, metrics (kernel labelcuda) and stale accounting as the wgpu engine.cudarc0.19 with dynamic loading, so there is no link-time CUDA dependency and the binary runs on hosts without a driver (it just falls back).kernels/mining.cu: same host contract and sponge schedule asmining_u64.wgsl(host midstate, low-256-bit nonce increments, lazy second squeeze), bit-exact withpow_core. The field multiply is__umul64hiplus a plain multiply and one reduction instead of four 32-bit partials with carry reconstruction.build.rs: generatesposeidon2_constants.cuhfromqp-poseidon-constants(the rule from #1: a hash change at origin is a dependency bump, never a hand-copied table) and compiles one fat binary with cubins forsm_86,sm_89,sm_120pluscompute_120PTX when nvcc is present. Without nvcc (therustlint runner, workstations) it writes an empty image and warns; the crate still builds andtry_newfails with a clear message.miner-service:resolve_gpu_configurationtries CUDA first unless--gpu-engine wgpu;--gpu-engine cudamakes its absence an error.miner-cligains the flag (MINER_GPU_ENGINE) onserveandbenchmark. Worker exit clears CUDA resources too.bench-harness:--engine auto|cuda|wgpu.deploy.yaml: matrix rows carry the kernel validate expects onminer_device_hashes_total; a silent wgpu fallback on a CUDA host now fails the deploy.Measured
quadbrat, RTX 3060 at 130 W, miner paused, 2 x 10 s windows:
1.59x from the straight port. Grid sizing sweep (
MINER_CUDA_THREADS_PER_SM): 8192 and above are flat at 59.4; 2048 loses 10 percent. The bench workflow on this PR runs--engine auto, so its comment below is the 4090 number against the 144.4 MH/s wgpu baseline.clippy
-D warnings, fmt and workspace tests clean (with the empty-kernel build here; the kernel built and passed parity on quadbrat).What merging does
The deploy builds on
cuda-13.0, where nvcc is present, so the fat binary is embedded and both hosts switch to the CUDA engine on this merge; validate assertskernel="cuda"on device 0.Not yet:
__constant__/unroll tuning and pipelined submission (steps 5 and 6 of #3),sccache.🤖 Generated with Claude Code
https://claude.ai/code/session_01CBgs2nSi4H2mdh8kD8vMX5
quantus-bench
6ecc5ee6c7on benjy.hanzalova.internaltotal median: 297.70 MH/s (batch 1000000, 5 x 30s, engine gpu-cuda)
--- resume miner ---
active