Skip to content

added direct MPO Process Tensor construction and temporal entanglement#508

Merged
aaronleesander merged 16 commits into
mainfrom
pt-control
Jul 22, 2026
Merged

added direct MPO Process Tensor construction and temporal entanglement#508
aaronleesander merged 16 commits into
mainfrom
pt-control

Conversation

@aaronleesander

Copy link
Copy Markdown
Member

Description

This PR adds the ability (and new default) to directly construct and MPO Process Tensor step by step rather than with tomography.

Additionally, it adds a proper temporal entanglement measure.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • AI-assisted commits include an Assisted-by: [Model Name] via [Tool Name] footer.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

@aaronleesander aaronleesander added the feature New feature or request label Jul 22, 2026
@aaronleesander

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@aaronleesander, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 99337563-dd7c-40b7-8660-323aec176e38

📥 Commits

Reviewing files that changed from the base of the PR and between 32e3acf and 22d43d4.

📒 Files selected for processing (5)
  • docs/examples/characterization.md
  • src/mqt/yaqs/characterization/memory/backends/tomography/constructor.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/direct.py
  • src/mqt/yaqs/memory_characterizer.py
  • tests/characterization/memory/backends/tomography/test_direct.py
📝 Walkthrough

Walkthrough

The tomography backend now constructs MPO process tensors directly by default, while dense outputs continue to use exhaustive tomography. Shared APIs compute temporal entanglement and evaluate probes across dense and MPO representations, with expanded tests and documentation.

Changes

Process-tensor construction and analysis

Layer / File(s) Summary
Dense process-tensor reconstruction
src/mqt/yaqs/characterization/memory/backends/tomography/data.py
Sequence data is packed and reconstructed into validated dense process tensors.
Direct MPO construction and dispatch
src/mqt/yaqs/characterization/memory/backends/tomography/direct.py, src/mqt/yaqs/characterization/memory/backends/tomography/constructor.py, src/mqt/yaqs/memory_characterizer.py
MPO process tensors are built directly through compressed branch expansion, with noiseless-only validation and updated defaults.
Temporal entropy and probe evaluation
src/mqt/yaqs/characterization/memory/backends/tomography/process_tensors.py, docs/examples/characterization.md, docs/examples/quickstart.md
Shared probe evaluation and temporal-entanglement APIs support dense and MPO process tensors.
Feature validation and release documentation
tests/characterization/memory/backends/tomography/*, CHANGELOG.md, docs/examples/memory_surrogate.md
Tests compare construction modes, execution modes, and solvers; examples and release notes document the updated behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant MemoryCharacterizer
  participant build_process_tensor_direct
  participant _apply_timestep
  participant MPOProcessTensor
  User->>MemoryCharacterizer: request return_type="mpo"
  MemoryCharacterizer->>build_process_tensor_direct: construct process tensor
  build_process_tensor_direct->>_apply_timestep: expand each intervention leg
  _apply_timestep->>MPOProcessTensor: accumulate compressed MPO terms
  MPOProcessTensor-->>User: return MPO process tensor
Loading

Possibly related PRs

Suggested labels: enhancement

Poem

I’m a rabbit with MPOs in flight,
Building process tensors crisp and light.
Entropy hops from cut to cut,
Probe results bloom from every nut.
Dense and direct now agree—
A carrot feast for memory! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: direct MPO process tensor construction and temporal entanglement.
Description check ✅ Passed The description includes a concise summary and a filled checklist, but it omits issue/dependency details from the template.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch pt-control

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mqt/yaqs/memory_characterizer.py`:
- Line 10: Replace the malformed Ruff suppression comments with valid noqa
comments or a Ruff disable block: retain the module-level suppression at
src/mqt/yaqs/memory_characterizer.py:10, and update the inline suppressions at
src/mqt/yaqs/memory_characterizer.py:870,
src/mqt/yaqs/characterization/memory/backends/tomography/constructor.py:444,
tests/characterization/memory/backends/tomography/test_process_tensors.py:8, and
tests/characterization/memory/backends/tomography/test_basis.py:8 so Ruff
recognizes the intended codes.

In `@tests/characterization/memory/backends/tomography/test_direct.py`:
- Line 33: Update the parametrized interacting equivalence test in
test_direct.py by replacing the all-zero timesteps schedule with nonzero
evolution durations, while preserving the existing schedule length of
num_interventions + 1 and the rest of the test setup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 84d97fae-d61d-4f3b-8dee-adc02b2d66be

📥 Commits

Reviewing files that changed from the base of the PR and between d143fbd and fd05b67.

📒 Files selected for processing (15)
  • CHANGELOG.md
  • docs/examples/characterization.md
  • docs/examples/memory_surrogate.md
  • docs/examples/quickstart.md
  • src/mqt/yaqs/characterization/memory/backends/__init__.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/__init__.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/constructor.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/data.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/direct.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/process_tensors.py
  • src/mqt/yaqs/memory_characterizer.py
  • tests/characterization/memory/backends/tomography/test_basis.py
  • tests/characterization/memory/backends/tomography/test_data.py
  • tests/characterization/memory/backends/tomography/test_direct.py
  • tests/characterization/memory/backends/tomography/test_process_tensors.py
💤 Files with no reviewable changes (1)
  • tests/characterization/memory/backends/tomography/test_data.py

Comment thread src/mqt/yaqs/memory_characterizer.py Outdated
Comment thread tests/characterization/memory/backends/tomography/test_direct.py Outdated
@aaronleesander

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aaronleesander

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mqt/yaqs/characterization/memory/backends/tomography/direct.py`:
- Around line 191-210: The direct MPO construction path must not pass a
flattened dense state to the TJM solver. In the worker containing the br.psi
conversion and _evolve_backend_state call, either reject solver="TJM" for
return_type="mpo" before branch extension, or preserve br.psi as an MPS
throughout this path; ensure unsupported combinations fail clearly and non-TJM
behavior remains unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fc266adf-c0d4-40d9-9081-a75085c9dfe1

📥 Commits

Reviewing files that changed from the base of the PR and between fd05b67 and 8a825b5.

📒 Files selected for processing (10)
  • docs/examples/characterization.md
  • docs/examples/memory_surrogate.md
  • src/mqt/yaqs/characterization/memory/backends/tomography/__init__.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/constructor.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/direct.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/process_tensors.py
  • src/mqt/yaqs/memory_characterizer.py
  • tests/characterization/memory/backends/tomography/test_constructor.py
  • tests/characterization/memory/backends/tomography/test_direct.py
  • tests/characterization/memory/backends/tomography/test_process_tensors.py

Comment thread src/mqt/yaqs/characterization/memory/backends/tomography/direct.py Outdated
@aaronleesander

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mqt/yaqs/characterization/memory/backends/tomography/direct.py`:
- Line 305: Restore a finite default max_bond_dim so _compress_branches runs by
default and direct construction remains scalable, while preserving None as the
opt-in for exact uncapped construction. Apply the same finite default in
src/mqt/yaqs/characterization/memory/backends/tomography/direct.py lines 305-305
and src/mqt/yaqs/characterization/memory/backends/tomography/constructor.py
lines 397-397; align the facade default and documentation in
src/mqt/yaqs/memory_characterizer.py lines 329-329.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e8c1fc02-f303-4b2e-8ece-3b1b05d9228a

📥 Commits

Reviewing files that changed from the base of the PR and between 8a825b5 and 32e3acf.

📒 Files selected for processing (10)
  • docs/examples/characterization.md
  • docs/examples/memory_surrogate.md
  • src/mqt/yaqs/characterization/memory/backends/__init__.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/__init__.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/constructor.py
  • src/mqt/yaqs/characterization/memory/backends/tomography/direct.py
  • src/mqt/yaqs/memory_characterizer.py
  • tests/characterization/memory/backends/tomography/test_constructor.py
  • tests/characterization/memory/backends/tomography/test_direct.py
  • tests/characterization/noise/backends/test_cma.py

Comment thread src/mqt/yaqs/characterization/memory/backends/tomography/direct.py Outdated
@aaronleesander

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aaronleesander
aaronleesander enabled auto-merge July 22, 2026 13:26
@aaronleesander
aaronleesander merged commit 7c78c6c into main Jul 22, 2026
13 checks passed
@aaronleesander
aaronleesander deleted the pt-control branch July 22, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant