Skip to content

Instantly share code, notes, and snippets.

@dakk
Created July 29, 2020 10:28
Show Gist options
  • Save dakk/5578a763ce542ca5a6b4f5b486003f2b to your computer and use it in GitHub Desktop.
Save dakk/5578a763ce542ca5a6b4f5b486003f2b to your computer and use it in GitHub Desktop.
open Qiskit
(* Create the circuit *)
let qc = quantum_circuit 2 2
|> h 0
|> id 1
|> barrier
|> cx 0 1
|> barrier
|> measure 0 0
|> measure 1 1
|> draw;;
(* Start a simulation *)
Aer.get_backend "qasm_simulator"
|> execute qc
|> result
|> get_counts
|> Visualization.plot_histogram;
(* Run the circuit on real quantum hardware *)
let prov = IBMQ.enable_account "IBMQ_API_KEY" in
let j = Provider.get_backend "ibmq_london" prov |> execute qc in
Tools.Monitor.job_monitor j;
j
|> result
|> get_counts
|> Visualization.plot_histogram;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment