Skip to content

Trotter tensor contraction - #95

Merged
BrendanKKrueger merged 4 commits into
mainfrom
bkk_force_approx
Aug 6, 2026
Merged

BrendanKKrueger merged 4 commits into
mainfrom
bkk_force_approx

Conversation

@BrendanKKrueger

Copy link
Copy Markdown
Collaborator

Allow the user to explicitly force a particular tensor contraction algorithm for the flattened Trotter. This option is intentionally not documented, because as a general rule it should only be used by developers. I need it for testing.

This commit adds the ability to force a specific tensor contraction
algorithm via configuration, enabling controlled comparisons between:
- O(n) incremental method
- O(log n) structured method (matrix exponentiation)

Changes:
- analysis/config_types.py: Add tensor_contraction_method parameter
  with validation (None, "auto", "incremental", "structured")
- analysis/unitary.py: Pass parameter through to Trotterization
- common/trotter_flattened.py: Implement forced mode logic in
  tensor_contract() method

When forced to "structured" but pattern cannot be detected, raises
RuntimeError instead of falling back (no silent behavior changes).

This enables comparison studies to test each algorithm under identical
conditions regardless of auto-selection thresholds.
@BrendanKKrueger
BrendanKKrueger marked this pull request as ready for review August 6, 2026 22:10
@BrendanKKrueger
BrendanKKrueger merged commit 8b56c07 into main Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants