MOD-14559 Fix float serialization precision for typed FPHA arrays#19
Open
AvivDavid23 wants to merge 4 commits intomasterfrom
Open
MOD-14559 Fix float serialization precision for typed FPHA arrays#19AvivDavid23 wants to merge 4 commits intomasterfrom
AvivDavid23 wants to merge 4 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
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.

When serializing typed float arrays, values were promoted to f64 (via INumber) before being passed to serde_json's
serialize_f64. This caused serde_json's ryu formatter to produce unnecessarily long decimal strings, because ryu needs more digits to uniquely identify a value among all f64s than among all f32s.For example, 0.3 stored in an F32 array would serialize as "0.30000001192092896" instead of "0.3".
The fix bypasses the
IValue/INumberconversion forF32/F16/BF16typed arrays during serialization, instead passing the raw float values directly to serde. This routes F32 values throughserialize_f32(andF16/BF16throughserialize_f32viaf32::from()), where ryu's f32 algorithm produces the shortest string that round-trips through f32 — matching user expectations.Note
Medium Risk
Changes the exact JSON text produced for typed float arrays (especially
f16/bf16/f32), which may affect snapshot tests or consumers relying on prior formatting, but it is constrained to serialization output.Overview
Improves
IArrayJSON serialization for typed float arrays to avoid promoting values throughINumber/f64, which previously caused overly long decimal strings.ArraySliceRef::F32now serializes elements asf32, andArraySliceRef::F16/BF16use a newfind_shortest_roundtrip_f64helper to pick the shortest decimal that round-trips through the half type before emitting viaserialize_f64. Adds focused tests to ensure short representations and round-trip stability acrossF16/BF16/F32/F64.Written by Cursor Bugbot for commit 2141ecf. This will update automatically on new commits. Configure here.