1. Problem Statement: The Short-Prefix Regime
Parallel Monte Carlo simulations, procedural lookups, and hash-indexed stochastic kernels
frequently require random streams addressed by a 2D coordinate (key, addr_hi)
where each trajectory consumes only a small prefix of K 32-bit words
(1 ≤ K << 255) before terminating via importance sampling, russian-roulette
absorption, or boundary exit.
Conventional array-buffered generators pay an upfront O(N) block initialization cost
(e.g., 256 words) regardless of whether the caller consumes 1 word or 255 words. Counter-based
generators such as Philox4x32-10 avoid large state initialization, but evaluate
10 rounds of 32-bit multiplication and XOR-shift per 128-bit counter block (~10.6–11.0 cycles/byte
at K=1 on scalar x86-64 hardware).
ra_core v2 addresses this trade-off through deferred prefix computation
over a two-array 256-entry state (M[256] and L[256], 2 KiB L1-resident):
initialization work scales strictly with the number of consumed words K up to the
block boundary N - 1 = 255.
2. Architecture of ra_core v2
Promoted on 2026-11-04 as the canonical production configuration
(Opsi_A3 + W2_D2_xag_opt + eng_v2_E2), ra_core v2 combines three
mechanisms:
-
2D Cross-Pre-Mix (
Opsi_A3): Maps 64-bit(key, addr_hi)coordinates through a coupled modular-addition and rotated-XOR pre-mix followed by twofmix32avalanches, enforcing odd strides (| 1u) and a+1index offset(i + 1) * step. This eliminates the zero fixed-point (M[0]=L[0]=0) and sequentialaddr_hicorrelation defects found in earlier v1 prototypes. -
2-Tap Causal Ramp-Up & Lag-2 Delayed Feedback (
W2_D2_xag_opt): AtK=1, evaluation touches only 2 state words (M[255]andM[1]); atK=2, 3 words. For longer prefixes, lag-2 delayed feedback exposes 2-step instruction-level parallelism (ILP) with in-place state couplingM[i+7] += L[d_use]and anO(1)7-word guard fold at cycle boundaries. -
Stateful On-The-Fly Engine (
eng_v2_E2): Inra_core_engine_t(3,520 bytes), drawsK=1,2execute purely in registers, drawsK=3..254advance in 2-step coupled pairs over an 8-word ring buffer (m_ring[8]), and fullM, Larray materialization is deferred until a stream crossesK ≥ 256.
3. Materialized-Buffer Throughput & Shootout Benchmarks
All throughput figures below write every generated word into an external materialized memory buffer followed by an optimization barrier and consumer checksum verification, preventing dead-code elimination (DCE). Measurements report the median of 7 (Stage 4) or 9 (Stage 6) pinned runs across two reference machines:
- Machine A: Intel Core i3-1115G4 (Arch Linux, GCC 16.2.1
-O3 -march=native,taskset -c 0) - Machine B: Intel Xeon KVM fixed
1.995 GHz(Debian 13, GCC 14.2.0,taskset -c 3, CoV 1.0%–4.8%)
3.1 Production API Throughput Across Prefix Lengths (MiB/s)
| API Mode | K=1 (A / B) | K=8 (A / B) | K=64 (A / B) | K=255 (A / B) |
|---|---|---|---|---|
Direct Stateless (ra_core_default_into) |
710.2 / 425.84 | 1,292.1 / 841.42 | 1,476.4 / 948.01 | 1,596.5 / 926.70 |
Stateful OTF Engine (eng_v2_E2) |
570.2 / 352.36 | 934.0 / 524.46 | 1,059.1 / 567.00 | 1,103.3 / 583.21 |
8-Way AVX2 SIMD (ra_core_singleblock_x8_into) |
1,329.2 / 883.12 | 5,648.4 / 3,714.07 | 9,851.4 / 5,944.28 | 10,687.9 / 6,180.36 |
3.2 Cross-Generator Shootout (Stage 6 Suite D, Median-of-9, 110/110 Bit-Exact A=B)
| Generator | Category | K=1 MiB/s (A / B) | K=1 cpb (B) | K=255 MiB/s (A / B) | K=255 cpb (B) |
|---|---|---|---|---|---|
ra_core_v2 Direct |
2D Addressable Array | 716.65 / 461.09 | 4.12 | 1,435.75 / 917.39 | 2.07 |
ra_engine_v2 (eng_v2_E2) |
2D Addressable Stateful | 573.94 / 331.80 | 5.73 | 1,139.99 / 663.49 | 2.87 |
Philox4x32-10 |
2D Counter-Based | 270.44 / 173.15 | 10.99 | 1,074.15 / 766.49 | 2.48 |
ChaCha8 (RFC 8439 KAT) |
2D Stream Cipher | 99.99 / 50.57 | 37.63 | 1,013.87 / 643.50 | 2.96 |
PCG32 |
1D Sequential Register | 2,543.90 / 1,225.99 | 1.55 | 3,212.91 / 2,462.81 | 0.77 |
xoshiro256** |
1D Sequential Register | 646.81 / 431.74 | 4.41 | 3,560.00 / 2,455.20 | 0.78 |
WyRand |
1D Sequential Register | 2,681.20 / 1,426.94 | 1.33 | 4,592.86 / 2,721.27 | 0.70 |
Against its direct structural peer in 2D addressable generation (Philox4x32-10),
ra_core_v2 Direct is 2.65× (A) / 2.66× (B) faster at K=1
and 1.34× (A) / 1.20× (B) faster at K=255 on scalar CPU execution
(and 7.17× (A) / 9.12× (B) faster than scalar ChaCha8 at K=1).
3.3 End-to-End Monte Carlo Workloads (Median-of-9, Bit-Exact A=B)
-
2D Lattice Bernoulli Sweep (
K=1, 2.10M draws): 15.351 ms (A) / 22.436 ms (B) — 1.342× (A) / 1.304× (B) speedup over Philox. -
2D Ising Metropolis at Critical Temperature (
T_c,256×256, 32 sweeps,K=1): 19.106 ms (A) / 29.501 ms (B) — 1.250× (A) / 1.276× (B) speedup over Philox, while matching expected critical magnetization (and flagging a low-bit correlation anomaly inWyRandat⟨|M|⟩ = 0.2888). -
E2-Slab Photon Transport (250k photons,
P_rej = 0.90, 731,124 draws):eng_v2_E2completes in 5.282 ms (A) / 7.064 ms (B) — 1.528× (A) / 1.242× (B) speedup over Philox (reaching 1.640× / 1.535× atP_rej = 0.98).
4. Statistical Verification & Cross-Architecture Parity
-
PractRand v0.94 (57 / 57 non-repeating regimes PASS, 0 FAIL, 0 SUSP):
Canonical continuous orbit passed through 8 GiB CLEAN; sequential
addr_hi(at fixedkey=0), sequentialkey, Gray-code stepping, and 2D bit-plane interleaving passed through 2 GiB CLEAN; downscaledN=16structural torture tests passed 15/15 (4 GiB CLEAN atK=14). -
Dieharder 3.31.1 (
-a -g 200): 113 PASS / 1 WEAK / 0 FAIL (27/27 test families Good) across both continuous orbit (continuous_key42) andK=1Weyl-stepped addressing (k1_weyl). -
Avalanche & Bit Independence:
2D Strict Avalanche Criterion (SAC,
64×32, 100k pairs) yields mean flip probabilityp̄ = 0.499959(χ²/dof = 1.1070) atK=1. Bit Independence Criterion (BIC,32×32) bounds maximum pairwise correlation atmax |ρ| ≤ 0.00477(mean0.00098–0.00103). -
Bit-Exact Parity:
2,720,934 reference words verified with 0 mismatches across scalar Direct,
Stateful OTF (
eng_v2_E2), 8-way AVX2 SIMD, x86-64 machines A & B, and CUDA (Blackwellsm_120). Test suite: 39/39 C validation keys and 53/53pytestchecks passing.
5. Explicit Operating Boundaries & Retracted Legacy Claims
Engineering claims for ra_core v2 are strictly bounded by four negative results
and methodological corrections documented in
docs/ERRATA.md:
-
Non-Cryptographic:
ra_core v2is designed for simulation and stochastic modeling. It must not be used as a CSPRNG. -
1D Sequential Streams:
When 2D
(key, addr_hi)addressability is not needed, small-state 1D register generators (PCG32,xoshiro256**,WyRand) achieve 0.70–0.78 cpb atK=255on Machine B and remain ~2.2×–3.2× faster thanra_core_v2. -
GPU Execution vs. Philox:
On NVIDIA Blackwell (
sm_120, RTX PRO 6000),ra_core v2matchesPhilox4x32-10atK=1and 2D Ising (1.001×–1.010×) due to L1 shared-array overhead, and trails Philox atK=4(0.777×) andK=8(0.833×). Its primary advantage is on scalar and AVX2 CPU targets. -
Retraction of Early Pre-v2 Throughput Numbers:
Two legacy numbers from September–October 2026 drafts (
30,303.0 MB/salgebraic extrapolation from sub-nanosecond loops and20,018.1 MB/swhere passingraw_stream == NULLtriggered compiler DCE) were formally retracted on 2026-11-02 and replaced by the materialized-buffer harness reported above.