-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51747da
commit c072042
Showing
2 changed files
with
206 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# September 2021 Challenge: Mentorship Program Screening Tasks\n", | ||
"\n", | ||
"Since this month coincides with the application window for the QOSF mentorship program, we have decided to make the corresponding screening tasks the challenge for this month. So, even if you aren't applying to the mentorship program you can still have a look at the screening tasks.\n", | ||
"\n", | ||
"There are four separate tasks, so you're welcome to try your hand at as many of them as you like!\n", | ||
"\n", | ||
"**_NOTE: The application deadline is September 29th, so don't submit any PRs until after that date since you would be making potential solutions public._**" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Task 1\n", | ||
"\n", | ||
"Design a quantum circuit that considers as input the following vector of integers numbers: \n", | ||
"\n", | ||
"[1,5,7,10]\n", | ||
"\n", | ||
"returns a quantum state which is a superposition of indices of the target solution, obtaining in the output the indices of the inputs where two adjacent bits will always have different values. In this case the output should be: 1/sqrt(2) * (|01> + |11>), as the correct indices are 1 and 3.\n", | ||
"\n", | ||
"1 = 0001 \n", | ||
"**5 = 0101** \n", | ||
"7 = 0111 \n", | ||
"**10 = 1010** \n", | ||
"\n", | ||
"The method to follow for this task is to start from an array of integers as input, pass them to a binary representation and you need to find those integers whose binary representation is such that two adjacent bits are different. Once you have found those integers, you must output a superposition of states where each state is a binary representation of the indices of those integers.\n", | ||
"\n", | ||
"### Example\n", | ||
"Consider the vector [1,5,4,2]\n", | ||
"\n", | ||
"Pass the integer values to binary numbers that is [001,101,100,010]\n", | ||
"\n", | ||
"Identifies which values whose binary representation is such that two adjacent bits are different, we can see that are 2 101 and 010, [001,101,100,010].\n", | ||
"\n", | ||
"Returns the linear combination of the indices in which the values satisfying the criterion are found.\n", | ||
"\n", | ||
"Indices:\n", | ||
"```\n", | ||
" 0 1 2 3\n", | ||
" | | | |\n", | ||
" [001, 101, 100, 010]\n", | ||
" ```\n", | ||
" \n", | ||
"Indices are converted to binary states:\n", | ||
"```\n", | ||
" |00> |01> |10> |11>\n", | ||
" | | | |\n", | ||
" [001, 101, 100, 010]\n", | ||
"```\n", | ||
"\n", | ||
"The answer would be the superposition of the states |01> and |11> or 1/sqrt(2) * (|01> + |11>)\n", | ||
"\n", | ||
"### Context\n", | ||
"If you’re struggling to find a proper way to solve this task, you can find some suggestions for a possible solution below. This is one way to approach the problem, but other solutions may be feasible as well, so feel free to also investigate different strategies if you see fit!\n", | ||
"\n", | ||
"The key to this task is to use the superposition offered by quantum computing to load all the values of the input array on a single quantum state, and then locate the values that meet the target condition. So, how can we use a quantum computer to store multiple values? A possible solution is using the QRAM (some references: https://arxiv.org/pdf/0708.1879.pdf, https://github.com/qsharp-community/qram/blob/master/docs/primer.pdf).\n", | ||
"\n", | ||
"As with classical computers, in the QRAM information is accessed using a set of bits indicating the address of the memory cell, and another set for the actual data stored in the array. \n", | ||
"For example, if you want to use a QRAM to store 2 numbers that have at most 3 bits, it can be achieved with 1 qubit of address and 3 qubits of data.\n", | ||
"\n", | ||
"Suppose you have the vector input_2 = [2,7]. \n", | ||
"In a properly constructed circuit, when the value of the address qubit is |0> the data qubits have value 010 (binary representation of 2) and when it is |1> in the data qubits have value 111 (binary representation of 7).\n", | ||
"\n", | ||
"Given such a structure, you should be able to use Grover’s algorithm in order to obtain the solution to the task.\n", | ||
"\n", | ||
"You can assume that the input always contains at least two numbers that have alternating bitstrings.\n", | ||
"\n", | ||
"Bonus:\n", | ||
"\n", | ||
"Design a general circuit that accepts vectors with random values of size 2n with m bits in length for each element and finds the state(s) indicated above from an oracle." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Task 2\n", | ||
"\n", | ||
"* Prepare 4 random 4-qubit quantum states of your choice.\n", | ||
"* Create and train a variational circuit that transforms input states into predefined output states. Namely\n", | ||
" * if random state 1 is provided, it returns state |0011>\n", | ||
" * if random state 2 is provided, it returns state |0101>\n", | ||
" * if random state 3 is provided, it returns state |1010>\n", | ||
" * if random state 4 is provided, it returns state |1100>\n", | ||
"* What would happen if you provided a different state?\n", | ||
"\n", | ||
"Analyze and discuss the results.\n", | ||
"\n", | ||
"Feel free to use existing frameworks (e.g. PennyLane, Qiskit) for creating and training the circuits. \n", | ||
"This PennyLane demo can be useful: [Training a quantum circuit with Pytorch](https://pennylane.ai/qml/demos/tutorial_state_preparation.html), \n", | ||
"This Quantum Tensorflow tutorial can be useful: [Training a quantum circuit with Tensorflow](https://www.tensorflow.org/quantum/tutorials/mnist).\n", | ||
"\n", | ||
"For the variational circuit, you can try any circuit you want. You can start from one with a layer of RX, RY and CNOTs, repeated a couple of times (though there are certainly better circuits to achieve this goal). \n", | ||
"\n", | ||
"### Context\n", | ||
"This challenge has been inspired by the following papers [\"A generative modeling approach for benchmarking and training shallow quantum circuits\"](https://www.nature.com/articles/s41534-019-0157-8) and [\"Generation of High-Resolution Handwritten Digits with an Ion-Trap Quantum Computer\"](https://arxiv.org/abs/2012.03924). The target states of this task can be interpreted as the 2x2 “bars and stripes” patterns used in the first paper.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Task 3\n", | ||
"\n", | ||
"Implement an interpreter of the qasm 3.0 code that can convert it to a quantum circuit (in the framework of your choice) and calculate a conjugate of a circuit. Provide examples showing that it works.\n", | ||
"\n", | ||
"The gate list that you need to consider are X, Y, Z, RX, RY, RZ, H, S, S†, T, T†, CX, CCX, SWAP & CSWAP.\n", | ||
"\n", | ||
"Some algorithms, such as Grover's algorithm (https://arxiv.org/pdf/2005.06468) or Quantum Autoencoders (https://arxiv.org/pdf/1612.02806) need the transpose conjugate of matrix U. In some frameworks, there is already a way to generate the conjugate of a gate or even a circuit, to help in such situations. In this challenge, you should do this yourself.\n", | ||
"\n", | ||
"The transpose conjugate of a matrix U is denoted with U†, and it is obtained by taking the transpose of the matrix U and then taking the complex conjugate of each element.Note that the transpose conjugate U† of a unitary matrix U has the following properties: \n", | ||
"$U^{\\dagger}= U^{-1}$ and $U^{-1}U = I$. \n", | ||
"https://en.wikipedia.org/wiki/Conjugate_transpose \n", | ||
"https://en.wikipedia.org/wiki/Complex_conjugate \n", | ||
"\n", | ||
"Idea for expanding:\n", | ||
"* Try writing an interpreter that works also with symbolic parameters, i.e. “RX(theta)” instead of just “RX(0.2)”." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Task 4\n", | ||
"\n", | ||
"Write a program that estimates how long running a variational quantum algorithm might take.\n", | ||
"It should take the following data as input:\n", | ||
"* Circuit (might be a circuit created in some popular framework, QASM file or some other format),\n", | ||
"* Number of circuit evaluations per iteration,\n", | ||
"* Number of iterations of the optimization loop,\n", | ||
"* Device information – information about the device being used (e.g. execution times of the gates),\n", | ||
"* Any additional information that you think is relevant.\n", | ||
"\n", | ||
"An example of a simple, but not very accurate formula would be:\n", | ||
"\n", | ||
"Total runtime = (N_1 * t_1 + N_2 * t_2) * n_s * n_i\n", | ||
"\n", | ||
"Where:\n", | ||
"* N_1, N_2 – number of 1-qubit (or 2) gates\n", | ||
"* t_1, t_2 – time of execution of 1-qubit (or 2) gates\n", | ||
"* n_s – number of samples per iteration\n", | ||
"* n_i – number of iterations\n", | ||
"\n", | ||
"Note that this doesn’t take into account that certain gates can be executed in parallel.\n", | ||
"\n", | ||
"This task is pretty open-ended – please try to make your formula as realistic as possible. It will require some investigation and review of existing literature or technical documentation on your own, which might turn out to be much more challenging than it seems, but we hope also much more rewarding :)\n", | ||
"\n", | ||
"Once this is done, you can try analyzing some numerical data from the existing research in order and see how long running such a circuit took (if done on a real device) or could take (if data comes from a simulation).\n", | ||
"\n", | ||
"Some papers with data about the quantum computing devices:\n", | ||
"* [N. Lacroix et al.](https://journals.aps.org/prxquantum/abstract/10.1103/PRXQuantum.1.020304) (ETH), see Table I\n", | ||
"* [Arute et al., supplementary information](https://static-content.springer.com/esm/art%3A10.1038%2Fs41586-019-1666-5/MediaObjects/41586_2019_1666_MOESM1_ESM.pdf) (Google)\n", | ||
"* [Superconducting Qubits: current state of play](https://arxiv.org/abs/1905.13641) (Review)\n", | ||
"* [Materials challenges and opportunities for quantum computing hardware](https://www.science.org/doi/10.1126/science.abb2823) (behind paywall :( )\n", | ||
"* You can often find specific information about quantum devices on the website of the companies building quantum hardware/software.\n", | ||
"\n", | ||
"Review paper on Variational Quantum Algorithms to look for factors that may contribute to longer runtimes:\n", | ||
"* [1st review paper](https://arxiv.org/abs/2012.09265)\n", | ||
"* [2nd review paper](https://arxiv.org/abs/2101.08448)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |