Skip to content

Commit

Permalink
qutip exporter and qasm2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Jan 16, 2024
1 parent 7334e28 commit f302b22
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install dependencies
run: |
pip install sphinx sphinx_rtd_theme sphinx_rtd_dark_mode myst_nb
pip install sympy qiskit-terra qiskit-aer matplotlib pylatexenc pennylane cirq
pip install sympy qiskit-terra qiskit-aer matplotlib pylatexenc pennylane cirq qutip qutip_qip
python setup.py install
- name: Sphinx build
run: |
Expand Down
61 changes: 2 additions & 59 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Roadmap
# Todo list

> And keep an eye to the roadmap. It likes to change
## Month 1

### Week 1: (25 Sept 23)
- [x] POC
- [x] Test suite setup
- [x] Integrate tox with linters, unit-tests, typecheck, coverage
Expand All @@ -14,8 +9,6 @@
- [x] Ast2logic: assign
- [x] Dummy compiler: compile ite
- [x] Ast2logic: tuple

### Week 2: (2 Oct 23)
- [x] Split ast2logic into a directory
- [x] Ast2logic: write a type inference function
- [x] Ast2logic: fix type inference on assign
Expand All @@ -28,14 +21,10 @@
- [x] OpenQASM3 exporter
- [x] Int: comparison - eq, noteq
- [x] Int: comparison - lt, gt, gte, lte

#### Typechecker branch
- [x] Translate_expr should returns ttype*expr
- [x] Args should also hold the original type
- [x] Transform Env to a class holding also the original types
- [x] Typecheck all the expressions

### Week 3: (9 Oct 23)
- [x] Test circuit and boolexp using the python code as reference
- [x] Qubit garbage uncomputing and recycling
- [x] Test: add qubit usage check
Expand All @@ -45,19 +34,13 @@
- [x] Doc: properly render documentation
- [x] Builtin debug functions: print()
- [x] Fix code structure and typing location

### Week 4: (16 Oct 23)
- [x] Extensible type system
- [x] Builtin functions: max(), min(), len()
- [x] Function call (to builtin)
- [x] Int arithmetic: +, -
- [x] Qtype: bitwise not
- [x] Qtype: shift right / left
- [x] Int: subtraction

## Month 2:

### Week 1: (23 Oct 23)
- [x] Symbol reassign and augassign
- [x] Remove unneccessary expressions
- [x] Remove quantum circuit identities
Expand All @@ -70,40 +53,23 @@
- [x] Grover algorithm
- [x] Tuple-tuple comparison
- [x] Multi var assign

### Week 2: (30 Oct 23)

- [x] Integrate qrack on test suite
- [x] Test / support on multiple py version >= 3.8
- [x] Fixed size list
- [x] Grover algorithm tests
- [x] Slideshow for UF midterm
- [x] Builtin functions: sum(), all(), any()
- [x] Bool optimizers test

### Week 3: (6 Nov 23)

- [x] Ast2logic: if-then-else statement
- [x] Midterm call
- [x] Bool optimization refactoring

### Week 4: (13 Nov 23)

- [x] Cirq exporter
- [x] Qint multiplier
- [x] Allow quantum gates inside sympy expressions
- [x] CNotSim dummy simulator for circuit testing

## Month 3:

### Week 1: (20 Nov 23)

- [x] Improve exporting utilities
- [x] Publish doc on github
- [x] Documentation

### Week 2: (27 Nov 23)

- [x] Qmatrix
- [x] Hash function preimage attack notebook
- [x] Move all examples to doc
Expand All @@ -112,37 +78,18 @@
- [x] Improve documentation
- [x] First stable release
- [x] Use cases

### Week 3: (4 Dec 23)

- [x] Int arithmetic: mod
- [x] Simon example
- [x] Deutsch-Jozsa example
- [x] Improve performance on big circuits

### Week 4: (11 Dec 23)

- [x] Minor fixes and new release

## Month 4:

### Week 1: (18 Dec 23)
- [x] Pennylane exporter
- [x] Regression test for qubit number and gates
- [x] Sympy exporter
- [x] QFT and IQFT


### Week 2: (25 Dec 23)

- [x] Separate tests in directories
- [x] Circuit decompilation

### Week 3: (1 Jan 24)

### Week 4: (8 Jan 24)


- [x] QuTip Support


## Future features
Expand All @@ -167,10 +114,6 @@

- [ ] Parameter bind

### Framwork support

- [ ] QuTip

### Tools

- [ ] py2qasm tool
Expand Down
1 change: 1 addition & 0 deletions docs/source/example_big_circuit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"source": [
"from qlasskit import Qint8, Qlist, boolopt, qlassfa\n",
"\n",
"\n",
"@qlassfa(bool_optimizer=boolopt.fastOptimizer)\n",
"def test(a_list: Qlist[Qint8, 64]) -> Qint8:\n",
" h_val = Qint8(0)\n",
Expand Down
16 changes: 10 additions & 6 deletions docs/source/example_grover_sudoku.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"from qlasskit import qlassf, Qmatrix\n",
"from qlasskit.algorithms import Grover\n",
"\n",
"\n",
"@qlassf\n",
"def sudoku_check(m: Qmatrix[bool, 2, 2]) -> bool:\n",
" constr = m[0][0]\n",
Expand All @@ -30,6 +31,7 @@
" sub3 = m[0][1] ^ m[1][1]\n",
" return sub0 and sub1 and sub2 and sub3 and constr\n",
"\n",
"\n",
"q_algo = Grover(sudoku_check)"
]
},
Expand Down Expand Up @@ -97,22 +99,24 @@
"source": [
"from qlasskit import Qint2, Qint4\n",
"\n",
"\n",
"@qlassf\n",
"def sudoku_check(m: Qmatrix[Qint2, 4, 4]) -> bool:\n",
" res = True\n",
" \n",
"\n",
" # Constraints\n",
" res = (m[0][2] == 3) and (m[0][0] == 1)\n",
" \n",
"\n",
" # Check every row and column\n",
" for i in range(4):\n",
" c = (Qint4(0) + m[i][0] + m[i][1] + m[i][2] + m[i][3]) == 6 \n",
" r = (Qint4(0) + m[0][i] + m[1][i] + m[2][i] + m[3][i]) == 6 \n",
" c = (Qint4(0) + m[i][0] + m[i][1] + m[i][2] + m[i][3]) == 6\n",
" r = (Qint4(0) + m[0][i] + m[1][i] + m[2][i] + m[3][i]) == 6\n",
" res = res and c and r\n",
" \n",
"\n",
" return res\n",
"\n",
"#q_algo = Grover(sudoku_check)\n",
"\n",
"# q_algo = Grover(sudoku_check)\n",
"print(sudoku_check.circuit())"
]
}
Expand Down
55 changes: 42 additions & 13 deletions docs/source/exporter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -47,7 +47,7 @@
"<Figure size 454.719x451.5 with 1 Axes>"
]
},
"execution_count": 13,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -75,13 +75,14 @@
"text": [
"OPENQASM 3.0;\n",
"\n",
"gate hello_world a b.0 b.1 anc_0 _ret.0 _ret.1 {\n",
"gate hello_world a b.0 b.1 _ret.0 _ret.1 {\n",
"\tcx a _ret.0\n",
"\tcx b.0 _ret.0\n",
"\tcx b.1 anc_0\n",
"\tccx a b.0 anc_0\n",
"\tcx b.1 _ret.1\n",
"\tccx a b.0 _ret.1\n",
"}\n",
"\n",
"hello_world q[0],q[1],q[2],q[3],q[4];\n",
"\n"
]
}
Expand All @@ -100,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -128,7 +129,7 @@
"4: ───hello_world───"
]
},
"execution_count": 15,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -149,7 +150,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -158,7 +159,7 @@
"<QuantumTape: wires=[0, 3, 1, 2, 4], params=0>"
]
},
"execution_count": 16,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -179,7 +180,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -191,7 +192,7 @@
"C((0,1),X(4))*CNOT(2,4)*CNOT(1,3)*CNOT(0,3)*|00000>"
]
},
"execution_count": 17,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -200,6 +201,34 @@
"qc = hello_world.export(\"sympy\")\n",
"qc"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Qutip"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Gate(hello_world, targets=[0, 1, 2, 3, 4], controls=None, classical controls=None, control_value=None, classical_control_value=None)]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"qc = hello_world.export(\"qutip\")\n",
"qc.gates"
]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion qlasskit/qcircuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from typing import Literal, get_args # noqa: F401

SupportedFramework = Literal["qiskit", "sympy", "cirq", "qasm", "pennylane"]
SupportedFramework = Literal["qiskit", "sympy", "cirq", "qasm", "pennylane", "qutip"]
SupportedFrameworks = list(get_args(SupportedFramework))

from . import gates # noqa: F401, E402
Expand Down
Loading

0 comments on commit f302b22

Please sign in to comment.