Skip to content

xi calculation in SB.py (cpu-float32 backend) does not include h term #32

@yaochengchen

Description

@yaochengchen

In mindquantum/mindquantum/algorithm/qaia/SB.py, the calculation of self.xi is inconsistent across different backends.

For "gpu-float32" and "npu-float32", when h is not None, the formula includes the h contribution:

  • 2 * ((self.h / 2) ** 2).sum()

However, for "cpu-float32", the current implementation is:

self.xi = 0.5 * np.sqrt(self.N - 1) / np.sqrt(csr_matrix.power(self.J, 2).sum())

This ignores the h term, which seems inconsistent and may lead to incorrect results when h is not None.

Proposed fix:
Update the "cpu-float32" branch to also include the h contribution, similar to other backends, for consistency and correctness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions