feat(format): f16-conversion-v1 + dpo-loss-v1 9-gate PARTIAL discharge#1395
Open
feat(format): f16-conversion-v1 + dpo-loss-v1 9-gate PARTIAL discharge#1395
Conversation
Bundles two sister contracts in one verdict module: f16-conversion-v1 (FALSIFY-F16-001..004): - F16-001: bit-trick output bit-exact equal to f32::from(f16) - F16-002: f16→f32→f16 roundtrip is identity for normal values - F16-003: sign preservation under conversion - F16-004: SIMD f16 conversion bit-exact equal to scalar dpo-loss-v1 (FALSIFY-DPO-001..005): - DPO-001: L_DPO ≥ 0 for all valid log-ratio pairs and beta > 0 - DPO-002: L_DPO ≈ log(2) at the reference policy (r_w == r_l == 0) - DPO-003: monotonicity in preferred log-ratio - DPO-004: finite output for log-ratios in [-100, 100] - DPO-005: symmetry — L(rw,rl) + L(rl,rw) == |z| + 2*log(1+exp(-|z|)) ## Five Whys 1. Why bundle these two contracts? Both peripheral, span the precision-conversion + preference-optimization coverage band; one verdict module captures both without duplicate provenance pin. 2. Why does this block ship? Coverage % cannot move while these peripheral contracts are unbound at PARTIAL_ALGORITHM_LEVEL. 3. Why bind both verdicts AND a reference `dpo_loss()` helper? The monotonicity (DPO-003) and symmetry (DPO-005) gates need a deterministic loss function to compare values; the `log(2)` gate (DPO-002) needs a pinned reference value. Pinning the numerically-stable softplus formula in-module prevents future drift between the verdict-test loss and the actual training loss. 4. Why bit-exact (`to_bits()`) for F16-001/004 vs ULP-tolerant? The contract specifies "Bit manipulation matches f32::from(f16)" — even one ULP of drift on a single conversion accumulates over millions of weights into measurable inference divergence. Strict bit-exact is the only way to enforce "no precision loss in the conversion path." 5. Why `f32::NAN` for invalid DPO inputs (vs returning Some/Result)? The downstream verdict functions all check `is_finite()` and Fail on NaN — making the loss helper return NaN for invalid inputs propagates the "broken harness" signal cleanly through the gate pipeline without changing every call-site signature. Adds 26 unit tests including a 11-bucket monotonicity sweep on DPO-003. Realistic-healthy walks the canonical loss values; pre-fix walks 9 simultaneous regressions across both contracts. No runtime % shift; algorithm-level coverage advances by 9 gates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bundles two sister contracts in one verdict module:
f16-conversion-v1(FALSIFY-F16-001..004): bit-trick parity, roundtrip, sign, SIMD≡scalardpo-loss-v1(FALSIFY-DPO-001..005): non-negativity, log(2) reference, monotonicity, stability, symmetry26 unit tests including 11-bucket monotonicity sweep on DPO-003. Algorithm-level coverage advances by 9 gates.
Gates bound
f32::from(f16)Reference helper
dpo_loss(r_w, r_l, beta)uses softplus form for numerical stability.Five Whys
See commit message — captures bit-exact rationale for F16-001/004, NaN-on-invalid-input policy, and why a reference loss helper ships in-module.
Test plan
cargo test -p aprender-core --lib f16_dpo— 26 passed🤖 Generated with Claude Code