MOD-14559 Fix float serialization precision for typed FPHA arrays#19
Merged
AvivDavid23 merged 6 commits intomasterfrom Mar 23, 2026
Merged
MOD-14559 Fix float serialization precision for typed FPHA arrays#19AvivDavid23 merged 6 commits intomasterfrom
AvivDavid23 merged 6 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.
|
run some preformence test |
gabsow
approved these changes
Mar 23, 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.

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.Performance:
Note
Medium Risk
Changes JSON serialization output for typed
F32/F16/BF16arrays, which may affect downstream consumers that relied on the previous (over-precise) decimal strings. Logic adds custom rounding/round-trip checks for half types, so edge cases around non-finite values and precision boundaries need review.Overview
Fixes typed float array JSON serialization to avoid promoting elements through
INumber/f64, which previously causedserde_json/ryu to emit overly long decimal strings (e.g.0.3becoming0.30000001192092896).IArray::serializenow special-casesArraySliceRef::F32to serialize elements asf32, andArraySliceRef::F16/BF16to compute the shortest decimal that round-trips through the stored half-precision value (viaround_to_sig_digits+find_shortest_roundtrip_f64) before serializing. Adds unit tests covering short formatting, round-trip stability acrossF16/BF16/F32/F64, and expected precision-loss cases (including negatives).Written by Cursor Bugbot for commit f630ed5. This will update automatically on new commits. Configure here.