You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stress test of main: int-overflow and deep-nesting segfaults, stale cache on -0.0, Parameter aliasing #37
y ** -1 likewise returns +inf instead of -inf. Comparing bytes instead of values would fix it.
4. Parameter.value keeps a view of the caller's array._flatten_shaped uses ravel('F'), which returns a view for 1-D or F-ordered input. Mutating that array changes p.value without bumping _param_version.
The value updates only after an unrelated Parameter is assigned. The same hole skips the quad_form symmetry check: with an F-ordered Q.value mutated to [[1, 5], [0, 1]], gradient() returns [2, 14] where the true value is [12, 9].
Bad errors / API
5. Read-only caches can be bypassed.J = f.jacobian(); J.data = np.zeros(...) corrupts the cached Jacobian. prob.gradient().setflags(write=True) succeeds because the array owns its data.
6. Dense constants aren't copied.e = A @ x; A[0, 0] = 100; sp.compile(e) picks up the mutation, so compiling the same expression twice can give different results.
7. Minor.Variable(True, 2) is accepted as shape (1, 2). x[5:2] raises "Shape dimensions must be positive". sp.logistic is softplus log(1+eˣ), but the docstring only says "Elementwise logistic".
Earlier reports, rechecked on main
index_flat casts to int32 before checking, so [2**32+1] and 1.7 select index 1. Still present.
A failed quad_form(x, Q) leaves Q marked symmetric. Still present.
entr(0) gives NaN and an inf Jacobian entry. Still present.
x[[]] error mentions "dtype float64", and string values are still accepted. Still present. Complex values now raise TypeError, which is fixed.
No problems found
2000 random expression trees matched finite differences for forward, Jacobian and Hessian, including after Parameter updates. They covered every atom, broadcasting, indexing, transpose, dense, sparse and Parameter matmul, reductions, and shared subexpressions.
Cache behaviour held under NaN values, variables added after a Problem, shared scopes and expressions, and repeated hessian() calls.
Non-canonical CSR constants (duplicate or unsorted entries) gave correct results.
1. Shapes with > INT_MAX entries:Reject shapes with more than INT_MAX entries #38 rejects them with a ValueError where the shape is created (in _check_shape and Node.__init__), so they no longer reach C.
4. Parameter.value aliasing the caller's array:Copy Parameter values on assignment #39 copies the value on assignment. This also closes the quad_form symmetry bypass.
Each PR adds a regression test. The other items are still open.
Not planned: deep nesting, signed-zero caching, read-only escapes, constant aliasing, and the minor error-message items. They need deliberate misuse or only happen at degenerate points.
Activity
dance858 commentedon Nov 13, 2026
Fixes are open for two of these:
ValueErrorwhere the shape is created (in_check_shapeandNode.__init__), so they no longer reach C.Parameter.valuealiasing the caller's array: Copy Parameter values on assignment #39 copies the value on assignment. This also closes thequad_formsymmetry bypass.Each PR adds a regression test. The other items are still open.
🤖 Generated with Claude Code
dance858 commentedon Nov 13, 2026
Closing: the most important items are handled.
Parameter.valuealiasing (Copy Parameter values on assignment #39).index_flatchecking indices before converting them to int32 (Validate index_flat indices before casting to int32 #40).🤖 Generated with Claude Code