FrankenNumPy

Docs/Guarantees and recipes

How to Investigate a Parity Issue

A practical runbook for "I think FrankenNumPy and NumPy disagree on something."

  1. Reproduce minimally. Reduce the input to the smallest array that still shows the divergence. Most parity issues survive on 4-element arrays.
  2. Run the operation under both with the same explicit RNG seed if any randomness is involved:
    let mut rng = fnp_random::Generator::from_pcg64_dxsm(42)?;
    let fnp_out = rng.<op>(...);
    
    rng = numpy.random.Generator(numpy.random.PCG64DXSM(42))
    np_out = rng.<op>(...)
    
  3. Capture the oracle via the conformance harness:
    FNP_REQUIRE_REAL_NUMPY_ORACLE=1 cargo run -p fnp-conformance --bin capture_numpy_oracle
    
    Add a fixture row to the relevant *_input_cases.json so the divergence is reproducible from a clean checkout.
  4. Run the differential gate for the relevant family:
    cargo run -p fnp-conformance --bin run_ufunc_differential   # for ufunc ops
    
    The output names the fixture, the expected value, and the observed value.
  5. Check the divergence ledger (docs/DIVERGENCES.md):
    cargo run -p fnp-conformance --bin run_divergence_ledger -- --fail-on-missing
    
    If the case is already known as parity_debt or intentional, the ledger row tells you why and what's planned.
  6. If new, the divergence is one of three things:
    • Bug in FrankenNumPy: fix the kernel, regenerate witnesses if applicable, add a regression fixture.
    • Behavior we want to keep but document: add a parity_debt row to docs/DIVERGENCES.md with bead ID and follow-up.
    • Bug in NumPy: extremely rare, but it happens. Document with upstream issue link.
  7. Regression-guard. Whatever the resolution, leave a fixture, a witness, or a ledger row behind so the next agent (or your future self) doesn't re-investigate from scratch.

The whole loop is built so investigation produces a permanent regression test, not just a one-off fix.


This section in the README on GitHub