Skip to content

Generalize GaussianLinearCombination to operators#104

Open
arnavk23 wants to merge 2 commits intoQuantumSavory:mainfrom
arnavk23:issue-83-linear-combinations-operators
Open

Generalize GaussianLinearCombination to operators#104
arnavk23 wants to merge 2 commits intoQuantumSavory:mainfrom
arnavk23:issue-83-linear-combinations-operators

Conversation

@arnavk23
Copy link
Contributor

@arnavk23 arnavk23 commented Mar 9, 2026

This PR fixes #83 by generalizing GaussianLinearCombination to support homogeneous linear combinations of GaussianState, GaussianUnitary, or GaussianChannel (with consistent basis and ħ).
It adds operator/channel arithmetic support (scalar ops and +/- with matching LC types), while keeping state-specific functionality and backward compatibility intact.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Benchmark Results (Julia v1)

Time benchmarks
main a9d7e54... main / a9d7e54...
operations/channel product/10 4.64 ± 0.8 μs 4.76 ± 0.69 μs 0.975 ± 0.22
operations/channel product/100 0.68 ± 0.065 ms 0.682 ± 0.072 ms 0.997 ± 0.14
operations/channel product/2 1.3 ± 0.09 μs 1.39 ± 0.11 μs 0.935 ± 0.098
operations/channel product/200 3.51 ± 1.1 ms 3.51 ± 0.75 ms 1 ± 0.39
operations/channel product/50 0.237 ± 0.02 ms 0.242 ± 0.025 ms 0.978 ± 0.13
operations/partial trace/10 1.29 ± 0.13 μs 1.32 ± 0.13 μs 0.977 ± 0.14
operations/partial trace/100 8.56 ± 1.4 μs 8.62 ± 1.2 μs 0.992 ± 0.21
operations/partial trace/2 0.892 ± 0.06 μs 0.902 ± 0.05 μs 0.989 ± 0.086
operations/partial trace/200 22.5 ± 3 μs 23.2 ± 3.3 μs 0.971 ± 0.19
operations/partial trace/50 4.59 ± 0.63 μs 4.58 ± 0.62 μs 1 ± 0.19
operations/tensor product/10 2.31 ± 0.38 μs 2.13 ± 0.41 μs 1.08 ± 0.27
operations/tensor product/100 0.151 ± 0.017 ms 0.148 ± 0.019 ms 1.02 ± 0.17
operations/tensor product/2 0.821 ± 0.059 μs 0.862 ± 0.06 μs 0.952 ± 0.095
operations/tensor product/200 0.817 ± 0.11 ms 0.803 ± 0.18 ms 1.02 ± 0.26
operations/tensor product/50 0.032 ± 0.0064 ms 0.0317 ± 0.0093 ms 1.01 ± 0.36
operations/unitary product/10 3.63 ± 0.29 μs 3.69 ± 0.38 μs 0.984 ± 0.13
operations/unitary product/100 0.643 ± 0.037 ms 0.639 ± 0.026 ms 1.01 ± 0.071
operations/unitary product/2 1.15 ± 0.05 μs 1.17 ± 0.051 μs 0.983 ± 0.06
operations/unitary product/200 3.4 ± 0.11 ms 3.41 ± 0.099 ms 0.997 ± 0.043
operations/unitary product/50 0.22 ± 0.016 ms 0.22 ± 0.016 ms 1 ± 0.1
time_to_load 0.214 ± 0.00094 s 0.216 ± 0.0026 s 0.991 ± 0.013
Memory benchmarks
main a9d7e54... main / a9d7e54...
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

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 74.35897% with 30 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@8a15976). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/linearcombinations.jl 74.35% 30 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #104   +/-   ##
=======================================
  Coverage        ?   96.16%           
=======================================
  Files           ?       19           
  Lines           ?     2709           
  Branches        ?        0           
=======================================
  Hits            ?     2605           
  Misses          ?      104           
  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
Contributor Author

arnavk23 commented Mar 10, 2026

@apkille whenever you are free, Andrew please take a look. Thanks!

@apkille apkille self-assigned this Mar 16, 2026
@apkille
Copy link
Member

apkille commented Mar 16, 2026

Thanks for the PR @arnavk23! And sorry for the slow response, I've been quite busy these past few months. I will do my best to review later this week.

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.

Linear combinations of Gaussian unitaries and Gaussian channels

2 participants