-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CoinToss simulator implemented. * Replaced the old CuStateVec simulator (C API) with a version using the Python API. * Updated README with installation instructions for CuStateVec. --------- Co-authored-by: PabloAndresCQ <[email protected]> Co-authored-by: Kartik Singhal <[email protected]>
- Loading branch information
1 parent
e7e4154
commit cec47a4
Showing
60 changed files
with
1,474 additions
and
3,617 deletions.
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
25 changes: 13 additions & 12 deletions
25
...s/cuquantum/cuquantum_wrapper/__init__.py → python/pecos/simulators/cointoss/__init__.py
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# Copyright 2023 The PECOS Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
# the License.You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
# Initial author: Tyson Lawrence | ||
# Copyright 2023 The PECOS Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
# the License.You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
from pecos.simulators.cointoss import bindings | ||
from pecos.simulators.cointoss.state import CoinToss |
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,53 @@ | ||
# Copyright 2023 The PECOS Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
# the License.You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
from pecos.simulators.cointoss.gates import ignore_gate, measure | ||
|
||
# Supporting gates from table: | ||
# https://github.com/CQCL/phir/blob/main/spec.md#table-ii---quantum-operations | ||
|
||
gate_dict = { | ||
"Init": ignore_gate, | ||
"Measure": measure, | ||
"I": ignore_gate, | ||
"X": ignore_gate, | ||
"Y": ignore_gate, | ||
"Z": ignore_gate, | ||
"RX": ignore_gate, | ||
"RY": ignore_gate, | ||
"RZ": ignore_gate, | ||
"R1XY": ignore_gate, | ||
"SX": ignore_gate, | ||
"SXdg": ignore_gate, | ||
"SY": ignore_gate, | ||
"SYdg": ignore_gate, | ||
"SZ": ignore_gate, | ||
"SZdg": ignore_gate, | ||
"H": ignore_gate, | ||
"F": ignore_gate, | ||
"Fdg": ignore_gate, | ||
"T": ignore_gate, | ||
"Tdg": ignore_gate, | ||
"CX": ignore_gate, | ||
"CY": ignore_gate, | ||
"CZ": ignore_gate, | ||
"RXX": ignore_gate, | ||
"RYY": ignore_gate, | ||
"RZZ": ignore_gate, | ||
"R2XXYYZZ": ignore_gate, | ||
"SXX": ignore_gate, | ||
"SXXdg": ignore_gate, | ||
"SYY": ignore_gate, | ||
"SYYdg": ignore_gate, | ||
"SZZ": ignore_gate, | ||
"SZZdg": ignore_gate, | ||
"SWAP": ignore_gate, | ||
} |
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,41 @@ | ||
# Copyright 2023 The PECOS Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
# the License.You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
from typing import Any | ||
|
||
import numpy as np | ||
|
||
|
||
def ignore_gate(state, qubits: int, **params: Any) -> None: | ||
""" | ||
Ignore the gate. | ||
Args: | ||
state: An instance of ``CoinToss``. | ||
qubits: The qubits the gate was applied to. | ||
Returns: | ||
""" | ||
|
||
|
||
def measure(state, qubits: int, **params: Any): | ||
""" | ||
Return |1> with probability ``state.prob`` or |0> otherwise. | ||
Args: | ||
state: An instance of ``CoinToss``. | ||
qubit: The qubit the measurement is applied to. | ||
Returns: | ||
""" | ||
return 1 if np.random.random() < state.prob else 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2023 The PECOS Developers | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
# the License.You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
|
||
import random | ||
|
||
from pecos.simulators.cointoss import bindings | ||
from pecos.simulators.parent_sim_classes import Simulator | ||
|
||
|
||
class CoinToss(Simulator): | ||
""" | ||
Ignore all quantum operations and toss a coin to decide measurement outcomes. | ||
Meant for stochastical debugging of the classical branches. | ||
""" | ||
|
||
def __init__(self, num_qubits, prob=0.5, seed=None): | ||
""" | ||
Initialization is trivial, since there is no state. | ||
Args: | ||
num_qubits (int): Number of qubits being represented. | ||
prob (float): Probability of measurements returning |1>. | ||
Default value is 0.5. | ||
seed (int): Seed for randomness. | ||
Returns: | ||
""" | ||
|
||
if not isinstance(num_qubits, int): | ||
msg = "``num_qubits`` should be of type ``int``." | ||
raise TypeError(msg) | ||
if not (prob >= 0 and prob <= 1): | ||
msg = "``prob`` should be a real number in [0,1]." | ||
raise ValueError(msg) | ||
random.seed(seed) | ||
|
||
super().__init__() | ||
|
||
self.bindings = bindings.gate_dict | ||
self.num_qubits = num_qubits | ||
self.prob = prob |
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
python/pecos/simulators/cuquantum/cuquantum_wrapper/.gitignore
This file was deleted.
Oops, something went wrong.
114 changes: 0 additions & 114 deletions
114
python/pecos/simulators/cuquantum/cuquantum_wrapper/CMakeLists.txt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.