Skip to content

Commit b7f847c

Browse files
committed
Merge branch '22-11-0-1' into 'main'
Prepare for 22.11.0.1 hotfix release See merge request cuda-hpc-libraries/cuquantum-sdk/cuquantum-public!16
2 parents ac2d699 + 68824a7 commit b7f847c

File tree

7 files changed

+31
-25
lines changed

7 files changed

+31
-25
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22

33
BSD-3-Clause
44

python/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22

33
BSD-3-Clause
44

python/cuquantum/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# Note: cuQuantum Python follows the cuQuantum SDK version, which is now
66
# switched to YY.MM and is different from individual libraries' (semantic)
77
# versioning scheme.
8-
__version__ = '22.11.0'
8+
__version__ = '22.11.0.1'

python/cuquantum/cutensornet/_internal/circuit_converter_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def infer_parser(circuit):
5050
Infer the package that defines the circuit object.
5151
"""
5252
if qiskit and isinstance(circuit, qiskit.QuantumCircuit):
53-
qiskit_version = qiskit.__qiskit_version__['qiskit'] # qiskit metapackage version
53+
import importlib.metadata
54+
qiskit_version = importlib.metadata.version('qiskit') # qiskit metapackage version
5455
check_version('qiskit', qiskit_version, QISKIT_MIN_VERSION)
5556
return circuit_parser_utils_qiskit
5657
elif cirq and isinstance(circuit, cirq.Circuit):

python/cuquantum/cutensornet/_internal/utils.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,27 +185,22 @@ def create_empty_tensor(cls, extents, dtype, device_id, stream_ctx):
185185
return tensor
186186

187187

188-
def create_output_tensor(cls, package, output, size_dict, device_id, data_type):
188+
def create_output_tensor(cls, package, output, size_dict, device_id, stream, data_type):
189189
"""
190190
Create output tensor and associated data (modes, extents, strides). This operation is
191-
blocking and is safe to use with asynchronous memory pools.
191+
ordered through events and is safe to use with asynchronous memory pools.
192192
"""
193193
modes = tuple(m for m in output)
194194
extents = tuple(size_dict[m] for m in output)
195195

196-
package_ifc = package_wrapper.PACKAGE[package]
197-
198-
stream = package_ifc.create_stream(device_id)
199-
stream, stream_ctx, _ = _create_stream_ctx_ptr_cupy_stream(package_ifc, stream)
196+
stream, stream_ctx, _ = get_or_create_stream(device_id, stream, package)
200197

201198
with device_ctx(device_id):
202-
start = stream.record()
203199
output = create_empty_tensor(cls, extents, data_type, device_id, stream_ctx)
204-
end = stream.record()
205-
end.synchronize()
200+
output_event = stream.record()
206201

207202
strides = output.strides
208-
return output, modes, extents, strides
203+
return output, output_event, modes, extents, strides
209204

210205

211206
def get_network_device_id(operands):
@@ -494,16 +489,10 @@ def get_mpi_comm_pointer(comm):
494489
Returns:
495490
tuple: A pair of int values representing the address and the size.
496491
"""
497-
# We won't initialize MPI for users in any case
498492
try:
499-
import mpi4py
500-
init = mpi4py.rc.initialize
501-
mpi4py.rc.initialize = False
502-
from mpi4py import MPI
493+
from mpi4py import MPI # init!
503494
except ImportError as e:
504495
raise RuntimeError("please install mpi4py") from e
505-
finally:
506-
mpi4py.rc.initialize = init
507496

508497
if not isinstance(comm, MPI.Comm):
509498
raise ValueError("invalid MPI communicator")

python/cuquantum/cutensornet/tensor_network.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,12 @@ def __init__(self, *operands, qualifiers=None, options=None):
233233
num_modes_in = tuple(len(m) for m in modes_in)
234234
self.qualifiers_in = utils.check_tensor_qualifiers(qualifiers, cutn.tensor_qualifiers_dtype, num_inputs)
235235

236-
self.contraction, modes_out, extents_out, strides_out = utils.create_output_tensor(
237-
self.output_class, self.package, self.output, self.size_dict, self.device_id, self.data_type)
236+
# Create the output in the context of the current stream to work around a performance issue with CuPy's memory pool.
237+
stream = None
238+
self.logger.debug("Beginning output tensor creation...")
239+
self.contraction, self.contraction_output_event, modes_out, extents_out, strides_out = utils.create_output_tensor(
240+
self.output_class, self.package, self.output, self.size_dict, self.device_id, stream, self.data_type)
241+
self.logger.debug("The output tensor has been created.")
238242

239243
# Create/set handle.
240244
if options.handle is not None:
@@ -631,7 +635,13 @@ def autotune(self, *, iterations=3, stream=None):
631635

632636
# Check if we still hold an output tensor; if not, create a new one.
633637
if self.contraction is None:
638+
self.logger.debug("Beginning output (empty) tensor creation...")
634639
self.contraction = utils.create_empty_tensor(self.output_class, self.extents_out, self.data_type, self.device_id, stream_ctx)
640+
self.logger.debug("The output (empty) tensor has been created.")
641+
elif self.contraction_output_event is not None:
642+
stream.wait_event(self.contraction_output_event)
643+
self.contraction_output_event = None
644+
self.logger.debug("Established ordering with output tensor creation event.")
635645

636646
timing = bool(self.logger and self.logger.handlers)
637647
self.logger.info(f"Starting autotuning...")
@@ -716,7 +726,13 @@ def contract(self, *, slices=None, stream=None):
716726

717727
# Check if we still hold an output tensor; if not, create a new one.
718728
if self.contraction is None:
729+
self.logger.debug("Beginning output (empty) tensor creation...")
719730
self.contraction = utils.create_empty_tensor(self.output_class, self.extents_out, self.data_type, self.device_id, stream_ctx)
731+
self.logger.debug("The output (empty) tensor has been created.")
732+
elif self.contraction_output_event is not None:
733+
stream.wait_event(self.contraction_output_event)
734+
self.contraction_output_event = None
735+
self.logger.debug("Established ordering with output tensor creation event.")
720736

721737
# Create a slice group for contraction.
722738
slice_group = None

python/samples/cutensornet/circuit_converter/qiskit_basic.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@
128128
"print(type(sv))\n",
129129
"\n",
130130
"# check if the computed statevector is correct\n",
131-
"circuit.save_statevector()\n",
132131
"simulator = qiskit.Aer.get_backend('aer_simulator_statevector')\n",
132+
"circuit.save_statevector()\n",
133133
"circ = qiskit.transpile(circuit, simulator)\n",
134134
"result = simulator.run(circ).result()\n",
135135
"sv_qiskit = np.asarray(result.get_statevector()).reshape([2]*num_qubits)\n",
@@ -327,7 +327,7 @@
327327
"name": "python",
328328
"nbconvert_exporter": "python",
329329
"pygments_lexer": "ipython3",
330-
"version": "3.9.12"
330+
"version": "3.9.15"
331331
}
332332
},
333333
"nbformat": 4,

0 commit comments

Comments
 (0)