Skip to content

TV ball: z_gamma without underflow in float32 - #166

Merged
dvillacis merged 1 commit into
masterfrom
fix/tv-ball-f32-subnormal-zgamma
Nov 14, 2026
Merged

dvillacis merged 1 commit into
masterfrom
fix/tv-ball-f32-subnormal-zgamma

Conversation

@dvillacis

Copy link
Copy Markdown
Owner

Fixes the nightly fuzz failure of 2026-11-14 (run 43585666004): invariant violated: dense J: not symmetric on a unit on tv1d_ball, float32, conjugate, weights [0.45, 0.03, 1.6, 2.6e-43, 5.7e152].

Cause

The projection's Jacobian on one row came out as 1·vᵀ with v off uniform by 1% (0.16607 vs 0.16786) instead of 11ᵀ/6. The derivative of z in γ, about w/|B| on a segment B, was formed in the row's dtype. With the jump on the 2.6e-43 edge it was subnormal in float32, with ~5 bits left. The power-of-two scale omega from 1.0.2 was applied only afterwards. At float32 weights beyond ~1e38 the same value was inf and the derivatives NaN.

Fix

structure, jvp and vjp in src/ops/tv_ball.cpp now take omega·z_gamma from 1D TV's JVP at dgamma = omega, which forms it in double.

Testing

  • The CI crash input replays clean; 800k random standalone fuzz inputs pass.
  • test_core, test_header, full pytest (2475 passed).
  • New case in test_tv_ball_derivatives_at_extreme_weights: float32 with w and α scaled by 2^±140. On master it fails at 2^-140 (0.45% error) and gives NaN at 2^+140.
  • Bit-identical to master where z_gamma was normal: 0 differences over 148k jvp/vjp outputs (weights 1e-20 to 1e20, both dtypes, prox and conjugate).

🤖 Generated with Claude Code

The nightly fuzz run of 2026-11-14 failed on tv1d_ball in float32 with a
jump weight of 2.6e-43: the projection's Jacobian was 1 v^T with v off
uniform by 1%, not symmetric. z_gamma, about w / |B| on a segment, was
formed in the row's dtype, where it was subnormal with ~5 bits left; the
power-of-two scale omega (1.0.2) was applied only afterwards. At float32
weights beyond ~1e38 it was inf and the derivatives NaN.

structure, jvp and vjp now take omega z_gamma from the 1D TV JVP at
dgamma = omega, formed in double. Where z_gamma was normal the bits are
unchanged (148k jvp/vjp outputs against master, both dtypes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dvillacis
dvillacis merged commit e05ed31 into master Nov 14, 2026
23 checks passed
@dvillacis
dvillacis deleted the fix/tv-ball-f32-subnormal-zgamma branch November 14, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant