Skip to content

Add nsteps for Trotter expansion based on propagator error#1371

Open
arettig wants to merge 4 commits into
quantumlib:mainfrom
arettig:trotter_prop_error
Open

Add nsteps for Trotter expansion based on propagator error#1371
arettig wants to merge 4 commits into
quantumlib:mainfrom
arettig:trotter_prop_error

Conversation

@arettig

@arettig arettig commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #820. Currently we compute the number of steps in a Trotter expansion based on the desired error in the ground state energy. This PR adds a function to compute the number of steps based on the desired error in the propagator $U$ (which is different). This could be useful for certain use cases like dynamics.

New tests are also added to cover this new function.

The current implementation computes the number of steps needed
in a Trotter expansion to reach an error in the ground state energy.
This commit adds functionality to compute the number of steps determined
by the error in the propagator itself.
@arettig arettig requested a review from mhucka June 22, 2026 23:00

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces trotter_steps_required_propagator to calculate the number of Trotter steps required for accurate state evolution, updates trotter_steps_required to handle negative times correctly, and adds corresponding unit tests. The reviewer suggested adding input validation to both functions to prevent division-by-zero errors when precision parameters are non-positive, and ensuring that at least one step is returned for any non-zero simulation time when the error bound is zero.

Comment thread src/openfermion/circuits/trotter/trotter_error.py Outdated
Comment thread src/openfermion/circuits/trotter/trotter_error.py Outdated
Added checks to ensure the parameters and therefore output
of trotter_steps_required functions are physically meaningful.
Added several tests for edge cases of these functions.

@mhucka mhucka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it would benefit for just a couple of small additions to value testing. Otherwise it looks good!

Comment thread src/openfermion/circuits/trotter/trotter_error.py
Comment thread src/openfermion/circuits/trotter/trotter_error.py
arettig added 2 commits June 23, 2026 16:34
The parameter trotter_error_bound is checked within the
trotter_steps_required function and a ValueError is raised if a
negative value is provided.

@mhucka mhucka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

@mhucka mhucka added the priority/before-1.7.2 Things to do before the next release label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/before-1.7.2 Things to do before the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect formula to calculate required Trotter steps

2 participants