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

Fixing quri-parts ansatz bug and refactoring #37

Merged
merged 1 commit into from
May 7, 2024

Conversation

yuyamashiro
Copy link
Contributor

Refactor QAOA ansatz for quri-parts

バグ修正

https://github.com/Jij-Inc/JijModelingTranspilerQuantum/blob/8bcd73a0ff3ec04852b5aeda7b6afe11b00fd5a4/jijmodeling_transpiler_quantum/quri_parts/qaoa/to_qaoa.py#L99C1-L104C18

            for pauli_z_info, coeff in zip(
                pauli_z_terms, coeff_terms[: self.num_vars]
            ):
                QAOAAnsatz.add_ParametricRZ_gate(
                    pauli_z_info[0], {Gamma[-1]: 2 * coeff}
                )

この部分の self.num_vars によって線形項がないときにansatzが適切な形にならないバグがありました。
以下のリファクタによりこのバグを修正しました。

関連するテストを追加し、通ることを確かめています。

get_qaoa_ansatz のリファクタ

また他実装を修正した方が良い部分があったので ising_hamiltonian.py をQAOAAnsatzクラスへ移植し、コードをシンプルにしました。

定数の扱いの変更

また大きな変更として定数の扱いが異なっています。
これまでは

Problem -> QUBO で出てくるconstant (=: qubo_constant)
QUBO -> Ising で出てくる constant (=: ising_constant)

をそれぞれ、ising_constantはイジングハミルトニアンの定数へ、qubo_constant + ising_constant を返り値の定数。

という形でしたが、ハミルトニアンの定数には値を含めずに全て、返り値に含めるようにしました。

@yuyamashiro yuyamashiro requested a review from Jacomichi February 3, 2024 09:26
@yuyamashiro yuyamashiro changed the title Remove ising_hamiltonian.py and update __init__.py in qaoa package Fix quri-parts ansatz bug and refactor Feb 3, 2024
@yuyamashiro yuyamashiro changed the title Fix quri-parts ansatz bug and refactor Fix quri-parts ansatz bug and refactoring Feb 3, 2024
@yuyamashiro yuyamashiro changed the title Fix quri-parts ansatz bug and refactoring Fixing quri-parts ansatz bug and refactoring Feb 3, 2024
Copy link
Collaborator

@Jacomichi Jacomichi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jacomichi Jacomichi merged commit e41b3b0 into main May 7, 2024
4 checks passed
@Jacomichi Jacomichi deleted the fix_quri_parts_hamiltonian branch May 7, 2024 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants