QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
918 stars 119 forks source link

More work on basic error channels #455

Closed jlbosse closed 1 year ago

jlbosse commented 1 year ago

Continuation of #416 with added documentation, tests and single and two-qubit depolarizing channels as well as getting up to date with master.

codecov[bot] commented 1 year ago

Codecov Report

Base: 88.27% // Head: 88.19% // Decreases project coverage by -0.08% :warning:

Coverage data is based on head (933fc78) compared to base (addf1df). Patch coverage: 80.00% of modified lines in pull request are covered.

:exclamation: Current head 933fc78 differs from pull request most recent head 39d3da8. Consider uploading reports for the commit 39d3da8 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #455 +/- ## ========================================== - Coverage 88.27% 88.19% -0.08% ========================================== Files 76 77 +1 Lines 4766 4813 +47 ========================================== + Hits 4207 4245 +38 - Misses 559 568 +9 ``` | [Impacted Files](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS) | Coverage Δ | | |---|---|---| | [lib/YaoBlocks/src/YaoBlocks.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0Jsb2Nrcy9zcmMvWWFvQmxvY2tzLmps) | `100.00% <ø> (ø)` | | | [lib/YaoBlocks/src/channel/unitary\_channel.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0Jsb2Nrcy9zcmMvY2hhbm5lbC91bml0YXJ5X2NoYW5uZWwuamw=) | `90.00% <0.00%> (ø)` | | | [lib/YaoBlocks/src/composite/composite.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0Jsb2Nrcy9zcmMvY29tcG9zaXRlL2NvbXBvc2l0ZS5qbA==) | `75.00% <ø> (ø)` | | | [lib/YaoArrayRegister/src/density\_matrix.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0FycmF5UmVnaXN0ZXIvc3JjL2RlbnNpdHlfbWF0cml4Lmps) | `93.33% <77.77%> (-5.16%)` | :arrow_down: | | [lib/YaoBlocks/src/channel/error\_channel.jl](https://codecov.io/gh/QuantumBFS/Yao.jl/pull/455?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS#diff-bGliL1lhb0Jsb2Nrcy9zcmMvY2hhbm5lbC9lcnJvcl9jaGFubmVsLmps) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=QuantumBFS)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

jlbosse commented 1 year ago

Before this gets merged, I was wondering if it might make more sense to define the different error channels without wrapping the unitaries in PutBlocks. This allows to wrap the output of bit_flip_channel in a PutBlock or KronBlock and have the same error channel act on many different locations in the circuit. So do

function bit_flip_channel(p)
    return unitary_channel([igate(1), X], [1-p, p])
end

instead of

function bit_flip_channel(n::Int, loc::Int; p::Real)
    return UnitaryChannel([igate(n), put(n, loc=>X)], [p, 1-p])
end
jlbosse commented 1 year ago

The CI failure seems unrelated to me and locally compiled docs also look good. So I think this is ready for a review @Roger-luo or @GiggleLiu !

jlbosse commented 1 year ago

I moved DensityMatrix back into YaoAPI and I think all other comments were also addressed. Please let me know if there is anything else that needs to be done, before this can get merged.

Roger-luo commented 1 year ago

@jlbosse great work! thanks!