FrankenMining

Numerics posture and determinism

1,423 words8 subsections4 tablesPlan version 0.1

On this page8
29.1 Why determinism is a product feature here29.2 Determinism classes29.3 The hazards, and the rule for each29.4 Arrays and adapters29.5 Randomness29.6 Numerical certificates: a number never claims more than its certificate29.7 Determinism lanes, golden hashes and performance29.8 Galaxy-brain card

29.1 Why determinism is a product feature here

GOAL-024 promises that an auditor can replay a disclosed number offline and get the same certificate digest. That promise is cheap for integer and exact computations, expensive for floating-point ones, and false for some of them unless designed in. This section says which outputs carry which promise.

29.2 Determinism classes

Every certificate (FMT-CERT-1) records its class. A consumer may not claim more than the class allows.

Class Meaning How achieved Required for
Exact Bit-identical everywhere, by construction Integers, ExactQty, rationals, content hashes Ledger, money, posting summaries, conservation checks, Merkle folding
BitwisePortable Bit-identical across x86_64-linux and aarch64-darwin fmine-core::det transcendentals (lifted), fixed-chunk reductions in a fixed order, keyed Philox streams, no HashMap iteration in outputs, canonical NaN/−0.0 Disclosure-grade outputs: published realization sets, statement numbers, reconciliation certificates, public-lane metrics
DeterministicPerIsa Bit-identical on the same ISA and OS, single-threaded or with deterministic partitioning Platform libm allowed; same build Planning and optimization (verified by certificate gaps, not bits), engineering cards
ThreadVariant Results may depend on thread count Consumed kernels with unverified parallel reductions Interactive exploration only. Never certified.

29.3 The hazards, and the rule for each

Hazard Fact Rule
Transcendentals f64::exp, ln, sin and powf call the platform libm (glibc vs Apple libm), so samplers, CDFs and back-transforms differ across ISAs (R8 §7.3) BitwisePortable code calls fmine-core::det only. xtask check-det flags std transcendentals in modules tagged BitwisePortable.
FMA rustc never contracts a*b + c without an explicit mul_add, and f64::mul_add is correctly rounded everywhere Not a hazard by itself. Explicit mul_add is allowed.
SIMD lane width Hand-chunked SIMD sums can change with target features (fp's fp-dot-kernel builds with +avx2,+fma) OPEN per kernel. Consumed kernels used in BitwisePortable paths need a cross-ISA golden test, or are replaced.
Parallel reductions rayon in fnp-linalg GEMM and fsci-sparse; fp's per-call thread fan-out Thread-count dependence is OPEN per kernel (OPEN-SUITE-5). FrankenMining's own reductions use fixed chunks combined in a fixed tree order.
Summation order Floating-point addition is not associative Pairwise sums over fixed chunks. Where exactness matters (balances), sum in ExactQty or with lifted error-free transformations.
Hash-map order Iteration order varies between runs HashMap never feeds an output. Use BTreeMap or sort explicitly (PO-BED-9).
Discrete branch points Accept/reject tests, neighbour-search ties and threshold tests turn tiny differences into different paths (GB-37) Ties are broken by key, never by float order. Stochastic engines whose outputs are disclosed run BitwisePortable, or their outputs are stored rather than regenerated (§13.5).

29.4 Arrays and adapters

There are about nine array representations across the consumed repos (R8 §7.1): fsym Matrix, fnp UFuncArray, fp ColumnData, fsci-linalg &[Vec<f64>], fsci-sparse CsrMatrix, fsci-ndimage NdArray, fsci-spatial input slices, fsci-arrayapi CoreArray, and fj TensorValue.

  • fmine-array is the canonical representation: contiguous Arc<[T]> plus dims and strides, row-major.

  • FMT-COL-1 columnar interval chunks (DESIGN). fp-io is not consumed (arrow and parquet are banned, L-5; §28.5), yet GATE-STORE-01 and GATE-CORE-01 rebuild and composite 10⁵ holes and 10⁷–2×10⁷ intervals in ≤ 15 min. fmine-array therefore defines FMT-COL-1, an S0, std-only chunk format stored in CAS (the CELL-DRILL projection cache and CELL-TEL segments):

    • run-length HoleId (u32 run ends plus a dictionary);
    • delta-varint or packed i32 millimetre depths (from_mm, to_mm);
    • bit-packed MeasurandId and QualifierBits (<DL, >UL, CommittedFlagged) with a validity bitmap;
    • 64-byte-aligned f64 buffers for value, dry density and error variance (alignment through #[repr(align(64))], no unsafe), and per-chunk zone maps of depth range and 3D bounding box.

    TARGET: the sweep-line overlap join and length-weighted compositing stream 10⁷ intervals in < 3 s on one core with no per-interval allocation. Chunks convert to fp-columnar and fsci slices without copying where layouts match.

  • fmine-numerics::bridge provides zero-copy views into flat &[f64] consumers (fnp-linalg, fsci-sparse, fp) and copying adapters for everything else.

  • An adapter declares whether it copies. Copying adapters on hot paths are tracked as upstream asks (flat-slice overloads in fsci, Appendix F).

29.5 Randomness

  • One generator: keyed Philox in fmine-core::rand (ADR-RNG-01, §27.3). The key schema is (seed_root, partition, domain, var_group, r, brick). Any block of any realization can be regenerated independently, which is what makes "regenerate, don't store" possible (§13.5).
  • Integer streams are bitwise portable. Distribution transforms (normal, gamma, beta) use det transcendentals in BitwisePortable code.
  • Every engine receives its seed as an input, and the seed is recorded in the certificate. No engine reads entropy (E layer has no TIME or IO, §28.2).
  • The realization index is shared across engines (§9.5), so the same r means the same world in geology, planning and economics.

29.6 Numerical certificates: a number never claims more than its certificate

Computation Certificate fields Refusal or downgrade when it fails
Linear solves (kriging, GMRF, reconciliation) Relative residual ‖Ax − b‖/‖b‖, condition estimate, ordering Residual > tolerance → the Claim is refused (FMINE-REF-2xx) or recomputed with a fallback solver
LP/MILP (§15) Primal and dual objectives, gap, feasibility violations The three-gap ledger (§15.2); unknown gap → labelled as such
Volumes and proportions Interval enclosures (volcert) Band too wide → colour Estimated
MCMC and SMC R-hat ≤ 1.01, bulk and tail ESS ≥ 400, divergences, SBC rank checks on synthetic truth Fails → Uncalibrated, never published as a posterior
Quadrature (gamma-bar) Rule order, error estimate against fsym-derived goldens Error above tolerance → finer rule
Root finding (IRR, cut-offs) Bracket, iterations, residual No bracket → refusal with the reason (e.g. multiple IRRs)

29.7 Determinism lanes, golden hashes and performance

  • CI runs determinism lanes on x86_64-linux and aarch64-darwin:
    • BitwisePortable fixtures must produce identical digests on both;
    • DeterministicPerIsa fixtures must reproduce per ISA, and are compared across ISAs by certificate tolerance;
    • debug and release builds must agree.
  • Digest drift blocks release (PO-BED-9).
  • Performance is profile-driven. There is no GPU path in v1, because frankenjax's GPU backend is a stub and has no WASM target. Scale targets (10⁸ blocks, 100+ realizations) are met by regeneration and bricking (§13.5), not by accelerators.
PO / Gate Statement Verification
PO-NUM-1 BitwisePortable fixtures give identical digests across both reference ISAs Determinism lanes
PO-NUM-2 No std transcendental appears in a module tagged BitwisePortable xtask check-det
PO-NUM-3 Every consumed kernel used in a certified path has a recorded determinism class and a thread-count test Kernel registry registries/kernels.toml
GATE-DET-01 100% of disclosure-grade fixture families BitwisePortable, verified on both ISAs M1, then every release

29.8 Galaxy-brain card

GB-37 · One ulp is harmless to a decision and fatal to a digest, and a few engines turn it into a different world.

  • Equation.
    • A perturbation δ₀ ≈ 2⁻⁵² ≈ 2.2·10⁻¹⁶ (one libm ulp) grows per iteration by a factor g.
    • It reaches a size δ* that flips discrete choices with appreciable probability after k = ln(δ*/δ₀)/ln g iterations.
  • Substituted.
    • In a non-contractive sampler regime (a multimodal posterior over a HypothesisSet), take g = 1.01 and δ* = 10⁻³ relative. Then k = ln(10¹³)/ln(1.01) ≈ 3,000 iterations. Inside a 10⁴-iteration run, the two replays become different samples of the same distribution.
    • In a contractive regime (strongly log-concave, where synchronous coupling of HMC contracts), g < 1 and the replays converge.
    • For a single cut-off decision on 10⁸ blocks with smooth grades, a 1-ulp perturbation flips an expected ~10⁸ × 10⁻¹⁵ ≈ 10⁻⁷ blocks: negligible.
  • Intuition.
    • Decisions are robust to ulps. Digests are not.
    • Engines with discrete branch points and non-contractive dynamics turn ulps into different realization sets, which would make an auditor's replay statistically equivalent but not verifiably identical.
  • Decision.
    • Disclosure-grade stochastic outputs run BitwisePortable, or are stored as objects and never regenerated.
    • Everything else is verified by certificate tolerance and statistical equivalence.
  • Assumptions. g = 1.01 is illustrative. The real growth rate is measured per engine on synthetic truth.
  • Flip. If det transcendentals cost more than ~2× the platform libm in profiling, store disclosed realization sets instead (§13.5 GB-10 trade-off).