<jupyter_start><jupyter_text>C3 Simulator as a backend for Qiskit Experiments This notebook demonstrates the use of the C3 Simulator with a high-level quantum programming framework [Qiskit](https://www.qiskit.org). You must additionally install qiskit and matplotlib to run this example.<jupyter_code>!pip install -q qiskit==0.23.6 matplotlib==3.3.4
from c3.qiskit import C3Provider
from qiskit import transpile, execute, QuantumCircuit, Aer
from qiskit.tools.visualization import plot_histogram, plot_state_city<jupyter_output><empty_output><jupyter_text>Define a basic Quantum circuit<jupyter_code>qc = QuantumCircuit(6, 6)
qc.x(0)
qc.z(0)
qc.cx(0,1)
qc.x(0)
qc.z(2)
qc.x(2)
qc.y(3)
qc.cx(3, 4)
qc.cx(4, 5)
qc.measure([0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5])
qc.draw()<jupyter_output><empty_output><jupyter_text>Get the C3 Provider and Backend<jupyter_code>c3_provider = C3Provider()
c3_backend = c3_provider.get_backend("c3_qasm_perfect_simulator")
config = c3_backend.configuration()

print("Name: {0}".format(config.backend_name))
print("Version: {0}".format(config.backend_version))
print("Max Qubits: {0}".format(config.n_qubits))
print("OpenPulse Support: {0}".format(config.open_pulse))
print("Basis Gates: {0}".format(config.basis_gates))<jupyter_output>Name: c3_qasm_perfect_simulator
Version: 0.1
Max Qubits: 20
OpenPulse Support: False
Basis Gates: ['cx', 'cy', 'cz', 'iSwap', 'id', 'x', 'y', 'z']<jupyter_text>Let's view how the Qiskit Transpiler will convert the circuit<jupyter_code>trans_qc = transpile(qc, c3_backend)
trans_qc.draw()<jupyter_output><empty_output><jupyter_text>Run an ideal device simulation using C3<jupyter_code>c3_backend.set_device_config("quickstart.hjson")
c3_job = execute(qc, c3_backend, shots=1000)
result = c3_job.result()
res_counts = result.get_counts(qc)
print(res_counts)
plot_histogram(res_counts, title='C3 Perfect Devices simulation')<jupyter_output><empty_output><jupyter_text>Run Simulation and verify results on Qiskit simulator<jupyter_code>qiskit_simulator = Aer.get_backend('qasm_simulator')
qiskit_result = execute(qc, qiskit_simulator, shots=1000).result()
counts = qiskit_result.get_counts(qc)
plot_histogram(counts, title='Qiskit simulation')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13082437275985664, 'fraction_numerical': 0.030913978494623656, 'mean_word_length': 8.502127659574468, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '163515', 'license': 'Apache-2.0', 'n_tokens_mistral': 917, 'n_tokens_neox': 850, 'n_words': 176, 'path': 'examples/c3_qiskit.ipynb', 'repo_name': 'flo-maier/c3', 'size': '2232'}