WikifitaGitHub live67e8de5
outro · compute-optimization/crustybike

crustybike — Distributed Mining & Topological Analysis

Distributed Bitcoin mining system: topological solver on MLX, Cartesian Miner on OpenCL/Metal, QUIC workers, TDR recovery, zero-copy Merkle.

Baixar raw

crustybike — Distributed Mining & Topological Analysis

A distributed Bitcoin mining system focused on topological analysis of the "Patoshi" pattern in early Bitcoin blocks. Uses Apple MLX as a tensor math library (not for ML training) for geometric determinant computation, and PyOpenCL for GPU-accelerated SHA-256 mining.

Repository: /Users/alefita/workdir/crustybike/ Branch model: main (protected), feature branches per hypothesis Tags: v0.0.1, v0.0.2, v.0.0.3, v2.2350-h16


Architecture

LayerTechnologyPurpose
SolverMLX (mlx.core)Topological evaluation — geometric determinants on Metal GPU
MiningPyOpenCLCartesian Miner — Double SHA-256 + DAA distance
MerkleMLX + MetalZero-copy permutations via mx.take(), on-GPU tree construction
WorkersPython asyncioQUIC-based distributed mining
TTSmlx_audioAudio generation (side feature)

Compute Stack

  • MLX ≥ 0.31.1 (macOS) / MLX[cuda] (Linux x86_64) — Tensor math, zero-copy gather
  • PyOpenCL — GPU mining kernels
  • scikit-learn, umap-learn, pysr — Offline analysis (notebooks)
  • No PyTorch — Zero imports, zero references

Kernel Architecture

V1 (Legacy) — Scientific Validation

  • chronobreaker_combined.cl (1272 lines, 14 kernels)
  • cartesian_miner.cl (132 lines)

V2 (Production) — Lean Mining

  • cartesian_miner.cl (132 lines) — Mining kernel
  • topology_eval.cl (193 lines) — Swift skip via discriminant

Metal

  • cartesian_miner.metal (128 lines) — MLX Metal conventions
  • merkle_sha256.metal (130 lines) — On-GPU Merkle tree

Key Optimizations

PatternDescription
Zero-copy Merklemx.take() GPU-side gather, no host copy
Swift Skipb² - 4ac < 0 → skip dispatch entirely
TDR RecoveryFull OpenCL context rebuild after GPU timeout
Atomic CASatomic_cmpxchg for race-free nonce discovery
Tropa de Choque10 concurrent prefetch workers
Midstate cachingSHA-256 first chunk computed once

Related Pages

Status

  • ✅ Production mining via Cartesian Miner
  • ✅ Topological solver on MLX
  • ✅ Zero-copy Merkle permutations
  • ✅ TDR recovery
  • ✅ Metal kernels present
  • ⚠️ Metal kernels not explicitly loaded by Python
  • ⚠️ float32 exclusively
  • 🔜 Potential Metal→MLX native pipeline