QUANTUM CODES
Some basic quantum computing codes using Qiskit
#1 Quantum Circuit
#2 Statevector
#3 State City
#4 Probability
#5 Histogram
#6 SamplerV2
#7 IBM Runtime
#8 Teleportation
#9 Grover's Algorithm
#0 Define Functions
Crafted by Mirza Nur Hidayat
Ref. IBM Qiskit
#7 IBM Runtime
from qiskit import QuantumCircuit from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2 as Sampler from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager service = QiskitRuntimeService(channel="ibm_quantum", token="your_IBM_account") qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc.measure_all() backend = service.least_busy(operational=True, simulator=False) pm = generate_preset_pass_manager(backend=backend, optimization_level=1) isa_circuit = pm.run(qc) sampler = Sampler(mode=backend) sampler.options.default_shots = 100000 job = sampler.run([isa_circuit]) pub_result = job.result()[0] print(f"Counts for the meas output register: {pub_result.data.meas.get_counts()}")