Repository navigation
fix(server): floatRepr spells non-finite floats as Python's repr does - #604
Merged
Merged
Conversation
Closed
Owner
|
Thank you, @chaog992. This is merged into main (ee1d4b9), your commit as it was, and it ships in 1.0.6. A NaN reaching any of the |
philip-pentatonic
pushed a commit
to machinegenieorg/TensorFold
that referenced
this pull request
Oct 10, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
… Python's repr does
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
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.
What this changes
floatReprinzig/src/server/json_write.zigrenders a float in scientific form and parses the exponent after thee. NaN and ±inf render asnanandinf, which have noe, so the slice at json_write.zig:116 starts past the end and panics; the server module is built ReleaseSafe, so that ends the process. The callers that render a value as Python'sstr()does (tool_specs.pyStr,decisions.zig:135,serve.zig:192,tool_params.zig:223) pass non-finite values on without a check.floatReprnow returnsnan,infor-inffor them, which is Python'sreprand the spellingpyrepr.zigalready writes. JSON output is unchanged, becausefloatJsonspellsNaNandInfinitybefore it callsfloatRepr. Every finite float renders as before.Receipt
2f8284e8, fixc7f583d0, Zig 0.17.0, Linux x86_64 under WSL2. No GPU or model is needed.zig build testpasses 37/37 steps and 358/358 tests.bash zig/tests/server/zig_test.shpasses 108 and 84 tests, as on the base; the change adds three rows (NaN, inf, -inf) to the existingfloat reprtable test.floatRepr:python3 tools/zig/lean_check.pyreports 1057 files and 542 problems on the base, and the same list with this change.zig fmt --check zig/src/server/json_write.zigpasses. The Zig format job already fails on main itself, on files this change does not touch. The server tests compile foraarch64-macoswith-mcpu apple_m1 --test-no-exec; this is a compile check, not a macOS test run.test-golden) and a served model on Metal or CUDA. The change touches no inference path.