Skip to content

digest: use math.fsum for coverage so digests are bit-identical across interpreters #26

Description

@onlyxItachi

Measured in: INTERPRETER_MATRIX_2026-07-18 — digests hashed across six CPythons (3.10, 3.11, 3.12, 3.13, 3.14, 3.14t).

10 of 11 pure-Python backends produce byte-identical digests on every interpreter. The single divergence is chrome_trace's coverage_pct_of_total_duration, and it splits cleanly at the 3.11/3.12 boundary: CPython 3.12 changed the builtin sum() to use compensated (Neumaier) summation, so core/digest.py's total-duration accumulation differs in its last bits between 3.10/3.11 and 3.12+. Reproduced directly with a sum()-vs-fsum() comparison on both sides of the boundary.

This is not a bug — no metric is wrong, no absence is fabricated, and the token-cost impact is roughly one byte. It is filed because the property it breaks is worth keeping deliberately rather than by accident: a digest that is bit-identical regardless of interpreter means a cached/committed digest, a CI-produced digest, and a local digest are directly comparable artifacts, and any future diff in them means the report changed rather than the runtime.

Suggested fix: use math.fsum for the float accumulation behind coverage_pct_of_total_duration (and audit core/digest.py / core/compare.py for any other float sum() over report data). fsum is exactly-rounded and version-stable, so the property becomes guaranteed instead of incidental.

Verification: re-run workloads/interpreter_matrix.py --legs identity from the bench repo; all 11 backends should hash identically across all six interpreters.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions