Comments (4)
To clarify: the issue in the original code was that the options
dict was passed to the QSimOptions
constructor, which only accepts individual option values, not a dict.
The solution above will work; alternatively, you can pass the {string: value} input format referenced in the docstring to QSimSimulator
directly:
options = {"f": 4, "g": True, "gmode": 1}
sim = qsimcirq.QSimSimulator(options)
from cuquantum.
The code, as posted:
import cirq
import qsimcirq
from cirq.contrib import quantum_volume
options = {"f": 4, "g": True, "gmode": 1}
gpu_options = qsimcirq.QSimOptions(options)
sim = qsimcirq.QSimSimulator(gpu_options)
def qv_circuit_cirq(depth, num_qubits, seed=None):
if seed is not None:
state = np.random.RandomState(int(seed, 2))
else:
state=None
return quantum_volume.generate_model_circuit(num_qubits, depth, random_state=state)
qc = qv_circuit_cirq(9, num_qubits=3)
print(sim.simulate(program=qc).final_state_vector)
will not work. It produces this error on cuQuantum Appliance version 23.03:
Traceback (most recent call last):
File "test3.py", line 17, in <module>
print(sim.simulate(program=qc).final_state_vector)
File "/home/cuquantum/conda/envs/cuquantum-23.03/lib/python3.8/site-packages/cirq/sim/simulator.py", line 495, in simulate
return self.simulate_sweep(
File "/home/cuquantum/conda/envs/cuquantum-23.03/lib/python3.8/site-packages/cirq/sim/simulator.py", line 510, in simulate_sweep
return list(self.simulate_sweep_iter(program, params, qubit_order, initial_state))
File "/home/cuquantum/conda/envs/cuquantum-23.03/lib/python3.8/site-packages/qsimcirq/qsim_simulator.py", line 620, in simulate_sweep_iter
qsim_state = fullstate_simulator_fn(options, initial_state)
RuntimeError: Unable to cast Python instance to C++ type (compile in debug mode for details)
To avoid this error, you must declare the simulator and use it as follows:
import cirq
import qsimcirq
from cirq.contrib import quantum_volume
options = qsimcirq.QSimOptions(
max_fused_gate_size=4,
disable_gpu=False,
gpu_mode=(0,) # change to (0,1,...) for multiple GPUs
)
simulator = qsimcirq.QSimSimulator(qsim_options=options)
def qv_circuit_cirq(depth, num_qubits, seed=None):
if seed is not None:
state = np.random.RandomState(int(seed, 2))
else:
state=None
return quantum_volume.generate_model_circuit(num_qubits, depth, random_state=state)
qc = qv_circuit_cirq(9, num_qubits=3)
result = simulator.simulate(qc)
print(result.state_vector()) # result.final_state_vector also works
We document this here.
If there is any confusion, please let us know.
from cuquantum.
@95-martin-orion thanks. Yes. We added additional GPU modes in the cuQuantum Appliance.
I wanted to clarify how to utilize the multi-GPU backend in the aforementioned case.
from cuquantum.
Marking this issue addressed.
from cuquantum.
Related Issues (20)
- Multithreaded cutn optimization issue HOT 1
- Disable slicing fails
- Releasing `qsim_mgpu` source on GitHub instead of only binaries the Docker container HOT 2
- cuQuantum MPS Simulator vs Qiskit Aer HOT 3
- gpu issue on qiskit - aer method , docker - cuquantum-appliance:23.10 HOT 1
- Website is down HOT 3
- Functions for arithmetic operations of two tensor networks HOT 3
- `cudaq` never giving correct result for `maxcut` QAOA problem. HOT 3
- `state_compute()` leading to kernel dying.
- Wrong sign in a single-gate-circuit statevector? HOT 3
- Sudo permission issue for cuquantum-appliance:23.10 container HOT 7
- 3XTF32 issue with the most recent cuquantum HOT 2
- Can't run pennyLane benchmarks in 23.10 cuQuantum Appliance HOT 8
- The output of apply_matrix_batched in cuQuantum Python is same as input HOT 4
- Small typo in README HOT 1
- Mid-circuit measurements cause significant slowdown HOT 3
- Unable to run cuqauntum in GH200 (grace hopper nvidia) docker arm64 HOT 3
- Support CUDA-Q kernels for CircuitToEinsum HOT 4
- Request for releasing a new version of cuQuantum Appliance HOT 4
- `CircuitToEinsum` fails for some qiskit `QuantumCircuit` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuquantum.