Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transpiling double bracket iterations into hamiltonian simulation #1294

Draft
wants to merge 151 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 123 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
c8513f1
dbi scheduling first commit: added feature 3 options of scheduling me…
Sam-XiaoyueLi Jan 25, 2024
5fae934
Merge branch 'dbf_migrate' of https://github.com/qiboteam/qibo into d…
Sam-XiaoyueLi Jan 29, 2024
5567114
Tests for double_bracket.py scheduling: test_double_bracket_iteration…
Sam-XiaoyueLi Jan 29, 2024
9a7c9f8
Merge branch 'dbf_migrate' of https://github.com/qiboteam/qibo into d…
Sam-XiaoyueLi Jan 29, 2024
abddfae
Updated utils and Pauli-Z notebook for scheduling
Sam-XiaoyueLi Jan 29, 2024
1948c01
Notebook section shows difference of scheduling techniques in Pauli-Z…
Sam-XiaoyueLi Jan 30, 2024
15e52e2
Create group_commutator_iteration_transpiler
marekgluza Feb 2, 2024
d50d13b
adding the code structure from this week. More work needed to fill in…
marekgluza Feb 2, 2024
23d34e0
Merge branch 'DBI_transpiling_code_structure' of github.com:qiboteam/…
marekgluza Feb 2, 2024
ffac68e
removing stray file
marekgluza Feb 5, 2024
9d7db21
Making a mess and exploring how to meaningfully structure evolution t…
marekgluza Feb 5, 2024
0197363
moving things around and thinking about the structure
marekgluza Feb 5, 2024
3951877
namings in progress
marekgluza Feb 5, 2024
358c423
sorted evolution oracles
marekgluza Feb 5, 2024
7d7324c
preparing for merge with transpiling branch
marekgluza Feb 5, 2024
4690220
stuff runs but next need to create a mutable EvolutionOracles allowin…
marekgluza Feb 6, 2024
41f0a76
defined FrameShifted evolution oracles, it is a recursive class on to…
marekgluza Feb 6, 2024
308b3ab
defined FrameShifted evolution oracles, it is a recursive class on to…
marekgluza Feb 6, 2024
6f9745f
it's running through, there might be bugs but overall code structure …
marekgluza Feb 6, 2024
e2a2ba5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 7, 2024
31c9ac8
there was a deepcopy issue for passing several circuits, now fixed it…
marekgluza Feb 8, 2024
d497483
pulling from the remote branch after fixing the deepcopy issue
marekgluza Feb 8, 2024
5630f4a
indentation issues of pre-commit...
marekgluza Feb 8, 2024
8ff096c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 8, 2024
2754cd2
New branch for implementing magnetic field strategy for double bracke…
Sam-XiaoyueLi Feb 13, 2024
588a02a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 15, 2024
00d7ae1
Merge branch 'dbi_scheduling' of https://github.com/qiboteam/qibo int…
Sam-XiaoyueLi Feb 15, 2024
9d663cb
Fix test random hamiltonian seed for test coverage stability
Sam-XiaoyueLi Feb 15, 2024
e38a340
Merge branch 'dbf_migrate' of https://github.com/qiboteam/qibo into d…
Sam-XiaoyueLi Feb 15, 2024
8c94e4f
Merge branch 'dbi_scheduling' of https://github.com/qiboteam/qibo int…
Sam-XiaoyueLi Feb 15, 2024
892fda4
Added functions for running gradient descent
Sam-XiaoyueLi Feb 22, 2024
ed7580e
Merge branch 'dbf_migrate' of https://github.com/qiboteam/qibo into d…
Sam-XiaoyueLi Feb 22, 2024
0eb2add
Run magnetic field strategy on TFIM
Sam-XiaoyueLi Feb 22, 2024
c3a149c
Merge branch 'master' of https://github.com/qiboteam/qibo into dbi_ma…
Sam-XiaoyueLi Feb 22, 2024
08fb837
Complete dbi_strategies_compare notebook
Sam-XiaoyueLi Feb 22, 2024
3cd9338
Fix error: missing argument d in gradient_onsite_Z
Sam-XiaoyueLi Feb 23, 2024
d01632b
added other reordering of GC; test notebook improved; there was no bu…
marekgluza Feb 28, 2024
46ea9ad
Merge branch 'dbf_migrate' of https://github.com/qiboteam/qibo into d…
Sam-XiaoyueLi Feb 28, 2024
bfec996
Complete the merge in docstring
Sam-XiaoyueLi Feb 28, 2024
54ced5b
Remove `use` in scheduling names
Sam-XiaoyueLi Feb 28, 2024
4b9dc91
Complete docstring; set default polynomial order to even number 4.
Sam-XiaoyueLi Feb 28, 2024
0c7199d
for some reason the discretization eps doesn't imporve gc
marekgluza Feb 28, 2024
a2455cd
for some reason the discretization eps doesn't imporve gc; fix bug on…
marekgluza Feb 28, 2024
9f999db
Merge branch 'dbi_scheduling' of https://github.com/qiboteam/qibo int…
Sam-XiaoyueLi Feb 28, 2024
a84ba9a
iterating the oracle gci works (slowly because repetitions kick in)
marekgluza Feb 28, 2024
1815b15
Merge branch 'DBI_transpiling_code_structure' into DBI_transpiling_co…
marekgluza Feb 28, 2024
745d407
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
4124519
Added documentation + test of effect of n_taylor
Sam-XiaoyueLi Feb 28, 2024
c5ab13e
Remove print line
Sam-XiaoyueLi Feb 28, 2024
3bdee0f
Test coverage for the branch
Sam-XiaoyueLi Feb 28, 2024
f35a58d
Fix error in notebook call (key arguments exchanged)
Sam-XiaoyueLi Mar 1, 2024
80d2604
Backup scheduling moved to `choose_step`
Sam-XiaoyueLi Mar 1, 2024
54a86a8
Update src/qibo/models/dbi/double_bracket.py
Sam-XiaoyueLi Mar 1, 2024
50554e3
Simplify code structure in `polynomial_step`
Sam-XiaoyueLi Mar 1, 2024
4fcdf64
Update `test_models_dbi.py`
Sam-XiaoyueLi Mar 1, 2024
4b985ac
Merge branch 'dbi_scheduling' of https://github.com/qiboteam/qibo int…
Sam-XiaoyueLi Mar 1, 2024
67701e1
Define sigma and Gamma as class function
Sam-XiaoyueLi Mar 1, 2024
ca71ffa
Modified structure: moving scheduling strategies in `utils_scheduling…
Sam-XiaoyueLi Mar 5, 2024
027dc00
Simplify backup option in `choose_step`
Sam-XiaoyueLi Mar 5, 2024
743f947
Fix test for new structure
Sam-XiaoyueLi Mar 6, 2024
00f6d8c
Test coverage for fail cases in polynomial step
Sam-XiaoyueLi Mar 6, 2024
08f8977
added new cost functions
wrightjandrew Mar 12, 2024
f2061f8
bug fix: use string of cost function
wrightjandrew Mar 12, 2024
93eb20a
added full diagonal gradients and a tutorial file
wrightjandrew Mar 15, 2024
f17eb1d
Revert "Test coverage for fail cases in polynomial step"
wrightjandrew Mar 16, 2024
b0c6958
Scheduling test
Sam-XiaoyueLi Mar 19, 2024
0326039
Initial commits for SA
Sam-XiaoyueLi Mar 19, 2024
0b241b1
Update utils_scheduling.py
wrightjandrew Mar 20, 2024
b3a5b0e
Fix lint error
Sam-XiaoyueLi Mar 25, 2024
c6749ab
Merge from scheduling_SA + added test for cost function
Sam-XiaoyueLi Mar 25, 2024
f91956b
Style changes for readability
Sam-XiaoyueLi Mar 25, 2024
9e914de
Remove verbose option for SA
Sam-XiaoyueLi Mar 25, 2024
6de7b6c
Merge branch 'master' into dbi_cost_functions
Sam-XiaoyueLi Mar 25, 2024
8d2b8fc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 25, 2024
46c10ca
Merge branch 'dbi_cost_functions' of https://github.com/qiboteam/qibo…
Sam-XiaoyueLi Mar 26, 2024
909972e
Merge branch 'dbi_cost_functions' of https://github.com/qiboteam/qibo…
Sam-XiaoyueLi Mar 26, 2024
59a56ec
Fix errors emerged from merch
Sam-XiaoyueLi Mar 26, 2024
e8ab447
Added numerical gradient as well as Z-ansatz
wrightjandrew Mar 26, 2024
bf9d5e3
Merge branch 'dbi_cost_functions' of https://github.com/qiboteam/qibo…
wrightjandrew Mar 26, 2024
4f6fe62
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 26, 2024
94fb1a4
Merge pull request #1291 from qiboteam/dbi_cost_functions
shangtai Mar 31, 2024
f4ddcfa
Update notebook
Sam-XiaoyueLi Apr 2, 2024
8cc73f6
Fix test error w energy fluctuation
Sam-XiaoyueLi Apr 2, 2024
39dbe4e
Update notebook to run
Sam-XiaoyueLi Apr 2, 2024
1f22e0e
Code adding Ising model to magnetic field, remaining test
Sam-XiaoyueLi Apr 4, 2024
eca3446
adding tests notebook after talking to Sam
marekgluza Apr 4, 2024
813948d
Merge branch 'master' of https://github.com/qiboteam/qibo into dbi_ma…
Sam-XiaoyueLi Apr 4, 2024
359d33a
largely simplified code but not everything tested. Will need to also …
marekgluza Apr 4, 2024
150dd95
wip fix the commutator conventions
marekgluza Apr 5, 2024
ca0ddfe
merged with Edo expose dbr operator
marekgluza Apr 5, 2024
b67d41c
merging sign conventions
marekgluza Apr 5, 2024
2911d69
continuing tests
marekgluza Apr 5, 2024
39eff87
cleared example files
marekgluza Apr 5, 2024
4d079ba
example notebook now gets test code and runs the test to show the exa…
marekgluza Apr 5, 2024
c0a89cf
removing unnecessary file
marekgluza Apr 5, 2024
61a83db
adding an import line
marekgluza Apr 5, 2024
972e5ad
reshuffle test file
marekgluza Apr 5, 2024
9f38a48
imporoving testing notebook
marekgluza Apr 5, 2024
8a8a5fa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 5, 2024
fd3a91a
merge again :)
marekgluza Apr 5, 2024
fe02a72
fixing typo in test file
marekgluza Apr 5, 2024
ac2d141
Merge branch 'dbi_fix_gc_sign_conventions' into DBI-transpiling-into-…
marekgluza Apr 5, 2024
92af754
almost caught what's wrong in the gci gc error
marekgluza Apr 5, 2024
5382973
conflict with precommit (?) reselvoed
marekgluza Apr 5, 2024
4c9413f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 5, 2024
0ef3146
introduce binary search to find the smallest step size for suzuki tro…
shangtai Apr 5, 2024
d0b8220
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 5, 2024
4abbaa0
remove print statements
shangtai Apr 5, 2024
b6526d7
Merge remote-tracking branch 'origin/DBI-transpiling-into-Hamiltonian…
shangtai Apr 5, 2024
6254a68
include the binary search variant in the circuit method.
shangtai Apr 5, 2024
318761a
apparently still somewhere a sign error in the query lists, also in d…
marekgluza Apr 6, 2024
720e2b7
Merge branch 'DBI-transpiling-into-Hamiltonian-Simulation' of github.…
marekgluza Apr 6, 2024
c599f2c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 6, 2024
1401409
fixed sign issue, now double_bracket.py has a scaling that works; nex…
marekgluza Apr 6, 2024
1f1f3ad
Merge branch 'DBI-transpiling-into-Hamiltonian-Simulation' of github.…
marekgluza Apr 6, 2024
82d16ba
Merge branch 'master' of https://github.com/qiboteam/qibo into dbi_ma…
Sam-XiaoyueLi Apr 8, 2024
6de6003
Update notebooks to function
Sam-XiaoyueLi Apr 8, 2024
5c391b2
Update code strucutre and dependencies
Sam-XiaoyueLi Apr 8, 2024
8b96110
Import dependency (optional)
Sam-XiaoyueLi Apr 8, 2024
417bbfc
small changes in the testing notebook
marekgluza Apr 9, 2024
6274f5f
Merge branch 'master' into DBI-transpiling-into-Hamiltonian-Simulation
marekgluza Apr 24, 2024
20ceda2
tests started working for gci vs dbi
marekgluza Apr 25, 2024
82adef2
gci and dbi agree on the GC with np backend; next test (and correct) …
marekgluza Apr 26, 2024
f49d553
the gci with evolution oracles agress with gci with classical memoiza…
marekgluza Apr 29, 2024
a2a2c5d
cleaned up notebook and test file; next extract circuit and check tha…
marekgluza Apr 29, 2024
ea79855
updating some variables to check if tests will advance
marekgluza Apr 29, 2024
28db390
moved the diagonal associations code sketch elsewhere to the analog p…
marekgluza Apr 29, 2024
9640356
a circuit extraction notebook in examples - you can use it to analyze…
marekgluza Apr 30, 2024
75dab02
removing old file
marekgluza Apr 30, 2024
24bb12d
Resolve cost function notebook issues based on commit 6a41ccf
Sam-XiaoyueLi May 2, 2024
de80cb0
Thanks Edoardo for pointing out the lint issues
marekgluza May 2, 2024
fd1737b
Fix minor errors in notebook, add new test files
Sam-XiaoyueLi May 19, 2024
b6f220a
Fix test_dbi.py with pytorch (backend.cast)
Sam-XiaoyueLi May 20, 2024
37a129b
extrating number of gates
marekgluza May 20, 2024
d3ab311
Fix test_gci_implementation_normal_and_oracles assertion error, incre…
Sam-XiaoyueLi May 20, 2024
9a75844
Merge branch 'DBI-transpiling-into-Hamiltonian-Simulation' of github.…
marekgluza May 20, 2024
b3b19e4
Fix errors with pytorch: backend.cast
Sam-XiaoyueLi May 21, 2024
b90a357
Missing import
Sam-XiaoyueLi May 21, 2024
5d4b0de
Merge branch 'dbi_magnetic_field_ising_model' of https://github.com/q…
Sam-XiaoyueLi May 21, 2024
1cd33d4
Pylint error delete comment line
Sam-XiaoyueLi May 21, 2024
3839a32
suggesting fix
marekgluza May 21, 2024
3e6cc73
suggesting fix
marekgluza May 21, 2024
c0eff70
Test fixes
Sam-XiaoyueLi May 21, 2024
8f07f17
Merge branch 'DBI-transpiling-into-Hamiltonian-Simulation' of https:/…
Sam-XiaoyueLi May 21, 2024
17a40ae
adding reordered gc
marekgluza May 21, 2024
ed46195
Merge branch 'DBI-transpiling-into-Hamiltonian-Simulation' of github.…
marekgluza May 21, 2024
b997251
Fix GC and reduced GC sign
Sam-XiaoyueLi May 21, 2024
976989e
Test coverage
Sam-XiaoyueLi May 21, 2024
97e3e44
added an imperfect inversion example
wrightjandrew May 21, 2024
d4ce533
Revert "Test coverage"
wrightjandrew May 21, 2024
83b67dd
updating the files present in this brench that were just merged into …
marekgluza Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 12 additions & 38 deletions examples/dbi/DBI_strategy_Pauli-Z_products.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -122,31 +122,16 @@
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[Qibo 0.2.4|INFO|2024-01-24 19:59:31]: Using qibojit (numba) backend on /CPU:0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Initial off diagonal norm 8.48528137423857\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# set the qibo backend (we suggest qibojit if N >= 20)\n",
"# alternatives: tensorflow (not optimized), numpy (when CPU not supported by jit)\n",
"set_backend(\"qibojit\", \"numba\")\n",
"\n",
"# hamiltonian parameters\n",
"nqubits = 2\n",
"nqubits = 5\n",
"h = 3\n",
"\n",
"# define the hamiltonian\n",
Expand All @@ -160,20 +145,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[-2.-0.j -0.-0.j -0.-0.j -0.-0.j]\n",
" [-0.-0.j 2.-0.j -0.-0.j -0.-0.j]\n",
" [-0.-0.j -0.-0.j 2.-0.j -0.-0.j]\n",
" [-0.-0.j -0.-0.j -0.-0.j -2.-0.j]]\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(H_TFIM.matrix)"
]
Expand Down Expand Up @@ -219,8 +193,9 @@
"# add in initial values for plotting\n",
"off_diagonal_norm_history = [dbi.off_diagonal_norm]\n",
"steps = [0]\n",
"scheduling = DoubleBracketScheduling.use_hyperopt\n",
"for _ in range(NSTEPS):\n",
" dbi, idx, step, flip_sign = select_best_dbr_generator(dbi, Z_ops, compare_canonical=False, max_evals=max_evals, step_max=step_max)\n",
" dbi, idx, step, flip_sign = select_best_dbr_generator(dbi, Z_ops, scheduling=scheduling, compare_canonical=False, max_evals=max_evals, step_max=step_max)\n",
" off_diagonal_norm_history.append(dbi.off_diagonal_norm)\n",
" steps.append(steps[-1]+step)\n",
" if flip_sign < 0:\n",
Expand Down Expand Up @@ -294,7 +269,6 @@
" step_max = 1,\n",
" space = hp.uniform,\n",
" optimizer = tpe,\n",
" max_evals = max_evals,\n",
" )\n",
" dbi_canonical(step=step)\n",
" print(f\"New optimized step at iteration {s+1}/{NSTEPS}: {step}, loss {dbi_canonical.off_diagonal_norm}\")\n",
Expand Down Expand Up @@ -389,7 +363,7 @@
"off_diagonal_norm_history_mixed = [dbi_mixed.off_diagonal_norm]\n",
"steps = [0]\n",
"for _ in range(NSTEPS):\n",
" dbi_mixed, idx, step, flip_sign = select_best_dbr_generator(dbi_mixed, Z_ops, compare_canonical=True, max_evals=max_evals)\n",
" dbi_mixed, idx, step, flip_sign = select_best_dbr_generator(dbi_mixed, Z_ops, scheduling=scheduling, compare_canonical=True, max_evals=max_evals, step_max=step_max)\n",
" off_diagonal_norm_history_mixed.append(dbi_mixed.off_diagonal_norm)\n",
" steps.append(steps[-1]+step)\n",
" if idx == len(Z_ops):\n",
Expand Down Expand Up @@ -479,7 +453,7 @@
"remaining_NSTEPS = NSTEPS - cannonical_NSTEPS\n",
"dbi_mixed_can.mode = DoubleBracketGeneratorType.single_commutator\n",
"for _ in range(remaining_NSTEPS):\n",
" dbi_mixed_can, idx, step, flip_sign = select_best_dbr_generator(dbi_mixed_can, Z_ops, compare_canonical=False)\n",
" dbi_mixed_can, idx, step, flip_sign = select_best_dbr_generator(dbi_mixed_can, Z_ops, scheduling=scheduling, compare_canonical=False, max_evals=max_evals, step_max=step_max)\n",
" off_diagonal_norm_history_mixed_can.append(dbi_mixed_can.off_diagonal_norm)\n",
" steps_mixed_can.append(step)\n",
" if idx == len(Z_ops):\n",
Expand Down
681 changes: 681 additions & 0 deletions examples/dbi/dbi_costs.ipynb

Large diffs are not rendered by default.

Loading
Loading