Skip to content

Add heterodyne measurement interface#96

Open
arnavk23 wants to merge 3 commits intoQuantumSavory:mainfrom
arnavk23:issue-84-heterodyne
Open

Add heterodyne measurement interface#96
arnavk23 wants to merge 3 commits intoQuantumSavory:mainfrom
arnavk23:issue-84-heterodyne

Conversation

@arnavk23
Copy link
Copy Markdown
Contributor

@arnavk23 arnavk23 commented Jan 9, 2026

Implement heterodyne measurement for Gaussian states:

  • Heterodyne struct for storing measurement results and output state
  • Support for both QuadPairBasis and QuadBlockBasis
  • Simultaneous measurement of both quadratures (unit-gain)
  • rand() support for sampling heterodyne measurement outcomes

Before considering your pull request ready for review and merging make sure that all of the following are completed (please keep the clecklist as part of your PR):

  • The code is properly formatted and commented.
  • Substantial new functionality is documented within the docs.
  • All new functionality is tested.
  • All of the automated tests on github pass.
  • We recently started enforcing formatting checks. If formatting issues are reported in the new code you have written, please correct them. There will be plenty of old code that is flagged as we are slowly transitioning to enforced formatting. Please do not worry about or address older formatting issues -- keep your PR just focused on your planned contribution.

Implement heterodyne measurement for Gaussian states:
- Heterodyne struct for storing measurement results and output state
- Support for both QuadPairBasis and QuadBlockBasis
- Simultaneous measurement of both quadratures (unit-gain)
- rand() support for sampling heterodyne measurement outcomes
- Comprehensive tests covering structural, analytical, and statistical validation
- Documentation in CHANGELOG
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 96.37306% with 7 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@93ede8e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/heterodyne.jl 96.37% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage        ?   97.18%           
=======================================
  Files           ?       21           
  Lines           ?     2879           
  Branches        ?        0           
=======================================
  Hits            ?     2798           
  Misses          ?       81           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@arnavk23
Copy link
Copy Markdown
Contributor Author

arnavk23 commented Feb 20, 2026

@apkille can you take a look at this whenever you are free. if this is good, we can start working on merging this. if not, can you recommend me some issues/additions to work on.

*Also can you recommend me other repos of the organisation to work on based on my work. I am interested in a future in Quantum Computing and would like to get as much exposure as i can get.
*Also interested in GSoC angle, if you think a project is good for me, we can start working on it.

Thanks for everything (especially your reviews and comments).

@apkille
Copy link
Copy Markdown
Member

apkille commented Mar 16, 2026

Thanks for this PR @arnavk23. I will try to review later this week.

Re recommendations to other repos: if you haven't already, I would check out the issues in QuantumClifford and QuantumSavory, which are pretty far in the development stage. It would be interesting to continue analog dynamics support in QuantumSavory. This WIP PR (QuantumSavory/QuantumSavory.jl#309) is an example of connecting Gabs to the existing infrastructure, but of course one could come up with more examples, both in the phase space representation in Gabs, and the state vector representation with, e.g., QuantumOptics or QuantumToolbox. There's also general interest in additionally having a matrix product state backend with ITensorMPS, which I might be able to help with. QuantumSymbolics also has some low-hanging fruit, although they are rather software-focused and might not be worth your time if you are primarily interested in quantum computing. Within Gabs itself, there's quite a lot of fun little projects we could do with symplectic analysis and continue to develop SymplecticMatrices, although again, that would involve a lot of applied mathematics, which you may or may not be interested in.

This is a rather disorganized list of things you could do. We can discuss in more detail over Slack if you're particularly interested in one of these projects or have something else in mind.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 19, 2026

Benchmark Results (Julia v1)

Time benchmarks
main df2ff61... main / df2ff61...
operations/channel product/10 4.8 ± 0.76 μs 4.49 ± 0.68 μs 1.07 ± 0.23
operations/channel product/100 0.687 ± 0.17 ms 0.7 ± 0.039 ms 0.982 ± 0.24
operations/channel product/2 1.35 ± 0.1 μs 1.29 ± 0.1 μs 1.05 ± 0.11
operations/channel product/200 3.52 ± 0.12 ms 3.53 ± 0.17 ms 0.996 ± 0.06
operations/channel product/50 0.245 ± 0.018 ms 0.255 ± 0.02 ms 0.963 ± 0.1
operations/partial trace/10 1.33 ± 0.13 μs 1.26 ± 0.13 μs 1.06 ± 0.15
operations/partial trace/100 9.18 ± 0.99 μs 8.47 ± 0.86 μs 1.08 ± 0.16
operations/partial trace/2 0.932 ± 0.06 μs 0.861 ± 0.049 μs 1.08 ± 0.093
operations/partial trace/200 24 ± 3.7 μs 21.4 ± 3.8 μs 1.12 ± 0.26
operations/partial trace/50 5.2 ± 0.91 μs 5.08 ± 0.75 μs 1.02 ± 0.23
operations/tensor product/10 2.23 ± 0.41 μs 1.94 ± 0.43 μs 1.15 ± 0.33
operations/tensor product/100 0.161 ± 0.018 ms 0.154 ± 0.028 ms 1.05 ± 0.23
operations/tensor product/2 0.892 ± 0.061 μs 0.832 ± 0.04 μs 1.07 ± 0.09
operations/tensor product/200 0.837 ± 0.18 ms 0.816 ± 0.16 ms 1.03 ± 0.3
operations/tensor product/50 0.033 ± 0.0083 ms 29.2 ± 13 μs 1.13 ± 0.57
operations/unitary product/10 3.7 ± 0.38 μs 3.58 ± 0.36 μs 1.03 ± 0.15
operations/unitary product/100 0.651 ± 0.029 ms 0.663 ± 0.044 ms 0.982 ± 0.078
operations/unitary product/2 1.18 ± 0.05 μs 1.12 ± 0.05 μs 1.05 ± 0.065
operations/unitary product/200 3.42 ± 0.16 ms 3.42 ± 0.088 ms 1 ± 0.055
operations/unitary product/50 0.231 ± 0.017 ms 0.234 ± 0.016 ms 0.988 ± 0.097
time_to_load 0.217 ± 0.0004 s 0.216 ± 0.00055 s 1.01 ± 0.0032
Memory benchmarks
main df2ff61... main / df2ff61...
operations/channel product/10 17 allocs: 10.2 kB 17 allocs: 10.2 kB 1
operations/channel product/100 17 allocs: 0.919 MB 17 allocs: 0.919 MB 1
operations/channel product/2 14 allocs: 0.891 kB 14 allocs: 0.891 kB 1
operations/channel product/200 19 allocs: 3.67 MB 19 allocs: 3.67 MB 1
operations/channel product/50 17 allocs: 0.231 MB 17 allocs: 0.231 MB 1
operations/partial trace/10 14 allocs: 0.672 kB 14 allocs: 0.672 kB 1
operations/partial trace/100 15 allocs: 2.79 kB 15 allocs: 2.79 kB 1
operations/partial trace/2 14 allocs: 0.672 kB 14 allocs: 0.672 kB 1
operations/partial trace/200 15 allocs: 5.04 kB 15 allocs: 5.04 kB 1
operations/partial trace/50 14 allocs: 1.69 kB 14 allocs: 1.69 kB 1
operations/tensor product/10 9 allocs: 13.1 kB 9 allocs: 13.1 kB 1
operations/tensor product/100 10 allocs: 1.22 MB 10 allocs: 1.22 MB 1
operations/tensor product/2 8 allocs: 0.797 kB 8 allocs: 0.797 kB 1
operations/tensor product/200 10 allocs: 4.89 MB 10 allocs: 4.89 MB 1
operations/tensor product/50 9 allocs: 0.307 MB 9 allocs: 0.307 MB 1
operations/unitary product/10 14 allocs: 6.95 kB 14 allocs: 6.95 kB 1
operations/unitary product/100 14 allocs: 0.614 MB 14 allocs: 0.614 MB 1
operations/unitary product/2 12 allocs: 0.688 kB 12 allocs: 0.688 kB 1
operations/unitary product/200 16 allocs: 2.45 MB 16 allocs: 2.45 MB 1
operations/unitary product/50 14 allocs: 0.155 MB 14 allocs: 0.155 MB 1
time_to_load 0.145 k allocs: 11 kB 0.145 k allocs: 11 kB 1

@arnavk23
Copy link
Copy Markdown
Contributor Author

@apkille Thank you for your comment. I have started prs on QuantumClifford.jl but failed to find something in QuantumSavory to really stick my teeth into but I will surely go through your suggestions and your draft pr on the repo. For gabs, certainly I am interested in symplectic analysis but the project of matrix product state backend with ITensorMPS drew my attention and I am planning to apply to GSoC for the same.

We can discuss on the same on Slack (I am currently not added to the channel, so will need an invite for the same). Open to any comments or suggestions on the same.

Sidebar : I saw on my other pr that you apologized for the slow response. No need for the same, I do understand that you are quite busy in your research and the comment was put forward as a general ping for whenever you are free.

Thank you!

@apkille
Copy link
Copy Markdown
Member

apkille commented Mar 19, 2026

We can discuss on the same on Slack (I am currently not added to the channel, so will need an invite for the same). Open to any comments or suggestions on the same.

Here's a link to join: https://julialang.org/slack/

matrix product state backend with ITensorMPS drew my attention and I am planning to apply to GSoC for the same.

I should note, before you put any work into this, that @riteshbhirud and I have a working bosonic MPS backend for Gabs that will be made public in the coming months. But there is plenty of work to do for having a general MPS backend in QuantumSymbolics and QuantumSavory and doing large-scale dynamics simulations

@Krastanov-agent
Copy link
Copy Markdown
Contributor

Krastanov-agent commented Mar 19, 2026

From the bot: Following the edge-case discussion in #106: the single-mode / all-modes case should be supported here as well. I added the corresponding generaldyne support and tests in #106 so this edge case is covered there too.

From the actual Stefan: Thanks, Arnav for looking into this. In a related PR I was making sure a that an edge case is properly handled by some of the other measurement functions -- in particular the fact that single-mode states were previously excluded from the API. The only reason for the post here is to warn about that edge case and to show how simple handling it was in the rest of the code base, in case it comes up here.

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.

3 participants