travis-s-ibm / q-kernel-ops Goto Github PK
View Code? Open in Web Editor NEWA repository for the QAMP Spring 2022 project
License: Apache License 2.0
A repository for the QAMP Spring 2022 project
License: Apache License 2.0
Setup the python package.
Links :
Python package doc
Medium article
EPIC #10
Allowing the update fo jupyter notebook from GitHub Actions
https://innerjoin.bit.io/automate-jupyter-notebooks-on-github-9d988ecf96a6
EPIC #5
Package who can help : Chordal Matrix Package
Fix a size as N' = N + n
(ie. N = 6
, n = 3
)
n
) entries, can be overlapping u
or ...For each u
look at time to solution
For time to solution, look at regime where
N'
?EPIC #5
EPIC #5
I suggest, we organize our codebase to be full compliant with the Qiskit Ecosystem.
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.
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.
unittest
from python lib.pylint
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.
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.
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.
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.
EPIC #5
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):
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.
EPIC #5
Create a cli for sync local data into shared folder data and git everything at the end.
EPIC #5
EPIC #10
Create an endpoint to run the entire workflow at once.
Use the previoux endpoint to call each part : kernel_flow
& completion_flow
EPIC #5
Add the error Out of memory
Job logs to analyze : https://quantum-computing.ibm.com/runtime/jobs/c9ttsjjf2jb93li5hg00
And corrected past run into telemetry file
EPIC #5
EPIC #5
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.
circuit-runner
to runtime functionEPIC #5
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
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.
Adding a check on the kernel_endpoint function to have only uniq pair
Code of the seed_x & seed_y generation :
Lines 73 to 92 in b5d5312
[2, 2] means :
circuit only run 6 circuits :
[ 0, 1, 2
0,
1,
2, ]
Getting only lower bound
EPIC #5
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
Catching the exception when Runtime return, the payload is too large.
And then writing the telemetry about it.
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'"
Folder resources files by backend
Write documentation and gen the Read the docs.
Links :
Read the Docs
Article check step 1
EPIC #5
Add telemetry info into the metadata files
Having the time, job id and payload of the circuit as data information for each dataset
nb_qubits | layer | circuit_id | job_id | time queue | time simu | payload size
EPIC #5
Catch exception when timeout from runtime + get telemetry infu such as time in simu and job id.
Epic #5
Add license information to repository.
Testing the final workflow with bunch of data and comparing with classical ML
EPIC #5
Stuff to do after finishing the QAMP #5
Gen 1 circuits of of each pqc of each number of qubits (1 to 10 to ...) and plots them
All quantum kernel generate PSD matrix, we need to generate Positive semi define matrix for studying the matrix completion.
EPIC #5
Just write a fun story about our project on medium :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.