-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Photonics get_state
#2243
Closed
Closed
Fix Photonics get_state
#2243
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
bac044c
Initial move to nvqir
Omar-ORCA cf5ce62
refactor
Omar-ORCA ce48351
Divide em and simulator
Omar-ORCA 081fb31
First working version
Omar-ORCA 54376f8
Fixed get_state c++
Omar-ORCA c9071da
Fix Python bindings
Omar-ORCA af95e79
Change executable name in photonics_tbi_get_state.spp
Omar-ORCA 12c53a8
Revert "Add Clifford-only simulator (Stim) (#2193)" (#2206)
bmhowe23 b1f5b92
Add missing optimizations for translation to openqasm2 (#2197)
annagrin cc1acc1
Add `dep-analysis` pass (a.k.a. `features/qubit-mgmt`) (#2163)
bmhowe23 50850b2
Fix argument conversion issues (#2211)
annagrin 027a5ee
Update simulators.rst (#2208)
mmvandieren e2fdbbd
Allow state synthesis for remote simulators (#2212)
annagrin ea19347
Fix flaky tests (#2221)
annagrin f6758b7
Disable tests using new argument synthesis for NVQC (#2224)
annagrin 7c661ce
[Python] [photonics] Enable 'get_state' API (#2201)
khalatepradnya 2a43052
fixing path to conda.io python env (#2230)
sacpis d005f25
Publishing pipeline fixes after PR#2201 (#2229)
khalatepradnya 75675d8
Fix exp_pauli issues on remote simulators and quantum devices (#2226)
annagrin 7554a3d
Noise model enhancements (#2168)
1tnguyen e2eca68
[core] Separate compilation, supporting C++ host side function refere…
schweitzpgi f57cc30
Use the standard C++ file banner. (#2234)
schweitzpgi c01d227
Add Clifford-only simulator (Stim) (#2235)
bmhowe23 adf22b0
[custom op] Two-qubit operation synthesis (#2217)
khalatepradnya b8ad51a
[C++ bridge] Add support for std::vector::data method. (#2241)
schweitzpgi c326a85
Python formatting
Omar-ORCA 2b4aa48
Revert "Python formatting" since it it inconsistent with other files.
khalatepradnya 898004c
* Code formatting
khalatepradnya f29897d
* Consistent 'compile and run' comment
khalatepradnya aab9d6f
* No banner in examples
khalatepradnya 36de665
Fix having more than one `sample` or `get_state` operation in a script
Omar-ORCA 8c2dbdb
Use the = <init-expr>; style for photonics examples
Omar-ORCA 4c8b510
Reformat a comment. (#2239)
schweitzpgi e834fcf
Update NVQC testing deployment spec (#2248)
bmhowe23 37b428b
Renaming qkernel_ref to qkernel per the spec. (#2253)
schweitzpgi 366ed1e
* Fix 2 out of 3 build errors.
khalatepradnya b5e63e8
[C++ bridge] Add support for move constructor of std::vector. (#2236)
schweitzpgi 41cc17e
clarifying the document text (#2247)
sacpis 97d5f3b
updating spec (#2255)
sacpis f1cd9fc
Fix PhotonicsTester
Omar-ORCA bbbb919
Formatting
Omar-ORCA 5dfa62b
Add enumerated noise_model_type to noise interface (#2200)
bmhowe23 5a91961
ORCA asynchronous sampling (#2205)
Omar-ORCA b5ad42a
Fix clang build
Omar-ORCA d4a83f8
Allow controlled Z gates for profile-specific QIR (#2245)
bmhowe23 fe2ab46
[core] Add quantum reference product type (#2254)
schweitzpgi b80fb40
* Restore the configuration for execution manager in the photnic
khalatepradnya 095d2dd
* Restore unedited file.
khalatepradnya 4e78361
* Doxygen fix
khalatepradnya a3f5c7d
Remove set_photonic_random_seed
Omar-ORCA 32b3c6f
Return 0 from main in examples
Omar-ORCA d6947ea
Add multi-QPU support for the 'orca' target (#2260)
khalatepradnya fe423bf
* Code formatting
khalatepradnya 2770546
* Addressing review comment - use `cudaq::linspace` API in C++ examples
khalatepradnya 2595c17
* Addressing review comment - use `cudaq::linspace` API in C++ examples;
khalatepradnya 2fba5ca
* Addressing review comment - remove superfluous 'else' after 'return'
khalatepradnya 38510d5
Random walk phase estimation example in Python #1579 (#2060)
Gaurang-Belekar 6eb87a4
Fixes a bug with separate compilation. (#2264)
schweitzpgi 6eda1f0
Added new gates
Omar-ORCA b836772
Use the same parameters in the examples
Omar-ORCA fdcf7e9
Document photonics operations
Omar-ORCA 492e995
Fix photonics_tbi_get_state.py
Omar-ORCA 6fc6258
DCO Remediation Commit for Pradnya Khalate <148914294+khalatepradnya@…
khalatepradnya e77b172
DCO Remediation Commit for Ben Howe <[email protected]…
khalatepradnya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -638,31 +638,67 @@ operations, each operating on 2 qubits. | |
Photonic Operations on Qudits | ||
============================= | ||
|
||
These operations are valid only on the `photonics` target which does not support the quantum operations above. | ||
These operations are valid only on the `photonics-cpu` target which does not support | ||
the quantum operations above. | ||
|
||
:code:`plus` | ||
:code:`create` | ||
--------------------- | ||
|
||
This is a place-holder, to be updated later. | ||
This operation increments the number of photons in a qumode up to a maximum value | ||
defined by the qudit level that represents the qumode. If it is applied to a qumode | ||
where the number of photons is already at the maximum value, the operation has no | ||
effect. | ||
|
||
:math:`U|0\rangle → |1\rangle, U|1\rangle → |2\rangle, U|2\rangle → |3\rangle, \cdots, U|d\rangle → |d\rangle` | ||
where :math:`d` is the qudit level. | ||
|
||
.. tab:: Python | ||
|
||
.. code-block:: python | ||
|
||
q = qudit(3) | ||
plus(q) | ||
create(q) | ||
|
||
.. tab:: C++ | ||
|
||
.. code-block:: cpp | ||
|
||
cudaq::qvector<3> q(1); | ||
plus(q[0]); | ||
create(q[0]); | ||
|
||
:code:`annihilate` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
--------------------- | ||
|
||
This operation reduces the number of photons in a qumode up to a minimum value of | ||
0 representing the vacuum state. If it is applied to a qumode where the number of | ||
photons is already at the minimum value 0, the operation has no effect. | ||
|
||
:math:`U|0\rangle → |0\rangle, U|1\rangle → |0\rangle, U|2\rangle → |1\rangle, \cdots, U|d\rangle → |d-1\rangle` | ||
where :math:`d` is the qudit level. | ||
|
||
.. tab:: Python | ||
|
||
.. code-block:: python | ||
|
||
q = qudit(3) | ||
annihilate(q) | ||
|
||
.. tab:: C++ | ||
|
||
.. code-block:: cpp | ||
|
||
cudaq::qvector<3> q(1); | ||
annihilate(q[0]); | ||
|
||
:code:`phase_shift` | ||
--------------------- | ||
|
||
This is a place-holder, to be updated later. | ||
A phase shifter adds a phase :math:`\phi` on a qumode. For the annihilation (:math:`a_1`) | ||
and creation operators (:math:`a_1^\dagger`) of a qumode, the phase shift operator | ||
is defined by | ||
|
||
.. math:: | ||
P(\phi) = \exp\left(i \phi a_1^\dagger a_1 \right) | ||
|
||
.. tab:: Python | ||
|
||
|
@@ -681,7 +717,13 @@ This is a place-holder, to be updated later. | |
:code:`beam_splitter` | ||
--------------------- | ||
|
||
This is a place-holder, to be updated later. | ||
Beam splitters act on two qumodes together and it is parametrized by a single angle | ||
:math:`\theta`, relating to reflectivity. | ||
For the annihilation (:math:`a_1` and :math:`a_2`) and creation operators (:math:`a_1^\dagger` | ||
and :math:`a_2^\dagger`) of two qumodes, the beam splitter operator is defined by | ||
|
||
.. math:: | ||
B(\theta) = \exp\left[i \theta (a_1^\dagger a_2 + a_1 a_2^\dagger) \right] | ||
|
||
.. tab:: Python | ||
|
||
|
@@ -700,19 +742,19 @@ This is a place-holder, to be updated later. | |
:code:`mz` | ||
--------------------- | ||
|
||
This operation returns the measurement results of the input qudit(s). | ||
This operation returns the measurement results of the input qumode(s). | ||
|
||
.. tab:: Python | ||
|
||
.. code-block:: python | ||
|
||
qutrits = [qudit(3) for _ in range(2)] | ||
mz(qutrits) | ||
qumodes = [qudit(3) for _ in range(2)] | ||
mz(qumodes) | ||
|
||
|
||
.. tab:: C++ | ||
|
||
.. code-block:: cpp | ||
|
||
cudaq::qvector<3> qutrits(2); | ||
mz(qutrits); | ||
cudaq::qvector<3> qumodes(2); | ||
mz(qumodes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Compile and run with: | ||
// ``` | ||
// nvq++ noise_callback.cpp --target density-matrix-cpu -o dyn.x | ||
// && ./dyn.x | ||
// ``` | ||
// | ||
// Note: You must set the target to a density matrix backend for the noise | ||
// to successfully impact the system. | ||
|
||
#include <cudaq.h> | ||
#include <iostream> | ||
|
||
// CUDA-Q supports several different models of noise. In this | ||
// case, we will examine the dynamic noise channel specified as a callback | ||
// function. | ||
|
||
int main() { | ||
|
||
// We will begin by defining an empty noise model that we will add | ||
// our channel to. | ||
cudaq::noise_model noise; | ||
// Noise model callback function | ||
const auto rx_noise = [](const auto &qubits, | ||
const auto ¶ms) -> cudaq::kraus_channel { | ||
// Model a pulse-length based rotation gate: | ||
// the bigger the angle, the longer the pulse, i.e., more amplitude damping. | ||
auto angle = params[0]; | ||
// Normalize the angle into the [0, 2*pi] range | ||
while (angle > 2. * M_PI) | ||
angle -= 2. * M_PI; | ||
|
||
while (angle < 0) | ||
angle += 2. * M_PI; | ||
// Damping rate is linearly proportional to the angle | ||
const auto damping_rate = angle / (2. * M_PI); | ||
std::cout << "Angle = " << params[0] | ||
<< ", amplitude damping rate = " << damping_rate << "\n"; | ||
return cudaq::amplitude_damping_channel(damping_rate); | ||
}; | ||
|
||
// Bind the noise model callback function to the `rx` gate | ||
noise.add_channel<cudaq::types::rx>(rx_noise); | ||
|
||
auto kernel = [](double angle) __qpu__ { | ||
cudaq::qubit q; | ||
rx(angle, q); | ||
mz(q); | ||
}; | ||
|
||
// Now let's set the noise and we're ready to run the simulation! | ||
cudaq::set_noise(noise); | ||
|
||
// Our results should show measurements in both the |0> and |1> states, | ||
// indicating that the noise has successfully impacted the system. Note: a | ||
// `rx(pi)` is equivalent to a Pauli X gate, and thus, it should be in the |1> | ||
// state if no noise is present. | ||
auto noisy_counts = cudaq::sample(kernel, M_PI); | ||
std::cout << "Noisy result:\n"; | ||
noisy_counts.dump(); | ||
|
||
// To confirm this, we can run the simulation again without noise. | ||
cudaq::unset_noise(); | ||
auto noiseless_counts = cudaq::sample(kernel, M_PI); | ||
std::cout << "Noiseless result:\n"; | ||
noiseless_counts.dump(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Is this a new gate? or an alias for 'plus'? Doesn't match the examples and API spec...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new gate replacing the
plus
that can be deprecated, the behaviour of theplus
gate is not very intuitive (cycling through the number of photons).