Skip to content

fix: preserve exact integer resource counts - #301

Open
ddri wants to merge 1 commit into
PsiQ:mainfrom
ddri:fix/bartiq-precision
Open

ddri wants to merge 1 commit into
PsiQ:mainfrom
ddri:fix/bartiq-precision

Conversation

@ddri

@ddri ddri commented Oct 10, 2026 •

Copy link
Copy Markdown

Hi team, this issue is part of a batch from our review of bartiq at Marqov. We routinely review quantum computing tools that our community requests or that we’re exploring for integration with the Marqov SDK and Platform. We’re sharing these findings, reproductions, and proposed fixes in the hope they’re useful. There’s no expectation of an immediate response, and we can maintain any patches we need in our own fork while using the software.

Description

Compiling an exact resource count supplied as a string can silently change its value: 9007199254740993 becomes 9007199254740990. Exact powers and arithmetic on large assigned inputs are affected too. The backend approximates a SymPy integer with N() before converting it to a native integer.

Return exact SymPy integers as Python integers before numerical approximation. This fixes expressions SymPy has reduced to an exact integer. Unevaluated sums and noninteger rational expressions retain their current approximation behavior. Regression tests cover positive and negative large integers, exact powers, compilation/export, and evaluation of N+1 with a large input.

Validation:

  • All eight new regression cases fail on unchanged upstream.
  • Full suite: 1,341 passed, 3 expected failures.
  • MYPYPATH=src poetry run mypy src --install-types --non-interactive: passes with the lockfile's mypy 1.16.1.
  • poetry run pre-commit run -a: passes.
  • Independent Claude Code review: approved commit 1b7a94b; independently reran the full suite and core-only symbolic/compiler tests.

Please verify that you have completed the following steps

  • I have self-reviewed my code.
  • I have included test cases validating introduced feature/fix.
  • I have updated documentation. No public API or documentation behavior changes are introduced.

@CLAassistant

CLAassistant commented Oct 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants