Giter Site home page Giter Site logo

q-kernel-ops's People

Contributors

cfilleke avatar dependabot[bot] avatar mickahell avatar travis-s-ibm avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

q-kernel-ops's Issues

Timeout Workflow

Resume

  • Putting a timeout of 30 min for Tests wf and Qiskit wf
  • Putting a 2h timeout for Gen metadata wf

Github Actions

Resume

  • Unit test launch
  • Syntax
  • Style
  • Qiskit version update

EPIC #5

Study Matrix completion

Experiments

Package who can help : Chordal Matrix Package

    • Create full matrix completion reutilizable code
    • Add quantum kernel data inputs
  • Fix a size as N' = N + n (ie. N = 6, n = 3)

    • Look at the effect of changing unknown (n) entries, can be overlapping u or ...
  • For each u look at time to solution

    • What is look likes ?
    • What is the accuracy ?
  • For time to solution, look at regime where

    • What is TTS vs N' ?

EPIC #5

Runtime limitation

Practical limitation of Qiskit Runtime

Questions

  • How much data can we put into the runtime during an invocation of a Runtime program ?
  • How fast does the Runtime operate ? Where are the latencies in its execution ?
  • What is the impact of charging the number qubits or the circuit depth ?
  • What others metrics info can Runtime give us ?
  • implementing time function (use qiskit job status to cheat and have a detail for each step)

Info

  • Each kernel entry requires 1 circuit, number of circuits per payload tells us how many entries we can calculate in 1 go
  • May want to use circuit runner program, as it gives us more API options to use

EPIC #5

Organize codebase

Organization of the codebase

I suggest, we organize our codebase to be full compliant with the Qiskit Ecosystem.

Standalone programs & Workflow

For the sources of our final program, I think we can write it as standalone programs, that way we can use it as API and call only the matrix completion or only the quantum kernel program or both like in our workflow.

Meaning

Simple program controlling by a CLI (commands line interface) using the lib fire.
So each standalone program take an input and deliver an output.

That'll really simplify our workflow as we will only need to add an endpoint calling first the QK endpoint and then the matrix cmpl endpoint.

Design

  • qkernel endpoint : call q kernel standalone program
  • matrix_cmpl endpoint : call matrix standalone program
  • workflow endpoint : call qkernel endpoint and then matrix cmpl endpoint

Tests & automation

  • For the tests, using the simple unittest from python lib.
  • For the code syntax, using pylint
  • For code style, using black

For controlling the execution of these, using tox
Launching everything at each commit from the GitHub Actions, and blocking the merge of PR if some don't pass.

Resources files

For the resources files, I suggest totally make the generalization of the data files from GitHub actions. Only means having a simple calling script with some options for each kind of data.

Splitting case

For the case of generating metadata from Quantum kernel (issue #4), we can split the scripts by :

  • circuit_##.py
  • launching.py

So, we call the circuit_##.py script with bunch of options (shots, seeds, layers, ...), its will call the launching.py script giving him our options and from that its will make the execution and generate the metadata file of that circuit called.
In definitive, we will have one file by circuit whose always calling the launching.py in order to not duplicate code.

Studies files

I suggest putting every jupyter notebook we wrote for our studies in the repo folder studies whom is not inside the source code and not tested at all.

Folders orga

  • /
  • .github/ --> (the whole bunch of files to make the CI/CD)
  • src/
    • manager.py (endpoint controler)
    • programs/
      • qkernel.py
      • matrix_cmpl.py
  • tests/
  • resources/
    • kernel_metadata/
      • each metadata file from #4
    • matrix/
      • matrix data file from #6
    • scripts/
      • scripts to generate each data (kernel metadata and matrix)
  • studies/
    • bunch of jupyter notebook
  • tox.ini
  • manager.py (api controler)
  • requirements.txt
  • setup.py (stuff for metadata)
  • setup.cfg (stuff for metadata)
  • .gitignore
  • README.md

EPIC #5

Study Quantum kernel

Copy form #3 (comment)


Cross-posting from Slack & expanding.

To build up a quantum kernel matrix, we're going to need to use some parameterized quantum circuits (PQCs).
A good way to do this is using the Qiskit Circuit Library, especially the TwoLocal circuit

In our study, we used a variety of circuits from this paper ("Sim et al.). For this work, we don't have to do that. I would suggest the following circuits from the SIm et al. paper (see Figure 2):

  • One of circuits 2, 3, or 4
  • One of circuits 5, 6, 13, or 14
  • One of circuits 9 or 10
  • One of circuit 18 or 19

We can pick a modest number of qubits (e.g., 2-10) or so. There's no reason, AFAIK, to go crazy with this.
In addition, in terms of the number of "layers" (terminology from Sim et al.) or "reps" (in TwoLocal documentation), we could fix that to be 1 for simplicity and then expand if we think that's an interesting direction to go.

Because we have to insert ("bind") parameters to these circuits, it's also crucial for reproducibility purposes that we fix the seed of whatever random number generator we are using.

With respect to generating the matrices themselves, I suggest first generating data files containing each kernel matrix element as its own row, with corresponding metadata. For starters, I suggest doing ideal (statevector) simulation; the data files would look something like this: suppose we are doing simulations of circuit ID id. The data file could be called kernels-[id]-ideal.csv, and would contain the following:

width layers shots seed1 seed2 fidelity of result

where seed1 and seed2 are the seed values used to generate the parameter bindings for the circuit used to calculate the kernel. And the result should always be an all 0 bitstring.

NOTE: We found it necessary to use a different file format, feather, which we found necessary to facilitate storage of the data files.

Notice that seed1 and seed2 would range over values 1, 2, ...., D, meaning that the largest kernel matrix we could extract from this data is DxD. I think we got up to D=1000 and then realized it just took too long to generate more data.

Using this data, we can then mock up different realizations of quantum kernel matrices by sampling from this data set. In particular, if seed1 and seed2 range from 1,2,... , D, then to generate an s x s kernel matrix, we can randomly sample a choice of integers of size s, and then subsample the data file to values of seed1 and seed2 in that choice.


Todo

  • Generate the array and tell what we got
  • One of circuits 2, 3, or 4
  • One of circuits 5, 6, 13, or 14
  • One of circuits 9 or 10
  • One of circuit 18 or 19
  • Runtime sampler program
  • Gen files program
  • Compatible with Actions
  • Kernel circuit program

EPIC #5

Shared folder endpoint / cli

Resume

Create a cli for sync local data into shared folder data and git everything at the end.

Details

  • Metadata sync
  • Telemetry sync
  • Git sync

EPIC #5

Adapt kernel flow

Resume

  • Adapt kernel flow to split when too large Payload
  • Make kernel_flow more simple
  • Make kernel_flow as object

EPIC #10

Full Workflow endpoint

Resume

Create an endpoint to run the entire workflow at once.
Use the previoux endpoint to call each part : kernel_flow & completion_flow

Details

  • Add endpoint to src/workflow.py

EPIC #5

Add data function + program to use statevector

Resume

For statevector we want to use the programid : circuit-runner
The return is lot different than the sampler program, so we need a new way to get to get the read the data and implement the gen_data function.

Goals

  • Add circuit-runner to runtime function
  • Add a new way to read the data and gen kernel metadata
  • Update unittest

EPIC #5

Error connection 500

Resume

Include error 500
Telemetry complete but Runtime failed ! Unknown Error
Exception::'Failed to run program: "HTTPSConnectionPool(host='runtime-us-east.quantum-computing.ibm.com', port=443): Max retries exceeded with url: /jobs (Caused by ResponseError('too many 500 error responses'))"'


EPIC #5

Qkernel - Only run uniq pair of [x,y]

Resume

We want to only generate circuit for uniq [x,y] pair.

As our matrix is symmetrical, we don't need to simulate every possible pair but only uniq pair.

Goal

Adding a check on the kernel_endpoint function to have only uniq pair
Code of the seed_x & seed_y generation :

seed_x = []
seed_y = []
if matrix_size is not None:
if matrix_size[0] != matrix_size[1]:
print(
"""
The coordinate have to be square.
Ex. [2,2] or [5,5]
"""
)
sys.exit(1)
for x_axe in range(matrix_size[0] + 1):
for y_axe in range(matrix_size[1] + 1):
seed_x.append(x_axe)
seed_y.append(y_axe)
else:
seed_x.append(seed1)
seed_y.append(seed2)

Example

[2, 2]

means :

circuit only run 6 circuits :

  • 00
  • 01
  • 11
  • 20
  • 21
  • 22
[ 0, 1, 2
0,
1, 

2,            ]

Getting only lower bound

EPIC #5

Using real world data

I think one thing we'd want to do as a preliminary step is to take a couple well-known large ML datasets such as Iris and MNIST, run them through a classical VSM development process (thus coming up with some classical kernels to study within the context of this workflow), then split those datasets up into "initialization" training/validation/test data sets and sample "streaming" data.

This should give us a baseline for comparison with the quantum enhanced algorithm when we devise & automate tests.

EPIC #5

Runtime exception and telemetry

Resume

Catching the exception when Runtime return, the payload is too large.
And then writing the telemetry about it.

  • Also, adding number of circuits column in telemetry files and runtime succeed/fail column

Actions url : https://github.com/Travis-S-IBM/q-kernel-ops/runs/6062172004?check_suite_focus=true
Actions logs :

  File "/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/qiskit_ibm_runtime/qiskit_runtime_service.py", line 901, in run
    raise IBMRuntimeError(f"Failed to run program: {ex}") from None
qiskit_ibm_runtime.exceptions.IBMRuntimeError: "Failed to run program: '413 Client Error: Payload Too Large for url: https://runtime-us-east.quantum-computing.ibm.com/jobs. <html>\\r\\n<head><title>413 Request Entity Too Large</title></head>\\r\\n<body>\\r\\n<center><h1>413 Request Entity Too Large</h1></center>\\r\\n<hr><center>nginx</center>\\r\\n</body>\\r\\n</html>\\r\\n'"

Standalone matrix cmpl

Write the standalone program for Matrix Completion (reuse from #3 study).
The program should be utilizable as simple python script.

  • Write program
  • Compatible with GitHub Actions

EPIC #5

Gen basic data

Resume

Plot some basic data from telemetry file

Data to generate (template)

nbqubits / matrix size [5,5] [10,10] [25,25] [50,50] [75,75] [100,100]
1
4
8
10

EPIC #5
Link #2

TELEMETRY - Add info

Resume

Add telemetry info into the metadata files

Goal

Having the time, job id and payload of the circuit as data information for each dataset

  • time in queue
  • time in simulation
  • job id
  • size of payload (python object send to Runtime)

nb_qubits | layer | circuit_id | job_id | time queue | time simu | payload size


EPIC #5

Workflow testing

Testing the final workflow with bunch of data and comparing with classical ML

EPIC #5

Standalone QK

Write the standalone program for Quantum Kernel (reuse from #4 study).
The program should be utilizable as simple python script.

  • Write program
  • Run with GitHub Actions

EPIC #5

Study size of 1 circuit

Resume

Gen 1 circuits of of each pqc of each number of qubits (1 to 10 to ...) and plots them

Generate PSD matrix via quantum kernel

All quantum kernel generate PSD matrix, we need to generate Positive semi define matrix for studying the matrix completion.

  • Generate PSD matrix by quantum kernel

EPIC #5

Medium article

Just write a fun story about our project on medium :)

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.