Skip to content

Added non-qubit local observables#497

Open
linusschulte wants to merge 2 commits into
munich-quantum-toolkit:mainfrom
linusschulte:trapped-ion-hamiltonian
Open

Added non-qubit local observables#497
linusschulte wants to merge 2 commits into
munich-quantum-toolkit:mainfrom
linusschulte:trapped-ion-hamiltonian

Conversation

@linusschulte

Copy link
Copy Markdown
Contributor

Description

Added support for one-site non-qubit observables using new LocalOperator in order to enable measurement of things like physical position.
Tests cover Observable construction from local matrices, MPS expectation evaluation on non-qubit sites, dimension-mismatch errors, and the proper expected trapped-ion trajectory.
Note: Local Observables are still called "Gates" due to qubit-only heritage. That might be a bit misleading for non-logical operators but renaming that consistently is outside of this PR's scope.

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:

PR was assisted by ChatGPT Codex 5.5 via VS Code Codex Plugin

  • I have disclosed the use of AI tools in the PR description as per our AI Usage Guidelines.
  • 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.

linusschulte and others added 2 commits July 8, 2026 08:19
Signed-off-by: linusschulte <119408387+linusschulte@users.noreply.github.com>
@aaronleesander

Copy link
Copy Markdown
Member

@linusschulte Can you do a couple things

  1. I don't want the user to have to import Observable. If you check previous usage, users just type Observable("name", site). Can you change it to be more user-friendly somehow? If not, let me know and we can look through it
  2. There was just a release so the CHANGELOG point should be moved up under [Unreleased]. You might need to add an added header like in the previous ones.

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

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.12698% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mqt/yaqs/core/data_structures/mps.py 77.1% 8 Missing ⚠️
...yaqs/core/data_structures/simulation_parameters.py 85.7% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@linusschulte

Copy link
Copy Markdown
Contributor Author

Regarding your first review point:
Are you looking for something like Observable("position", site)? The constructor needs the actual grid values, so I don't think it can be done without passing additional context. The next best thing I can think of is something like Observable.position(positions, site), but that's really just a wrapper for np.diag, and I'm not sure how much higher that ranks on the user-friendliness scale.

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.

2 participants