Code Monkey home page Code Monkey logo

euriqa-api's Introduction

EURIQA API Guide

This guides provides the minimal info for external users to use the EURIQA-blue API correctly.

EURIQA provides the API interface which submits a list of circuits and collect the list of probabiilty histograms: prob_vector = run_on_EURIQA(circuits, num_shots). More inforamtion returns is possible but needs to coordinate with the experiment operator in advance.

For the purpose of code development, one can use the following example. Please refer to the euriqa_interface.py for the docstrings of run_on_EURIQA for any input/output format issue.

import qiskit
import numpy as np
from euriqa_interface import run_on_EURIQA


qc0 = qiskit.QuantumCircuit(2)
qc0.rxx(np.pi/2,0,1)

qc1 = qc0.copy()
qc1.rx(np.pi/2,0)

qasm_circuits = [c.qasm() for c in  [qc0, qc1]]


# Do necessary preprocessing including basis transformation to generate list of circuits in OpenQASM2.0 string format.
# For local test (returns exact simulation prob result):
probs_local = run_on_EURIQA(qasm_circuits,num_shots=100, run_simulation_local=True)
# For actual experiment (this shows what it looks like to experimentalists, api calls to the actual machine is only accessable to EURIQA internal computers):
# probs_exp = run_on_EURIQA(qasm_circuits,num_shots=100)

print(probs_local)
# Then do post-processing using probs

Expected output:

[array([0.5, 0. , 0. , 0.5]), array([0.25, 0.25, 0.25, 0.25])]

!!! It is highly recommended provide version info on key modules or requiremnets.txt to best reproduce the working enviroment.

More on qasm string

Euriqa runs on an older version of qiskit might not recognize the qasm string generated from newer version of qiskit even if both of them are OpenQASM2.0. In order to test if your qasm string works on the eurqia system, please test your qasm strings with correct qiskit version. The following is recommended procedure.

1. Generate qasm string with the working code (which presumebaly uses the newer version of qiskit) and save it locally and save the probability histogram vector for later comparison.

Below is the example for generating and saving the qasm string.

qc0.remove_final_measurements()
with open(path+'/qc0.qasm','w') as f:
    f.write(qc0.qasm())

Depending on your qiksit version, you can generate exact probability histogram using abs(qiskit.quantum_info.Statevector(cq).data)**2 or abs(qiskit.quantum_info.Statevector.from_instruction(cq))**2 for newer and older qiskit version repectively. Then you can save the result locally for later comparison.

2. Create a fresh virtual env and install the specific qiskit version use the following:

pip install qiskit-terra==0.16.1

so that the version result of qiskit.__qiskit_version__ is: {'qiskit-terra': '0.16.1', 'qiskit-aer': None, 'qiskit-ignis': None, 'qiskit-ibmq-provider': None, 'qiskit-aqua': None, 'qiskit': None}. Also the numpy version is 0.18.1.

3. Source the new virtual env and try to load the new qasm circuit and compare the probability histogram

Comparing the probability histogram generated with your version of qiskit and older version (0.18.1) of qiskit to make sure they result in the same probability histogram.

euriqa-api's People

Contributors

kee-wang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.