Different kernels for Apple Metal vs Nvidia and everything else - #92
Conversation
NVIDIA was ~37% slower on the 4.0.1 Metal-tuned kernel. Split Poseidon2 kernels and pick by backend: - Metal + SHADER_INT64: v4.0.1 u64 - other SHADER_INT64: v4.0.0 u64 - no SHADER_INT64: 32-bit fallback (same as 4.0.0) CI uploads the Linux release binary as an artifact so we can bench NVIDIA without building on the GPU box.
Log native-u64 vs native-u64 Apple Metal without tying the strings to release tags.
n13
left a comment
There was a problem hiding this comment.
Reviewer model: GPT Sol
Verdict (advisory): Approve
No blocking findings.
The centralized selector correctly uses the Apple-tuned u64 kernel for Metal adapters with SHADER_INT64, the v4.0.0-era u64 kernel for other int64-capable backends, and the unchanged 32-bit kernel otherwise. The production engine, component runner, and trusted-hashrate example all reuse that selector. I also verified that the moved 32-bit shader is byte-identical to v4.0.0 and that both u64 kernels differ from their claimed source revisions only in header text.
Non-blocking: after 13abd969 removed version suffixes from the runtime labels, the PR description's two Kernel logged entries still quote the old versioned strings.
Validation on exact head 13abd9697dae25d47e8d5f91c195ae87c9298e1b:
git diff --check ceff470a...13abd969— passedtaplo format --check --config taplo.toml— passedcargo fmt --all -- --check— passedcargo clippy --locked -p engine-gpu --all-targets -- -D warnings— passedcargo test --locked -p engine-gpu— 23 passedcargo run --locked -p engine-gpuon Apple Metal — all component and CPU-verified end-to-end suites passed for the 32-bit, default u64, and Apple Metal u64 kernels- Current GitHub format, build/test, Clippy/doc, benchmark, and dependency-cooldown checks — passed
Overview
v4.0.1's Metal-tuned u64 kernel is ~1.8x faster on Apple and ~37% slower on NVIDIA (RTX 3080 Ti). This PR keeps 4.0.0 GPU coverage and uses the 4.0.1 kernel only on Apple Metal.
What changed (engine-gpu)
Poseidon2 kernels live in
crates/engine-gpu/src/kernels/and are selected by backend:SHADER_INT64→ v4.0.1 u64 (mining_u64_apple.wgsl)SHADER_INT64→ v4.0.0 u64 (mining_u64.wgsl)SHADER_INT64→ 32-bit fallback (mining.wgsl), same as 4.0.0CI uploads
quantus-miner-linux-x86_64from the benchmark job so NVIDIA boxes can run the PR binary without a local Rust toolchain.Validation
cargo fmt --all -- --checkcargo clippy -p engine-gpu --all-targets -- -D warningsLive GPU benches of this PR binary (10s,
--gpu-devices 1 --cpu-workers 0):native-u64 Apple Metal (4.0.1)native-u64 (4.0.0)Risks and mitigations
wgpu::Backend::Metalvs everything else, covered by unit tests and startup logs.Follow-ups
None for this PR. Ready to tag a release once merged.