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
Lattigo emitter rounds small floating-point constants to zero #3575
I found that the Lattigo Go emitter loses precision when printing floating-point splat constants. Small nonzero values can become exactly zero in the generated code, changing the computation.
std::to_string prints six digits after the decimal point, so 4e-7 becomes 0.000000.
This also rounds larger values unnecessarily. For example, 0.1234567 is emitted as 0.123457.
The emitter should preserve enough floating-point precision for the generated literal to represent the original value, for example through round-trip-safe formatting.
Adding to this: the same root cause shows up in two more places in the Lattigo emitter, and both are still there in nightly-2026.10.31. Non-splat float globals are printed with 7 significant digits (%.6e), and Chebyshev coefficients and domain endpoints go through std::scientific at its default precision.
Repro with heir-translate --emit-lattigo repro.mlir:
This emits var a = []float64{3.333333e-01, 1.234568e+00}, SetFloat64(1.234568e-01) for the coefficient, and [2]float64{-1.234568e+00, 1.234568e+00} for the domain. The digits are gone before the values reach big.Float, so the extra precision there doesn't help.
This matters even for ordinary constants: a coefficient like 0.0390625 on an x^4 term comes out as 0.039062, which shifts the result by about 3e-3 at x = 9. The sigmoid, relu_composite and mnist examples in this repo also get truncated constants, but their tests don't catch it.
Printing round-trip-safe values, as the OpenFHE emitter already does, would cover all three paths.
Given the recent pushback on AI-generated bug reports, I'm adding this here rather than opening new issues. I agree with that pushback: a tool-found bug is only worth maintainers' time if someone has checked it and can say why it matters.
Activity
A1ester commentedon Oct 31, 2026
Adding to this: the same root cause shows up in two more places in the Lattigo emitter, and both are still there in nightly-2026.10.31. Non-splat float globals are printed with 7 significant digits (
%.6e), and Chebyshev coefficients and domain endpoints go throughstd::scientificat its default precision.Repro with
heir-translate --emit-lattigo repro.mlir:This emits
var a = []float64{3.333333e-01, 1.234568e+00},SetFloat64(1.234568e-01)for the coefficient, and[2]float64{-1.234568e+00, 1.234568e+00}for the domain. The digits are gone before the values reachbig.Float, so the extra precision there doesn't help.This matters even for ordinary constants: a coefficient like
0.0390625on an x^4 term comes out as0.039062, which shifts the result by about 3e-3 at x = 9. The sigmoid, relu_composite and mnist examples in this repo also get truncated constants, but their tests don't catch it.Printing round-trip-safe values, as the OpenFHE emitter already does, would cover all three paths.
Given the recent pushback on AI-generated bug reports, I'm adding this here rather than opening new issues. I agree with that pushback: a tool-found bug is only worth maintainers' time if someone has checked it and can say why it matters.