Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions qmb/_hamiltonian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ auto prepare(py::dict hamiltonian) {
auto coef = torch::empty({term_number, 2}, torch::TensorOptions().dtype(torch::kFloat64).device(torch::kCPU));
// No need to initialize

auto site_accessor = site.template accessor<std::int16_t, 2>();
auto kind_accessor = kind.template accessor<std::uint8_t, 2>();
auto coef_accessor = coef.template accessor<double, 2>();
auto site_accessor = site.accessor<std::int16_t, 2>();
auto kind_accessor = kind.accessor<std::uint8_t, 2>();
auto coef_accessor = coef.accessor<double, 2>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

我就不作校验了hhh最好是有 CI 能保证构建成功,回头可以看看有没有什么办法接入 GitHub

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

确实可以,搜到了这个 https://github.com/marketplace/actions/cuda-toolkit 。理论上,可以设置一个matrix,不同python、不同pytorch、不同cuda。但是1、github action上只能编译,不能运行一个哪怕简单的例子;2、量大不适合放github action里。

我平时是commit前跑一下 python -m qmb precompile openfermion -PH2 这个东西会在编译一个试试,并跑一个很简单的例子。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

哦对了,等 #42 merge 了, 目前写了的 pytest 可以直接跳过cuda部分,只测试cpu版本的。


std::int64_t index = 0;
for (auto& item : hamiltonian) {
Expand Down
4 changes: 2 additions & 2 deletions qmb/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def _load_module(cls, n_qubytes: int = 0, particle_cut: int = 0) -> object:
f"{folder}/_hamiltonian_cuda.cu",
],
is_python_module=n_qubytes == 0,
extra_cflags=["-O3", "-ffast-math", "-march=native", f"-DN_QUBYTES={n_qubytes}", f"-DPARTICLE_CUT={particle_cut}"],
extra_cuda_cflags=["-O3", "--use_fast_math", f"-DN_QUBYTES={n_qubytes}", f"-DPARTICLE_CUT={particle_cut}"],
extra_cflags=["-O3", "-ffast-math", "-march=native", f"-DN_QUBYTES={n_qubytes}", f"-DPARTICLE_CUT={particle_cut}", "-std=c++20"],
extra_cuda_cflags=["-O3", "--use_fast_math", f"-DN_QUBYTES={n_qubytes}", f"-DPARTICLE_CUT={particle_cut}", "-std=c++20"],
build_directory=build_directory,
)
if n_qubytes == 0: # pylint: disable=no-else-return
Expand Down