Repository navigation
Add native CUDA mining engine (--cuda-gpu) - #94
Merged
Merged
Conversation
Rework the native CUDA kernel while keeping the golden-vector KV tests passing: - round constants and MDS diagonal in __constant__ memory - rolled round loops (#pragma unroll 1) to cut register spilling and raise occupancy - wide 96-bit accumulators with one Goldilocks reduction per layer - native __umul64hi multiply, inline-PTX add, folded round constants - volatile results poll instead of atomicAdd, __launch_bounds__(256, 4) ~68 -> ~140 MH/s on a rented RTX 3060 Ti (2.04x). Records the Clore bench progression and the Clore SSH/ControlMaster notes in docs/.
Same binaries, same 2.04x on an RTX 3080 (114 -> 233 MH/s), showing the optimization is architectural rather than chip-specific.
Optimize CUDA mining kernel ~2x
- reduce128: fold 2^64 = 2^32 - 1 and 2^96 = -1 in one 64-bit add/sub chain with a signed carry correction, replacing the 13-op 32-bit PTX sequence - mining_main takes one by-value MiningParams struct instead of four device buffers, dropping four host-to-device copies per batch - New engine-cuda tests: exact target boundaries on the golden vectors, CPU/GPU parity across nonce carries, 128-bit reduction vs u128 modulo - Add .agents/skills/cuda-benchmark with the same-host comparison script - Record the 2026-09-05 Clore RTX 3080 Ti run in docs/benchmarks and docs/clore-gpu-benches.md Validation: all five engine-cuda tests passed on a rented RTX 3080 Ti (driver 535.171.04, NVRTC 12.2.140) for this exact kernel. End-to-end +3.7-4.2% for the reduction alone; kernel-only 217 -> 233-236 MH/s with both changes. cargo fmt, taplo, clippy -D warnings clean.
illuzen
approved these changes
Sep 9, 2026
n13
commented
Sep 9, 2026
n13
left a comment
Contributor
Author
There was a problem hiding this comment.
Reviewer model: GPT 5.6 Sol
Verdict (advisory): Request changes
Blocking finding:
crates/engine-cuda/src/lib.rs:70-93,Cargo.toml:46-50— CUDA setup relies oncatch_unwindto turn cudarc's missing-library panics into errors, while release builds usepanic = "abort"andsilent_catchdisables the panic hook. On this exact head,cargo build --release --locked -p miner-clifollowed by./target/release/quantus-miner benchmark --cuda-gpu --gpu-devices 1 --cpu-workers 0 --duration 1on a host without NVRTC exited 134 and emitted zero bytes.docs/vast-gpu-benches.md:39-40records the same behavior. Thus a common driver-only CUDA host fails silently instead of reachingmain.rs:331-333's actionable error path. Preflight NVRTC and the CUDA driver through a non-panicking loader path (or otherwise avoid panic-based loading), then add a release-profile regression proving missing NVRTC/driver dependencies produce actionable stderr and a normal nonzero exit rather than aborting.
Validation:
git diff --check,cargo fmt --all -- --check, andtaplo format --check --config taplo.tomlpassed.cargo test --locked --workspacepassed; all five CUDA tests self-skipped on this non-CUDA host, while the committed benchmark notes record execution of those tests on an RTX 3080 Ti.cargo clippy --locked --workspace --all-targets --all-features -- -D warningsand the release build passed.- GitHub format, analysis/docs, build/test, and CPU benchmark jobs passed. The dependency-cooldown gate remains failed because
[email protected]was 28 days old versus the required 30, with no bypass label.
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.
Overview
Adds a native CUDA mining engine (
--cuda-gpu/MINER_CUDA_GPU) for NVIDIA boxes that have CUDA but no usable Vulkan stack (Clore.ai, most rental containers). The kernel was tuned in two measured rounds on rented GPUs, gated on the fixed nonce/hash vectors at every step.Measured on the same host, GPU-only, release miner: Vast RTX 3080 Ti WGSL 106 MH/s vs CUDA 274 MH/s (~2.6x). Clore RTX 3080 Ti (no Vulkan without manual driver injection) WGSL 51 MH/s vs CUDA 217-220 MH/s (~4.2x).
What changed
crates/engine-cuda(new): NVRTC-compiled Goldilocks/Poseidon2 mining kernel viacudarcwith dynamic driver loading; multi-device workers, midstate reuse, CPU-verified seals. Kernel round 1 (constant-memory round tables, rolled rounds,__launch_bounds__(256, 4), native__umul64hi) gave 2.04x on RTX 3060 Ti and RTX 3080. Round 2 rewrotereduce128as one 64-bit add/sub chain with a signed carry correction and passes kernel params by value (drops four H2D copies per batch), +3.7-4.2% end-to-end and ~8% kernel-only.crates/pow-core:mining_midstate_u32s,u512_to_le_u32s,hash_from_noncehelpers shared by the CUDA path and its tests.crates/miner-cli,crates/miner-service,crates/engine-gpu:--cuda-gpuflag wiring and engine selection.README.md: CUDA usage.docs/clore-gpu-benches.md,docs/vast-gpu-benches.md,docs/benchmarks/: per-host measurements, kept/rejected variants, raw JSON with clocks, power and binary hashes..agents/skills/cuda-benchmark: repo-local skill and same-host comparison script used for these runs.Validation
engine-cudatests on rented NVIDIA GPUs (RTX 3060 Ti, RTX 3080, RTX 3080 Ti): golden vectors, target boundarieshash-1/hash/hash+1, CPU/GPU parity across nonce carries, 128-bit reduction vsu128 % pon 4177 inputs. All pass for the shipped kernel.cargo fmt --check,taplo fmt --check,cargo clippy --workspace --all-targets -- -D warnings,cargo testclean on stable.Risks and mitigations
docs/.cudarcis loaded dynamically, so binaries still run on machines withoutlibcuda.Follow-ups