Number of Givens rotations does not decrease monotonically with increased tolerance

Open
#672 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
backend

Research direction

Start by reproducing the provided script and inspect the implementation of ffsim.linalg.givens_decomposition, which is the entry point named in the report. Trace how tol affects retained rotations, then add or update coverage so the reported cases produce a non-increasing rotation count as tolerance increases.

Written by the indexing model from the issue text.

Description

Courtesy of @jrm874

import numpy as np
import scipy.linalg

import ffsim


def siam_diag_bath_h1e(n_bath: int) -> np.ndarray:
    hopping = -np.diag(np.ones(n_bath - 1), 1) - np.diag(np.ones(n_bath - 1), -1)
    _, eigvecs = np.linalg.eigh(hopping)
    norb = n_bath + 1
    rot = np.eye(norb)
    rot[1:, 1:] = eigvecs
    h1e = np.zeros((norb, norb))
    h1e[0, 1] = h1e[1, 0] = -1.0  # impurity-bath coupling
    for i in range(1, norb - 1):  # bath chain hopping
        h1e[i, i + 1] = h1e[i + 1, i] = -1.0
    return rot.T @ h1e @ rot


h1e = siam_diag_bath_h1e(n_bath=13)
mat = scipy.linalg.expm(-1j * 0.1 * h1e)

tols = [1e-12, 1e-10, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1]

prev = None
monotonic = True
for tol in tols:
    givens_rotations, _ = ffsim.linalg.givens_decomposition(mat, tol=tol)
    count = len(givens_rotations)
    flag = ""
    if prev is not None and count > prev:
        flag = "  <-- INCREASED (non-monotonic!)"
        monotonic = False
    print(f"tol={tol:<8g} num Givens rotations: {count}{flag}")
    prev = count

print(f"\nMonotonic (non-increasing)? {monotonic}")
tol=1e-12    num Givens rotations: 63
tol=1e-10    num Givens rotations: 73  <-- INCREASED (non-monotonic!)
tol=1e-08    num Givens rotations: 46
tol=1e-07    num Givens rotations: 46
tol=1e-06    num Givens rotations: 55  <-- INCREASED (non-monotonic!)
tol=1e-05    num Givens rotations: 38
tol=0.0001   num Givens rotations: 42  <-- INCREASED (non-monotonic!)
tol=0.001    num Givens rotations: 25
tol=0.01     num Givens rotations: 23
tol=0.1      num Givens rotations: 0

Monotonic (non-increasing)? False
Dominant language
Python
Stars
116
Forks
50
Avg merge
2h 1m
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Qiskit/ffsim

All issues in Qiskit/ffsim

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.