Upgrade to use C++20. - #43
Merged
Merged
Conversation
hzhangxyz
requested review from
CuSO4Deposit and
Copilot
and removed request for
Copilot
June 17, 2025 08:49
There was a problem hiding this comment.
Pull Request Overview
This PR updates the build configuration to target C++20 and modernizes tensor accessor calls in the C++ extension.
- Adds
-std=c++20to both host and CUDA compilation flags in the Python loader - Removes redundant
templatedisambiguator on.accessor<…>()calls in the C++ extension
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| qmb/hamiltonian.py | Append -std=c++20 to extra C++ and CUDA compiler flags |
| qmb/_hamiltonian.cpp | Drop unnecessary template keyword before .accessor<…>() |
Comments suppressed due to low confidence (1)
qmb/hamiltonian.py:34
- [nitpick] Consider adding a compiler feature check or fallback to C++17 to avoid build failures on systems that lack full C++20 support.
"-std=c++20"]
stevapple
approved these changes
Jun 17, 2025
| 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>(); |
There was a problem hiding this comment.
我就不作校验了hhh最好是有 CI 能保证构建成功,回头可以看看有没有什么办法接入 GitHub
Member
Author
There was a problem hiding this comment.
确实可以,搜到了这个 https://github.com/marketplace/actions/cuda-toolkit 。理论上,可以设置一个matrix,不同python、不同pytorch、不同cuda。但是1、github action上只能编译,不能运行一个哪怕简单的例子;2、量大不适合放github action里。
我平时是commit前跑一下 python -m qmb precompile openfermion -PH2 这个东西会在编译一个试试,并跑一个很简单的例子。
Member
Author
There was a problem hiding this comment.
哦对了,等 #42 merge 了, 目前写了的 pytest 可以直接跳过cuda部分,只测试cpu版本的。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Upgrade to use C++20.
Closes: #40
Closes: #36
Checklist: