cuda-quantum
cuda-quantum copied to clipboard
[RFC] Python frontend for photonic simulator
Required prerequisites
- [X] Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.
Describe the feature
-
Add support to use the photonics simulator with
photonics-cpu
target from Python frontend of CUDA-Q -
Proposed API
-
Gates (same as those supported on C++ frontend):
-
plus(q: qudit) -> None
, -
phase_shift(q: qudit, phi: float) -> None
, -
beam_splitter(q: qudit, r: qudit, theta: float) -> None
, -
mz(q: qudit) -> int
andmz(q: list[qudit]) -> list[int]
-
-
Handler is inferred from the target
-
Custom handler must provide API for defining a
qudit
of level = N, for example,qudit(3)
-
APIs
- Synchronous sampling:
cudaq.sample(*args, **kwargs)
- State retrieval:
cudaq.get_state(*args, **kwargs)
- Synchronous sampling:
-
-
Example
import cudaq
cudaq.set_target("photonics-cpu")
@cudaq.kernel
def photonicsKernel():
qutrits = [qudit(3) for i in range(2)]
plus(qutrits[0])
plus(qutrits[1])
plus(qutrits[1])
mz(qutrits)
counts = cudaq.sample(photonicsKernel)
print(counts)
state = cudaq.get_state(photonicsKernel)
print(state)