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

Dbi scheduling #1219

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 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
588a02a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 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
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
c5ab13e
Remove print line
Sam-XiaoyueLi Feb 28, 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
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
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
548 changes: 548 additions & 0 deletions examples/dbi/dbi_costs.ipynb

Large diffs are not rendered by default.

Loading
Loading