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

merge_gateのcontrol, DenseMatrix対応 #180

Closed
wants to merge 15 commits into from
Closed

merge_gateのcontrol, DenseMatrix対応 #180

wants to merge 15 commits into from

Conversation

KowerKoint
Copy link
Contributor

close #149 #141
controlありのmerge_gateに対応しました

Comment on lines +34 to +35
"build/_deps/eigen-src",
"build/_deps/googletest-src/googletest/include",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FetchContent_MakeAvailableを使うようにしたとき、ディレクトリの名前が変わっていました

@@ -126,7 +126,7 @@ if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQ
endif()

# Debug options
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if ((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OR CMAKE_CUDA_COMPILER)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

SCALUQ_USE_CUDA=Yesのとき

g++: fatal error: cannot specify ‘-o’ with ‘-c’, ‘-S’ or ‘-E’ with multiple files
compilation terminated.

があったので対応

gate2->target_qubit_list(),
gate2->control_qubit_mask() & ~common_control_mask,
merged_operand_vector);
auto matrix = matrix2 * matrix1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$\otimes I$の拡張をしてから掛け算をするのは計算量的に悪いので変えたくもありますが、そんなに大きすぎるゲートのmergeをしないだろうということで妥協しています…

if (pauli_id2 == 3) return {gate::Y(target1), Kokkos::numbers::pi / 2};
if (pauli_id2 == 2) {
if (gate1_control_mask == 0) {
return {gate::Z(target1, control_list), -Kokkos::numbers::pi / 2};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

YX=-iZのようにGlobalPhase付きで返したいところなのですが、controlつきのGlobalPhaseを返しても嬉しくないのでそれより下のPauliGate生成やDenseMatrix生成にフォールバックします

@@ -88,33 +88,45 @@ inline internal::ComplexMatrix kronecker_product(const internal::ComplexMatrix&

inline internal::ComplexMatrix get_expanded_matrix(const internal::ComplexMatrix& from_matrix,
const std::vector<std::uint64_t>& from_targets,
std::vector<std::uint64_t>& to_targets) {
std::uint64_t from_control_mask,
std::vector<std::uint64_t>& to_operands) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

controlを加味したexpandができるようになりました。
from_control_maskが1の部分以外はIとします

@@ -17,7 +17,8 @@ CMAKE_OPS="-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-D SCALUQ_USE_OMP=${SCALUQ_USE_OMP} \
-D SCALUQ_USE_CUDA=${SCALUQ_USE_CUDA} \
-D SCALUQ_USE_TEST=${SCALUQ_USE_TEST}"
-D SCALUQ_USE_TEST=${SCALUQ_USE_TEST} \
-D SCALUQ_USE_EXE=${SCALUQ_USE_EXE}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

抜けてたので修正

if (gate_type1 == GateType::I) return {gate2, 0.}; // copy can be removed by #125
if (gate_type1 == GateType::Probablistic || gate_type2 == GateType::Probablistic) {
throw std::runtime_error(
"merge_gate(const Gate&, const Gate&): ProbablisticGate is not supported.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

確率ごとにmergeして生成することはできますが、今の所optimizeにしか使いみちがないのでなしとします。

@KowerKoint KowerKoint marked this pull request as ready for review November 6, 2024 03:28
Copy link
Contributor

@gandalfr-KY gandalfr-KY left a comment

Choose a reason for hiding this comment

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

よさそうです

Copy link
Contributor

@Glacialte Glacialte left a comment

Choose a reason for hiding this comment

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

とてもいいと思います!ありがとうございます!
ただ、main.cppの利用例が削除されたのが削除されている部分が気になったのですが、これは理由がありますか?

@KowerKoint
Copy link
Contributor Author

KowerKoint commented Nov 13, 2024

main.cppの利用例が削除されたのが削除されている部分が気になったのですが、これは理由がありますか?

特にないです。
よくテストに使ったもので内容がコロコロ変わっているのでここの内容は気にしていません
main.pyのことなら過去に私が間違えてpushしたものなのでサイレントに消しちゃいました

@KowerKoint
Copy link
Contributor Author

#183 に移動

@KowerKoint KowerKoint closed this Nov 22, 2024
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.

merge_gateをcontrolに対応
3 participants