Skip to content

Commit c239db4

Browse files
authored
Merge branch 'main' into add-patch-pypi.sh
2 parents 3489216 + 307af81 commit c239db4

File tree

197 files changed

+1759
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+1759
-544
lines changed

docker/release/cudaq.nvqc.Dockerfile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,36 @@
1010
#
1111
# Usage:
1212
# Must be built from the repo root with:
13-
# docker build -f docker/release/cudaq.nvqc.Dockerfile .
13+
# # to skip prerequisites (default)
14+
# docker build --target=without_tpls -f docker/release/cudaq.nvqc.Dockerfile .
15+
#
16+
# # to install and clone prerequisites
17+
# docker build --target=with_tpls \
18+
# -f docker/release/cudaq.nvqc.Dockerfile .
1419

1520
# Base image is CUDA-Q image
1621
ARG base_image=nvcr.io/nvidia/nightly/cuda-quantum:cu12-latest
1722
FROM $base_image AS nvcf_image
1823

24+
# With prerequisites
25+
FROM $base_image AS with_tpls
26+
RUN echo "Build with prerequisites"
27+
# COPY install_prerequisites into the image
28+
RUN sudo mkdir -p /tmp
29+
COPY --chmod=0755 scripts/install_prerequisites.sh /tmp/install_prerequisites.sh
30+
COPY .gitmodules /tmp/.gitmodules
31+
# Manually run this command locally to create tpls_commits.lock file
32+
# git config --file .gitmodules --get-regexp '^submodule\..*\.path$' \
33+
# | awk '{print $2}' \
34+
# | while read p; do printf "%s %s\n" "$(git rev-parse HEAD:$p)" "$p"; done \
35+
# > tpls_commits.lock
36+
COPY tpls_commits.lock /tmp/tpls_commits.lock
37+
RUN sudo bash /tmp/install_prerequisites.sh -l /tmp/tpls_commits.lock
38+
39+
# Without prerequisites
40+
FROM $base_image AS without_tpls
41+
RUN echo "Default build without prerequisites"
42+
1943
# Run the tar command and then uncomment ADD cudaq.tar.gz ... in order to
2044
# override the installation.
2145
# tar czvf /workspaces/cuda-quantum/cudaq.tar.gz -C /usr/local/cudaq .

docs/sphinx/api/languages/python_api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Backend Configuration
8484
.. autofunction:: cudaq::reset_target
8585
.. autofunction:: cudaq::set_noise
8686
.. autofunction:: cudaq::unset_noise
87+
.. autofunction:: cudaq::register_set_target_callback
88+
.. autofunction:: cudaq::unregister_set_target_callback
8789

8890
.. function:: cudaq.apply_noise(error_type, parameters..., targets...)
8991

docs/sphinx/examples/python/random_walk_qpe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ def rwpe_kernel(n_iter: int, mu: float, sigma: float) -> float:
3535
x.ctrl(aux, target)
3636
h(aux)
3737
if mz(aux):
38-
x(aux)
3938
mu = mu + sigma * .6065
4039
else:
4140
mu = mu - sigma * .6065
4241

4342
sigma *= .7951
4443
iteration += 1
44+
reset(aux)
4545

4646
return 2.0 * mu
4747

docs/sphinx/using/extending/backend.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Create a ``YAML`` configuration file for your target:
225225
preprocessor-defines: ["-D CUDAQ_QUANTUM_DEVICE"]
226226
# Define the lowering pipeline
227227
# This will cover applying hardware-specific constraints since each provider may have different native gate sets, requiring custom mappings and decompositions. You may need assistance from the CUDA-Q team to set this up correctly.
228-
platform-lowering-config: "classical-optimization-pipeline,globalize-array-values,func.func(state-prep),unitary-synthesis,canonicalize,apply-op-specialization,aggressive-early-inlining,classical-optimization-pipeline,lower-to-cfg,func.func(canonicalize,multicontrol-decomposition),decomposition{enable-patterns=U3ToRotations},symbol-dce,<provider_name>-gate-set-mapping"
228+
platform-lowering-config: "classical-optimization-pipeline,globalize-array-values,func.func(state-prep),unitary-synthesis,canonicalize,apply-op-specialization,aggressive-inlining,classical-optimization-pipeline,lower-to-cfg,func.func(canonicalize,multicontrol-decomposition),decomposition{enable-patterns=U3ToRotations},symbol-dce,<provider_name>-gate-set-mapping"
229229
# Tell the rest-qpu that we are generating QIR base profile.
230230
# As of the time of this writing, qasm2, qir-base and qir-adaptive are supported.
231231
codegen-emission: qir-base

include/cudaq/Optimizer/InitAllPasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ inline void registerCudaqPassesAndPipelines() {
2020
opt::registerOptTransformsPasses();
2121

2222
// CUDA-Q pipelines
23-
opt::registerAggressiveEarlyInliningPipeline();
23+
opt::registerAggressiveInliningPipeline();
2424
opt::registerUnrollingPipeline();
2525
opt::registerClassicalOptimizationPipeline();
2626
opt::registerToExecutionManagerCCPipeline();

include/cudaq/Optimizer/Transforms/Passes.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ namespace cudaq::opt {
2121
/// Add a pass pipeline to transform call between kernels to direct calls that
2222
/// do not go through the runtime layers, inline all calls, and detect if calls
2323
/// to kernels remain in the fully inlined into entry point kernel.
24-
void addAggressiveEarlyInlining(mlir::OpPassManager &pm,
25-
bool fatalCheck = false);
26-
void registerAggressiveEarlyInliningPipeline();
24+
void addAggressiveInlining(mlir::OpPassManager &pm, bool fatalCheck = false);
25+
void registerAggressiveInliningPipeline();
2726

2827
void registerUnrollingPipeline();
2928
void registerClassicalOptimizationPipeline();

lib/Optimizer/CodeGen/Pipelines.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void cudaq::opt::commonPipelineConvertToQIR(PassManager &pm,
1717
auto passConfigFields = passConfigAs.split(':');
1818

1919
pm.addNestedPass<func::FuncOp>(createApplyControlNegations());
20-
addAggressiveEarlyInlining(pm);
20+
addAggressiveInlining(pm);
2121
pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
2222
pm.addNestedPass<func::FuncOp>(createUnwindLowering());
2323
pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());
@@ -40,7 +40,7 @@ void cudaq::opt::commonPipelineConvertToQIR(PassManager &pm,
4040
pm.addPass(createApplySpecialization());
4141
// If there was any specialization, we want another round in inlining to
4242
// inline the apply calls properly.
43-
addAggressiveEarlyInlining(pm);
43+
addAggressiveInlining(pm);
4444
addLowerToCFG(pm);
4545
pm.addNestedPass<func::FuncOp>(createCombineQuantumAllocations());
4646
pm.addNestedPass<func::FuncOp>(createCanonicalizerPass());

lib/Optimizer/Transforms/AggressiveEarlyInlining.cpp renamed to lib/Optimizer/Transforms/AggressiveInlining.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace cudaq::opt {
2222
#include "cudaq/Optimizer/Transforms/Passes.h.inc"
2323
} // namespace cudaq::opt
2424

25-
#define DEBUG_TYPE "aggressive-early-inlining"
25+
#define DEBUG_TYPE "aggressive-inlining"
2626

2727
using namespace mlir;
2828

@@ -141,8 +141,7 @@ static void defaultInlinerOptPipeline(OpPassManager &pm) {
141141
/// Such a failure is most likely a sign that there is a cycle in the call
142142
/// graph. [This check is a bad idea: this should be deferred to final codegen
143143
/// when translating the final Quake IR.]
144-
void cudaq::opt::addAggressiveEarlyInlining(OpPassManager &pm,
145-
bool fatalChecks) {
144+
void cudaq::opt::addAggressiveInlining(OpPassManager &pm, bool fatalChecks) {
146145
llvm::StringMap<OpPassManager> opPipelines;
147146
pm.addPass(cudaq::opt::createConvertToDirectCalls());
148147
pm.addPass(createInlinerPass(opPipelines, defaultInlinerOptPipeline));
@@ -152,8 +151,8 @@ void cudaq::opt::addAggressiveEarlyInlining(OpPassManager &pm,
152151
}
153152

154153
namespace {
155-
struct AggressiveEarlyInliningPipelineOptions
156-
: public PassPipelineOptions<AggressiveEarlyInliningPipelineOptions> {
154+
struct AggressiveInliningPipelineOptions
155+
: public PassPipelineOptions<AggressiveInliningPipelineOptions> {
157156
// Running the inlining checks here defeats the compiler engineering principle
158157
// of having composable passes. It is therefore highly discouraged.
159158
PassOptions::Option<bool> runFatalChecker{
@@ -163,11 +162,11 @@ struct AggressiveEarlyInliningPipelineOptions
163162
};
164163
} // namespace
165164

166-
void cudaq::opt::registerAggressiveEarlyInliningPipeline() {
167-
PassPipelineRegistration<AggressiveEarlyInliningPipelineOptions>(
168-
"aggressive-early-inlining",
165+
void cudaq::opt::registerAggressiveInliningPipeline() {
166+
PassPipelineRegistration<AggressiveInliningPipelineOptions>(
167+
"aggressive-inlining",
169168
"Convert calls between kernels to direct calls and inline functions.",
170-
[](OpPassManager &pm, const AggressiveEarlyInliningPipelineOptions &opt) {
171-
addAggressiveEarlyInlining(pm, opt.runFatalChecker);
169+
[](OpPassManager &pm, const AggressiveInliningPipelineOptions &opt) {
170+
addAggressiveInlining(pm, opt.runFatalChecker);
172171
});
173172
}

lib/Optimizer/Transforms/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif()
1212

1313
add_cudaq_library(OptTransforms
1414
AddDeallocs.cpp
15-
AggressiveEarlyInlining.cpp
15+
AggressiveInlining.cpp
1616
ApplyControlNegations.cpp
1717
ApplyOpSpecialization.cpp
1818
ArgumentSynthesis.cpp

python/cudaq/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125
num_available_gpus = cudaq_runtime.num_available_gpus
126126
set_noise = cudaq_runtime.set_noise
127127
unset_noise = cudaq_runtime.unset_noise
128+
register_set_target_callback = cudaq_runtime.register_set_target_callback
129+
unregister_set_target_callback = cudaq_runtime.unregister_set_target_callback
128130

129131
# Noise Modeling
130132
KrausChannel = cudaq_runtime.KrausChannel

0 commit comments

Comments
 (0)