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 3rd order GCI #1342

Merged
merged 21 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
20407c9
added third order gci
wrightjandrew Jun 4, 2024
01b8373
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 4, 2024
46d78cf
added test (copy of previous generator type tests)
wrightjandrew Jun 4, 2024
0f18e27
Merge branch 'dbi_gci_third_order' of https://github.com/qiboteam/qib…
wrightjandrew Jun 4, 2024
22444d4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 4, 2024
e075312
added doc string to third order gci
wrightjandrew Jun 5, 2024
2c6aa9d
added docstrin plus notebook showing the 3rd commutator of the DBI group
wrightjandrew Jun 5, 2024
bf36a09
Merge branch 'dbi_gci_third_order' of https://github.com/qiboteam/qib…
wrightjandrew Jun 5, 2024
9bdd178
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
c6dd603
Merge branch 'master' of https://github.com/qiboteam/qibo into dbi_gc…
wrightjandrew Jun 6, 2024
630c2f3
fixed doctring + remove notebook
wrightjandrew Jun 7, 2024
b335cb7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2024
7f4456f
fix test
wrightjandrew Jun 7, 2024
16856c0
Merge branch 'dbi_gci_third_order' of https://github.com/qiboteam/qib…
wrightjandrew Jun 7, 2024
9683ab1
Update src/qibo/models/dbi/double_bracket.py
wrightjandrew Jun 7, 2024
86c0dce
Update tests/test_models_dbi.py
wrightjandrew Jun 7, 2024
1704c58
3rd to third
wrightjandrew Jun 7, 2024
c096287
third order gci name change
wrightjandrew Jun 7, 2024
67e63b5
third order gci name change
wrightjandrew Jun 7, 2024
bc0b0d7
Merge branch 'dbi_gci_third_order' of https://github.com/qiboteam/qib…
wrightjandrew Jun 7, 2024
89c2e29
doc: Remove notebook from doc
andrea-pasquale Jun 10, 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
12 changes: 12 additions & 0 deletions src/qibo/models/dbi/double_bracket.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DoubleBracketGeneratorType(Enum):
group_commutator = auto()
"""Use group commutator approximation"""
# TODO: add double commutator (does it converge?)
wrightjandrew marked this conversation as resolved.
Show resolved Hide resolved
group_commutator_3 = auto()


class DoubleBracketCostFunction(str, Enum):
Expand Down Expand Up @@ -125,6 +126,17 @@ def __call__(
@ self.h.exp(step)
@ self.backend.calculate_matrix_exp(step, d)
)
elif mode is DoubleBracketGeneratorType.group_commutator_3:
if d is None:
d = self.diagonal_h_matrix
operator = (
self.h.exp(-step * (np.sqrt(5) - 1) / 2)
@ self.backend.calculate_matrix_exp(-step * (np.sqrt(5) - 1) / 2, d)
@ self.h.exp(step)
@ self.backend.calculate_matrix_exp(step * (np.sqrt(5) + 1) / 2, d)
@ self.h.exp(-step * (3 - np.sqrt(5)) / 2)
@ self.backend.calculate_matrix_exp(-step, d)
)
operator_dagger = self.backend.cast(
np.array(np.matrix(self.backend.to_numpy(operator)).getH())
)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_models_dbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ def test_double_bracket_iteration_group_commutator(backend, nqubits):
assert initial_off_diagonal_norm > dbi.off_diagonal_norm


@pytest.mark.parametrize("nqubits", [1, 2])
def test_double_bracket_iteration_group_commutator_3(backend, nqubits):
"""Check group commutator mode."""
h0 = random_hermitian(2**nqubits, backend=backend, seed=seed)
d = backend.cast(np.diag(np.diag(backend.to_numpy(h0))))
dbi = DoubleBracketIteration(
Hamiltonian(nqubits, h0, backend=backend),
mode=DoubleBracketGeneratorType.group_commutator_3,
)
initial_off_diagonal_norm = dbi.off_diagonal_norm

# test first iteration with default d
dbi(mode=DoubleBracketGeneratorType.group_commutator_3, step=0.01)
wrightjandrew marked this conversation as resolved.
Show resolved Hide resolved
for _ in range(NSTEPS):
dbi(step=0.01, d=d)

assert initial_off_diagonal_norm > dbi.off_diagonal_norm


@pytest.mark.parametrize("nqubits", [1, 2])
def test_double_bracket_iteration_single_commutator(backend, nqubits):
"""Check single commutator mode."""
Expand Down