parquet_expkey Module

The frozen -log(u) transform behind pf_weighted_permutation's exponential race.

A leaf module on purpose, and the reason is a tool rather than taste. tools/check_exp_key.sh proves the transform gives the same bits under every IEEE-conforming build, and it can only do that by compiling it standalone under several compilers and flag sets. parquet_random gained a dependency on parquet_sorting -- and so, transitively, on Arrow -- the moment the weighted permutation needed a sort, which put the transform out of that check's reach. Splitting it out costs one file and keeps the check dependency-free, which matters because that check is what found the FMA exposure to begin with.

Why this is not log() from the runtime. Everything parquet_random promises is a pure function of its coordinates, frozen by pf_random_algorithm, and every other generic delivers that with integer arithmetic alone -- Philox, the Lemire reduction and the Feistel permutation are all integer, so two machines agree bit for bit and the golden vectors say so. log breaks that property class, because libm is not part of any contract this project controls. Measured on machine B over two million deterministic inputs: 1.33% of -log(u) values differ between gfortran and ifx at their default flags, worst gap 126775 ulp; 0.083% still differ under -fp-model=precise; and ifx disagrees with ITSELF across flag settings, so this is not only a cross-vendor problem.

A weighted permutation is decided by the ORDER of e/w, so one differing key changes the answer only when it crosses its neighbour -- rare at n = 10**6, approaching certain by n = 10**9. That is a latent wrong answer with no symptom, which is the one failure mode this tier exists to rule out.

The approximation costs nothing distributionally. The race needs E ~ Exp(1) iid; a transform accurate to about two ulp perturbs each key by ~2e-16 relative, eleven orders of magnitude below the Monte Carlo standard error of any test that could detect it. Approximation error buys exact reproducibility, which is the trade this tier exists to make.

Depends on iso_fortran_env and nothing else. Keep it that way -- a dependency here is a dependency the cross-build check cannot carry.



Functions

public function ek_rnd(x) result(y)

The rounding barrier: an identity that the optimiser may not fuse across.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: x

the product to round

Return Value real(kind=real64)

the same value, rounded to real64

public function exp_key(u) result(e)

-log(u) for u in [2**-53, 1], using only IEEE + - * /. Not a general-purpose log.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: u

a uniform in [2**-53, 1]; nothing validates this

Return Value real(kind=real64)

-log(u), in [0, 36.74]

public function parquet_debug_exp_key(u) result(e)

exp_key under a public name. Test-only.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: u

a uniform in [2**-53, 1]

Return Value real(kind=real64)

-log(u)

public function exp_key_contract_ok()

Re-derives the frozen transform over 32 fixed inputs and compares against ek_contract_fp.

Read more…

Arguments

None

Return Value logical


Subroutines

public subroutine parquet_debug_set_exp_key_contract(ok)

Forces the frozen-transform check to fail. Test-only.

Read more…

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: ok

.false. makes the contract check report failure