Run quantum circuits on Qsim GPU emulation
Qsim is a high-performance quantum circuit simulator developed by Google Quantum AI (via the QuantumLib initiative). It is designed to simulate quantum circuits on classical hardware with state-of-the-art performance, leveraging advanced techniques like gate fusion and AVX/SSE vectorization.
Scaleway QaaS allows you to scale Qsim beyond your local machine. You can execute your emulated computation on dedicated CPU or GPU (like Nvidia H100, L40S) seamlessly, benefiting from pre-configured, optimized environments.
Why use Qsim on Scaleway?
- Billed at time: The billing starting time begins only when the Platform is fully operational and the first Job can be executed.
- Multi-Framework support: Uniquely, our Qsim platforms are accessible via both Cirq (Google's native SDK) and Qiskit. You can choose your preferred language while benefiting from the Qsim engine.
- Extreme performance: Qsim is optimized for simulating intermediate-scale quantum circuits. When coupled with Scaleway's high-end GPUs, it drastically reduces execution time for deep circuits.
- Smart compression: Just like our Aer offerings, the platform automatically compresses circuit data and computation results to optimize network throughput and latency.
How to access via Cirq (Native)
Cirq is the native language of Qsim. Using the cirq-scaleway adapter allows you to run your Google Cirq circuits directly on our cloud GPUs.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account with a valid Project ID
- A Scaleway API Key (Secret Key)
- Python and
cirqinstalled on your local machine
-
Install the
cirq-scalewayprovider. Refer to the Cirq Scaleway GitHub repository for more information.pip install cirq-scaleway -
Create a file with the following computation script. Replace
$SCW_PROJECT_IDand$SCW_SECRET_KEYwith your Scaleway Project ID and secret key.import cirq from cirq_scaleway import ScalewayQuantumService # 1. Initialize the Provider service = ScalewayQuantumService( project_id="<$SCW_PROJECT_ID>", secret_key="<$SCW_SECRET_KEY>" ) # 2. Get the Qsim platform qsim_platform = service.device(name="EMU-QSIM-H100") # 3. Create a Circuit (e.g., Bell State) # and run in on your dedicated Qsim Session with qsim_simulator.create_session() as session: qubit = cirq.GridQubit(0, 0) circuit = cirq.Circuit(cirq.X(qubit) ** 0.5, cirq.measure(qubit, key='m')) result = session.run(circuit) print("Result:", result) -
Save the script. In this example we save it as
cirq.py. -
Run the script.
python ~/cirq.py
How to access via Qiskit
Before you start
To complete the actions presented below, you must have:
- A Scaleway account with a valid Project ID.
- A Scaleway API Key (Secret Key).
- Python and
qiskitinstalled on your local machine
-
Install the
qiskit-scalewayprovider. Refer to the Qiskit Scaleway GitHub repository for more information.pip install qiskit-scaleway -
Create a file with the following computation script. Replace
$SCW_PROJECT_IDand$SCW_SECRET_KEYwith your Scaleway Project ID and secret key.from qiskit import QuantumCircuit from qiskit_scaleway import ScalewayProvider # 1. Initialize Provider provider = ScalewayProvider( project_id="$SCW_PROJECT_ID", secret_key="$SCW_SECRET_KEY" ) # 2. Select the Qsim Backend # Scaleway bridges the Qiskit circuit to the Qsim engine automatically backend = provider.get_backend("EMU-QSIM-H100") # 3. Create & Run Circuit qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc.measure_all() job = backend.run(qc, shots=1000) print("Counts:", job.result().get_counts()) -
Save the script. In this example we save it as
computation.py. -
Run the script.
python ~/computation.py