diff --git a/qtensor/compression/Compressor.py b/qtensor/compression/Compressor.py index 65e28f8d..26d42a94 100644 --- a/qtensor/compression/Compressor.py +++ b/qtensor/compression/Compressor.py @@ -220,7 +220,7 @@ def compress(self, data): isCuPy, num_elements_eff = _get_data_info(data) dtype = data.dtype cmp_bytes, outSize_ptr = self.cuszx_compress(isCuPy, data, num_elements_eff, self.r2r_error, self.r2r_threshold) - # return (cmp_bytes, num_elements_eff, isCuPy, data.shape, dtype, outSize_ptr) + # return (cmpbytes, num_elements_eff, isCuPy, data.shape, dtype, outSize_ptr) return (cmp_bytes, num_elements_eff, isCuPy, data.shape, dtype, outSize_ptr.contents.value) @@ -526,9 +526,9 @@ def _gen_filename(self, info): def compress(self, data): import cupy if isinstance(data, cupy.ndarray): - isCupy=False - else: isCupy=True + else: + isCupy=False fname = self._gen_filename((data.dtype, data.shape, isCupy)) data.tofile(fname) return (fname, data.dtype, data.shape, isCupy) diff --git a/qtensor/contraction_backends/cupy.py b/qtensor/contraction_backends/cupy.py index ee4e4b6c..cb0ead28 100644 --- a/qtensor/contraction_backends/cupy.py +++ b/qtensor/contraction_backends/cupy.py @@ -99,7 +99,11 @@ def get_sliced_buckets(self, buckets, data_dict, slice_dict): # cp.argsort requires input to be cp array #print(tensor.indices) out_indices = list(sorted(tensor.indices, key=int, reverse=True)) - data = data_dict[tensor.data_key] + if tensor.data is None: + data = data_dict[tensor.data_key] + else: + data = tensor.data + #print(f"Data shape: {data.shape}, Tensor indices: {tensor.indices}, out_indices: {out_indices}") data, new_indices = slice_numpy_tensor(data, tensor.indices, out_indices, slice_dict) # transpose indices try: @@ -114,4 +118,4 @@ def get_sliced_buckets(self, buckets, data_dict, slice_dict): return sliced_buckets def get_result_data(self, result): - return cp.transpose(result.data) + return cp.transpose(result.data).get() diff --git a/qtensor/contraction_backends/performance_measurement_decorator.py b/qtensor/contraction_backends/performance_measurement_decorator.py index 39efffa7..e20008cd 100644 --- a/qtensor/contraction_backends/performance_measurement_decorator.py +++ b/qtensor/contraction_backends/performance_measurement_decorator.py @@ -85,7 +85,7 @@ def check_store(self): tensors_sizes=[len(tensor.indices) for tensor in self.object_store.values()] )) # -- - print('MH', self.mem_history[-1]) + #print('MH', self.mem_history[-1]) if cupy_mem>1024**2: self._print("CuPy memory usage", cupy_mem/1024/1024, "MB. Total MB:", mempool.total_bytes()/1024**2) diff --git a/second_try.nc b/second_try.nc deleted file mode 100644 index 8022d972..00000000 Binary files a/second_try.nc and /dev/null differ