Files
zeekay d9d61ee66a v0.53 — PVM transition kernels (CUDA + Metal); CPU/Metal/CUDA determinism
Ship the GPU-native PlatformVM transition substrate. Four kernels in
canonical order produce byte-identical roots across CPU, Metal, and
CUDA backends:

  - pvm_validator_set_apply   Add/Remove/UpdateWeight/Jail/Unjail/RotateKeys
  - pvm_stake_transition      Bond/Unbond/Delegate/Redelegate/Reward/Commission
  - pvm_slashing_transition   Equivocation tombstones; downtime+vote jail
  - pvm_epoch_transition      Promotion + auto-unjail + 4-root composition

Per-kernel sources mirror byte-for-byte between .metal and .cu so the
keccak-folded roots agree across backends. Drivers:

  - pvm_gpu_engine.mm         Apple Metal: AOT metallib + PSO-per-kernel
  - pvm_gpu_engine_cuda.cpp   CUDA: <<<1,1>>> launchers + cudaMemcpy
  - pvm_engine_stub.cpp       CPU-only fallback (returns nullptr)

Tests:

  - pvm-gpu-engine-test       6/6 (Apple M1 Max) — Metal vs CPU byte match
                              for full round (100v / 1000s / 5ev), jailed
                              exclusion, redelegate atomicity, empty round
                              determinism, reward saturation
  - pvm-determinism-test      6/6 — CPU<->GPU byte-identical roots; two
                              engines bytewise identical across runs

Two real bugs found and fixed during bring-up:

  1. rotl64 invoked with n=0 (kKeccakRot[0] is 0) is undefined behavior:
     `x >> (64 - 0)` is a 64-wide shift on a 64-bit value. clang -O2 on
     Apple Silicon exploited the UB and produced garbage keccak output.
     Fix: mask shift counts (`(n & 63)`, `((64 - n) & 63)`). Applied
     identically in CPU, Metal, and CUDA so all backends agree.

  2. Metal PSO compile of pvm_stake_transition crashed Apple's optimizer
     pipeline (XPC_ERROR_CONNECTION_INTERRUPTED after retries). Repro:
     -Os/-O2 fails, -O0 always succeeds. The kernels are 1x1 single-thread
     dispatches; we lose nothing by skipping the optimizer. Build with
     `metal -O0`.

CMakeLists bumped to 0.53.0. Adds Metal AOT metallib build, CUDA target,
and the two new test executables. .metallib lookup now checks the
executable's directory first so the engine works from any CWD.

.gitignore added to keep build/ out of future commits.
2026-04-26 15:18:28 -07:00
..
2026-04-26 14:37:43 -07:00