Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into cuda-builds
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Jan 30, 2024
2 parents 19a5982 + 83839cc commit f50c4b6
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
- os: macos-12 # x86_64
name: mac
cibw:
build: "cp37* cp38* cp39* cp310* cp311*"
build: "cp37* cp38* cp39* cp310* cp311* cp312*"
- os: macos-13-large # Apple Silicon
name: mac_arm64
cibw:
build: "cp37* cp38* cp39* cp310* cp311*"
build: "cp37* cp38* cp39* cp310* cp311* cp312*"
- os: ubuntu-20.04
name: manylinux2014
cibw:
arch: x86_64
build: "cp37* cp38* cp39* cp310* cp311*"
build: "cp37* cp38* cp39* cp310* cp311* cp312*"
manylinux_image: manylinux2014
- os: windows-2019
name: win_amd64
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/testing_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ jobs:
- os: macos-12 # x86_64
name: mac
cibw:
build: "cp37* cp38* cp39* cp310* cp311*"
build: "cp37* cp38* cp39* cp310* cp311* cp312*"
- os: macos-13-large # Apple Silicon
name: mac_arm64
cibw:
build: "cp37* cp38* cp39* cp310* cp311*"
build: "cp37* cp38* cp39* cp310* cp311* cp312*"
- os: ubuntu-20.04
name: manylinux2014
cibw:
arch: x86_64
build: "cp37* cp38* cp39* cp310* cp311*"
build: "cp37* cp38* cp39* cp310* cp311* cp312*"
manylinux_image: manylinux2014
- os: windows-2019
name: win_amd64
Expand Down
6 changes: 3 additions & 3 deletions docs/choose_hw.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ backends and do not involve sampling bitstrings (i.e. no measure gates).
For GPU-based simulations, you can either use qsim's native GPU backend
or the NVIDIA cuQuantum backend. While the native qsim GPU backend is performant
for extracting amplitudes of specific quantum states, it is not optimized for
sampling bitstrings, i.e. for simulating circuits that have measurement gates. For
sampling bitstrings, i.e., for simulating circuits that have measurement gates. For
that purpose, cuQuantum performs significantly better. cuQuantum is also needed
for multi-GPU support. More specifically, there are three options for GPU-based
simulations:
Expand Down Expand Up @@ -132,9 +132,9 @@ Alternatively, you can use your own hardware.
Note the [hardware requirements](https://docs.nvidia.com/cuda/cuquantum/getting_started.html#custatevec)
for NVIDIA's cuQuantum when picking a GPU; in particular, it must have
CUDA Compute Capability 7.0 or higher.
At the time of writing, the following compatable GPUs are available on GCP:
At the time of writing, the following compatible GPUs are available on GCP:
* [NVIDIA T4](https://www.techpowerup.com/gpu-specs/tesla-t4.c3316).
This is the least expensive compatable GPU on GCP.
This is the least expensive compatible GPU on GCP.
It has 16GB of memory and can therefore simulate up to 30 qubits.
It is not compatible with multi-GPU simulations.
* [NVIDIA V100](https://www.techpowerup.com/gpu-specs/tesla-v100-pcie-16-gb.c2957).
Expand Down
4 changes: 2 additions & 2 deletions docs/type_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ they fulfill the same expectations.
| Bitstring | Alias for `uint64_t`. |
| Circuit | [`Circuit`](https://github.com/quantumlib/qsim/tree/master/lib/circuit.h) |
| Container (util.h) | A vector of strings, or `Op`'s output type. |
| Ctype | A complex type, e.g. `std::complex<float>`. |
| Ctype | A complex type, e.g., `std::complex<float>`. |
| For | `for` loop abstractions, see below. |
| ForArgs | Arguments for constructing `For` objects, see below. |
| FP (simulator_basic.h) | Same as `fp_type`. |
| fp_type | A floating-point type, i.e. `float` or `double`. |
| fp_type | A floating-point type, i.e., `float` or `double`. |
| Function (parfor.h) | Any function; args are specified with `Args`. |
| FuserT | [`BasicGateFuser`](https://github.com/quantumlib/qsim/tree/master/lib/fuser_basic.h) |
| Gate | [`Gate`](https://github.com/quantumlib/qsim/tree/master/lib/gate.h) |
Expand Down
2 changes: 1 addition & 1 deletion lib/fuser_basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class BasicGateFuser final : public Fuser<IO, Gate> {
* @param gfirst, glast The iterator range [gfirst, glast) to fuse gates
* (or pointers to gates) in. Gate times of the gates that act on the same
* qubits should be ordered. Gates that are out of time order should not
* cross the time boundaries set by `times_to_split_at` or by measurment
* cross the time boundaries set by `times_to_split_at` or by measurement
* gates.
* @param times_to_split_at Ordered list of time steps (boundaries) at which
* to separate fused gates. Each element of the output will contain gates
Expand Down
2 changes: 1 addition & 1 deletion lib/fuser_mqubit.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class MultiQubitGateFuser final : public Fuser<IO, Gate> {
* @param gfirst, glast The iterator range [gfirst, glast) to fuse gates
* (or pointers to gates) in. Gate times of the gates that act on the same
* qubits should be ordered. Gates that are out of time order should not
* cross the time boundaries set by `times_to_split_at` or by measurment
* cross the time boundaries set by `times_to_split_at` or by measurement
* gates.
* @param times_to_split_at Ordered list of time steps (boundaries) at which
* to separate fused gates. Each element of the output will contain gates
Expand Down
2 changes: 1 addition & 1 deletion pybind_interface/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ set_target_properties(qsim_cuda PROPERTIES
)
set_source_files_properties(pybind_main_cuda.cpp PROPERTIES LANGUAGE CUDA)

target_link_libraries(qsim_cuda PUBLIC OpenMP::OpenMP_CXX)
target_link_libraries(qsim_cuda OpenMP::OpenMP_CXX)
2 changes: 1 addition & 1 deletion pybind_interface/custatevec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ set_target_properties(qsim_custatevec PROPERTIES
)
set_source_files_properties(pybind_main_custatevec.cpp PROPERTIES LANGUAGE CUDA)

target_link_libraries(qsim_custatevec PUBLIC OpenMP::OpenMP_CXX)
target_link_libraries(qsim_custatevec OpenMP::OpenMP_CXX)
4 changes: 3 additions & 1 deletion pybind_interface/decide/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if(has_nvcc)
SUFFIX "${PYTHON_MODULE_EXTENSION}"
)
set_source_files_properties(decide.cpp PROPERTIES LANGUAGE CUDA)
target_link_libraries(qsim_decide OpenMP::OpenMP_CXX)
elseif(has_hipcc)
list(APPEND CMAKE_MODULE_PATH "/opt/rocm/lib/cmake/hip")
find_package(HIP REQUIRED)
Expand All @@ -42,8 +43,9 @@ elseif(has_hipcc)
PREFIX "${PYTHON_MODULE_PREFIX}"
SUFFIX "${PYTHON_MODULE_EXTENSION}"
)
target_link_libraries(qsim_decide PUBLIC OpenMP::OpenMP_CXX)
else()
pybind11_add_module(qsim_decide decide.cpp)
target_link_libraries(qsim_decide PUBLIC OpenMP::OpenMP_CXX)
endif()

target_link_libraries(qsim_decide PUBLIC OpenMP::OpenMP_CXX)
10 changes: 5 additions & 5 deletions qsimcirq/qsim_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ def compute_amplitudes_sweep_iter(
bitstrings: The bitstrings whose amplitudes are desired, input as an
string array where each string is formed from measured qubit values
according to `qubit_order` from most to least significant qubit,
i.e. in big-endian ordering.
i.e., in big-endian ordering.
param_resolver: Parameters to run with the program.
qubit_order: Determines the canonical ordering of the qubits. This is
often used in specifying the initial state, i.e. the ordering of the
often used in specifying the initial state, i.e., the ordering of the
computational basis states.
Yields:
Expand Down Expand Up @@ -539,7 +539,7 @@ def simulate_sweep_iter(
program: The circuit to simulate.
params: Parameters to run with the program.
qubit_order: Determines the canonical ordering of the qubits. This is
often used in specifying the initial state, i.e. the ordering of the
often used in specifying the initial state, i.e., the ordering of the
computational basis states.
initial_state: The initial state for the simulation. This can either
be an integer representing a pure state (e.g. 11010) or a numpy
Expand Down Expand Up @@ -587,7 +587,7 @@ def simulate_expectation_values_sweep_iter(
observables: An observable or list of observables.
params: Parameters to run with the program.
qubit_order: Determines the canonical ordering of the qubits. This
is often used in specifying the initial state, i.e. the
is often used in specifying the initial state, i.e., the
ordering of the computational basis states.
initial_state: The initial state for the simulation. The form of
this state depends on the simulation implementation. See
Expand Down Expand Up @@ -706,7 +706,7 @@ def simulate_moment_expectation_values(
or observable list to calculate after ALL moments.
param_resolver: Parameters to run with the program.
qubit_order: Determines the canonical ordering of the qubits. This
is often used in specifying the initial state, i.e. the
is often used in specifying the initial state, i.e., the
ordering of the computational basis states.
initial_state: The initial state for the simulation. The form of
this state depends on the simulation implementation. See
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ cirq-core~=1.0
numpy~=1.16
pybind11
typing_extensions
setuptools
13 changes: 9 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import shutil
import platform
import subprocess
import sysconfig

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion


class CMakeExtension(Extension):
Expand All @@ -27,21 +27,25 @@ def run(self):
)

if platform.system() == "Windows":
cmake_version = LooseVersion(
from packaging.version import parse

cmake_version = parse(
re.search(r"version\s*([\d.]+)", out.decode()).group(1)
)
if cmake_version < "3.1.0":
if cmake_version < parse("3.1.0"):
raise RuntimeError("CMake >= 3.1.0 is required on Windows")

for ext in self.extensions:
self.build_extension(ext)

def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
python_include_dir = sysconfig.get_path("include")
cmake_args = [
"-DCMAKE_CUDA_COMPILER=nvcc",
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
"-DPYTHON_EXECUTABLE=" + sys.executable,
"-DPYTHON_INCLUDE_DIR=" + python_include_dir,
]

cfg = "Debug" if self.debug else "Release"
Expand Down Expand Up @@ -114,8 +118,9 @@ def build_extension(self, ext):
url="https://github.com/quantumlib/qsim",
author="Vamsi Krishna Devabathini",
author_email="[email protected]",
python_requires=">=3.7.0,<3.12.0",
python_requires=">=3.7.0",
install_requires=requirements,
setup_requires=["packaging"],
extras_require={
"dev": dev_requirements,
},
Expand Down

0 comments on commit f50c4b6

Please sign in to comment.