Skip to content

Commit

Permalink
Some random clean up (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
bettinaheim authored Nov 27, 2023
1 parent 0adfa3e commit b2d43db
Show file tree
Hide file tree
Showing 33 changed files with 198 additions and 190 deletions.
24 changes: 13 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
"destination": "workspaces/host"
}
},
// Getting a browser to e.g. preview docs within the container (optional - uncomment if needed)
// "postCreateCommand": "apt update && apt install -y curl && curl -sSL https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb -o /tmp/chrome.deb && apt install -y /tmp/chrome.deb",
// Unfortunately, it is not currently possible to have the same dev container definition for systems with and without a supported GPU.
// See also https://github.com/airo-ugent/airo-ros/issues/17.
// To enable the container to leverage GPU acceleration, add "--gpus=all" to the list of arguments below.
"runArgs": [ "--net=host", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
"features": {
// Getting a GUI to show content in Chrome (optional - uncomment if needed)
// "ghcr.io/devcontainers/features/desktop-lite:1": { "password": "cuda-quantum" }
// If you do not have the NVIDIA container runtime installed, available GPUs will not be automatically detected.
// You can manually pass the flag to enable GPU support to docker by uncommenting the line below.
// "runArgs": [ "--gpus=all" ],
"hostRequirements": {
"gpu": "optional"
},
"forwardPorts": [6080],
// To use certain debugging tools, you may want uncomment the two lines below.
// Be mindful of security implications when you do. See also
// - https://github.com/rr-debugger/rr/wiki/Docker
// - https://www.cybereason.com/blog/container-escape-all-you-need-is-cap-capabilities
// "capAdd": ["SYS_PTRACE"],
// "securityOpt": [ "seccomp=unconfined" ],
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -32,7 +33,8 @@
"stkb.rewrap",
"qiu.llvm-ir-language-support",
"llvm-vs-code-extensions.vscode-mlir",
"ms-azuretools.vscode-docker"
"ms-azuretools.vscode-docker",
"ritwickdey.liveserver"
],
"settings": {
"files.associations": {
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/command_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ jobs:
run: |
if ${{ startsWith(github.event.comment.body, '/') }}; then
echo "react=true" >> $GITHUB_OUTPUT
command=$(echo "${{ github.event.comment.body }}" | head -n 1 | xargs | cut -d " " -f 1)
json_config=`cat .github/workflows/config/command_dispatch_config.json | sed 's/{{.*}}//g'`
entries=`echo "$json_config" | jq -c '.[]'`
for entry in $entries; do
command_name=`echo $entry | jq -r '.command'`
if [ "${command:1}" == "$command_name" ]; then
if [ "${COMMENT_BODY#/$command_name}" != "$COMMENT_BODY" ]; then
command_suffix=`echo $entry | jq -r '.event_type_suffix'`
echo "command_type=${command:1}${command_suffix:--command}" >> $GITHUB_OUTPUT
echo "command_type=${command_name}${command_suffix:--command}" >> $GITHUB_OUTPUT
fi
done
fi
env:
COMMENT_BODY: ${{ github.event.comment.body }}

command_dispatch:
name: Dispatch slash commands
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/config/spellcheck_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ matrix:
# Ignore content between inline backticks
- open: '(?P<open>`+)'
close: '(?P=open)'
# Ignore the first lowercase word after @param, which is usually the parameter name
- open: '@param(?:\s[a-z]+)?'
close: '(\s|$)'
# Ignore words that start with an @, e.g. @param used in doc comments
- open: '@\S'
close: '(\s|$)'
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/config/spelling_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Toffoli
VQE
Vazirani
WSL
accessor
adjoint
al
ansatz
Expand All @@ -71,6 +72,7 @@ backends
bitcode
bitstring
bitstrings
boolean
buildable
callable
callables
Expand All @@ -79,7 +81,10 @@ canonicalize
canonicalizer
canonicalizes
codebase
comparator
comparators
composable
constructible
controlled
coprocessor
coprocessors
Expand All @@ -92,6 +97,8 @@ deallocated
deallocates
deallocation
deallocations
decrement
decrementing
deserialize
destructor
discretization
Expand All @@ -115,9 +122,16 @@ et
executables
extensibility
extremal
homogenous
increment
incrementing
inlining
instantiation
instantiations
intrinsics
iterable
lookup
lookups
namespace
namespaces
natively
Expand All @@ -128,8 +142,6 @@ parallelization
precompute
precomputed
prepend
qplt
qpu
quantize
quantized
qubit
Expand All @@ -147,6 +159,7 @@ subcommand
subfolder
submodule
subscriptable
subscripted
subtype
subtyped
subtypes
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/repo_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,12 @@ jobs:
md_status=`create_summary Markdown markdown`
rst_status=`create_summary reStructuredText rst`
cxx_status=`create_summary "C++ Headers" cxx_headers`
cxx_status=`create_summary "C++ Examples" cxx_examples`
cxx_h_status=`create_summary "C++ Headers" cxx_headers`
cxx_ex_status=`create_summary "C++ Examples" cxx_examples`
py_status=`create_summary Python python`
if [ ! "$md_status" -eq 0 ]; then exit 1; fi
if [ ! "$rst_status" -eq 0 ]; then exit 2; fi
if [ ! "$cxx_status" -eq 0 ]; then exit 3; fi
if [ ! "$py_status" -eq 0 ]; then exit 4; fi
if [ ! "$cxx_h_status" -eq 0 ]; then exit 3; fi
if [ ! "$cxx_ex_status" -eq 0 ]; then exit 4; fi
if [ ! "$py_status" -eq 0 ]; then exit 5; fi
42 changes: 18 additions & 24 deletions Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export PATH="${CUDAQ_INSTALL_PREFIX}/bin:${PATH}"
export PYTHONPATH="${CUDAQ_INSTALL_PREFIX}:${PYTHONPATH}"
```

Our development container comes with a pre-built version of LLVM which is used to
build CUDA Quantum. If you are working outside our container, please see the
Our development container comes with a pre-built version of LLVM which is used
to build CUDA Quantum. If you are working outside our container, please see the
instructions for [building CUDA Quantum with a custom LLVM
version](#building-cuda-quantum-with-a-custom-llvm-version).

Expand All @@ -47,14 +47,8 @@ detected, the corresponding backends will simply be omitted from the build.

To use or develop GPU-based simulators, you will need to make sure you have a
suitable NVIDIA GPU with the [latest driver][nvidia_driver] installed. You can
confirm the GPU is properly detected running the command `nvidia-smi`.

If you are working in our development container, please add a `--gpus=all` flag
to the list of `runArgs` in the
[.devcontainer/devcontainer.json](.devcontainer/devcontainer.json) file and
relaunch the container. It is unfortunately not possible to define a development
container that enables GPU support depending on the system configuration (see
[this issue](https://github.com/airo-ugent/airo-ros/issues/17)).
confirm the GPU is properly detected running the command `nvidia-smi` in your
development environment.

If you are not working in our development container, you may need to specify the
correct path to your cuQuantum installation by setting the environment variable
Expand All @@ -65,20 +59,20 @@ correct path to your cuQuantum installation by setting the environment variable

## Building CUDA Quantum with a custom LLVM version

CUDA Quantum is intended to be built using the LLVM commit that the submodule
is set to (currently LLVM 16.0.6). If you need to update the LLVM commit, or if
you are not using the pre-built version of that commit in our development
container, LLVM will need to be built from source. ***Building with LLVM >=
17.x is not currently supported*** due to the QIR specification's requirement
to use typed pointers. LLVM 17.x removed the ability to use typed pointers and
instead now requires [opaque pointers](https://llvm.org/docs/OpaquePointers.html#version-support).
The QIR specification will be updated to support opaque pointers in the near
future.

To configure our build scripts with a custom LLVM, please set the LLVM
submodule to the desired commit, and set the following environment variable,
replacing `<installation_path>` with the path where the freshly built LLVM tools
and libraries should be installed:
CUDA Quantum is intended to be built using the LLVM commit that the submodule is
set to (currently LLVM 16.0.6). If you need to update the LLVM commit, or if you
are not using the pre-built version of that commit in our development container,
LLVM will need to be built from source. ***Building with LLVM >= 17.x is not
currently supported*** due to the QIR specification's requirement to use typed
pointers. LLVM 17.x removed the ability to use typed pointers and instead now
requires [opaque
pointers](https://llvm.org/docs/OpaquePointers.html#version-support). The QIR
specification will be updated to support opaque pointers in the near future.

To configure our build scripts with a custom LLVM, please set the LLVM submodule
to the desired commit, and set the following environment variable, replacing
`<installation_path>` with the path where the freshly built LLVM tools and
libraries should be installed:

```bash
export LLVM_INSTALL_PREFIX=<installation_path>
Expand Down
8 changes: 4 additions & 4 deletions include/cudaq/Optimizer/Builder/Factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ inline mlir::Type getCharType(mlir::MLIRContext *ctx) {
return mlir::IntegerType::get(ctx, /*bits=*/8);
}

/// Return the LLVM-IR dialect ptr type.
/// Return the LLVM-IR dialect `ptr` type.
inline mlir::Type getPointerType(mlir::MLIRContext *ctx) {
return mlir::LLVM::LLVMPointerType::get(getCharType(ctx));
}
Expand Down Expand Up @@ -130,8 +130,8 @@ inline mlir::Block *addEntryBlock(mlir::LLVM::GlobalOp initVar) {
return entry;
}

/// Return an i64 array where the kth element is N if the kth
/// operand is veq<N> and 0 otherwise (e.g. is a ref).
/// Return an i64 array where element `k` is `N` if the
/// operand `k` is `veq<N>` and 0 otherwise.
mlir::Value packIsArrayAndLengthArray(mlir::Location loc,
mlir::ConversionPatternRewriter &rewriter,
mlir::ModuleOp parentModule,
Expand Down Expand Up @@ -170,7 +170,7 @@ mlir::FunctionType toCpuSideFuncType(mlir::FunctionType funcTy,

/// @brief Return true if the given type corresponds to a
/// std-vector type according to our convention. The convention
/// is a ptr<struct<ptr<T>, ptr<T>, ptr<T>>>.
/// is a `ptr<struct<ptr<T>, ptr<T>, ptr<T>>>`.
bool isStdVecArg(mlir::Type type);

} // namespace opt::factory
Expand Down
5 changes: 3 additions & 2 deletions include/cudaq/Optimizer/Builder/Intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ static constexpr const char stdvecBoolCtorFromInitList[] =
/// (QUAntum Kernel Execution) and CC (Classical Computation) dialects.
///
/// This builder also allows for the inclusion of predefined intrinsics into
/// the ModuleOp on demand. Intrinsics exist in a map accessed by a symbol name.
/// the `ModuleOp` on demand. Intrinsics exist in a map accessed by a symbol
/// name.
class IRBuilder : public mlir::OpBuilder {
public:
using OpBuilder::OpBuilder;
Expand All @@ -36,7 +37,7 @@ class IRBuilder : public mlir::OpBuilder {
}

/// Create a global for a C-style string. (A pointer to a NUL terminated
/// sequence of bytes.) \p cstring must have the NUL character appended \b
/// sequence of bytes.) `cstring` must have the NUL character appended \b
/// prior to calling this builder function.
mlir::LLVM::GlobalOp genCStringLiteral(mlir::Location loc,
mlir::ModuleOp module,
Expand Down
3 changes: 2 additions & 1 deletion include/cudaq/Optimizer/CodeGen/Pipelines.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace cudaq::opt {
/// specified if `QIRProfile` is true.
/// @param QIRProfile whether or not this is lowering to a specific QIR profile
/// @param pm Pass manager to append passes to
/// @param convertTo String name of qir profile (e.g., qir-base, qir-adaptive)
/// @param convertTo String name of QIR profile (e.g., `qir-base`,
/// `qir-adaptive`)
template <bool QIRProfile = false>
void addPipelineToQIR(mlir::PassManager &pm,
llvm::StringRef convertTo = "none") {
Expand Down
2 changes: 1 addition & 1 deletion include/cudaq/Optimizer/CodeGen/QIRFunctionNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ constexpr static const char NVQIRPackSingleQubitInArray[] =
constexpr static const char NVQIRReleasePackedQubitArray[] =
"releasePackedQubitArray";

/// QIR Array funciton name strings
/// QIR Array function name strings
constexpr static const char QIRArrayGetElementPtr1d[] =
"__quantum__rt__array_get_element_ptr_1d";
constexpr static const char QIRArrayQubitAllocateArray[] =
Expand Down
4 changes: 2 additions & 2 deletions python/tests/backends/test_IQM.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

iqm_client = pytest.importorskip("iqm.iqm_client")
try:
from utils.mock_qpu.iqm import startServer
from utils.mock_qpu.iqm.mock_iqm_cortex_cli import write_a_mock_tokens_file
from utils.mock_qpu.iqm.mock_iqm_server import startServer
except:
pytest.skip("Mock qpu not available, skipping IQM tests.",
allow_module_level=True)

# Define the port for the mock server
port = 9100
port = 62443


def assert_close(want, got, tolerance=1.0e-5) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion python/tests/backends/test_IonQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
pytest.skip("Mock qpu not available.", allow_module_level=True)

# Define the port for the mock server
port = 62455
port = 62441


def assert_close(got) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
pytest.skip("Mock qpu not available.", allow_module_level=True)

# Define the port for the mock server
port = 62444
port = 62442


def assert_close(got) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion python/tests/backends/test_Quantinuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
pytest.skip("Mock qpu not available.", allow_module_level=True)

# Define the port for the mock server
port = 62454
port = 62440


def assert_close(got) -> bool:
Expand Down
Loading

0 comments on commit b2d43db

Please sign in to comment.