From ca7cf6a122323f2c6e4d737ed22088a11c112e38 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:23:52 +0100 Subject: [PATCH 1/2] Update dependency pasqal-cloud to v0.12.5 (#611) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 74c612c9..7cbf030f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ allow-ambiguous-features = true pulser = [ "pulser-core==1.1.1", "pulser-simulation==1.1.1", - "pasqal-cloud==0.12.4", + "pasqal-cloud==0.12.5", ] visualization = [ "graphviz", From 465506538e151e541208433d9e1ef8844270ed14 Mon Sep 17 00:00:00 2001 From: chMoussa Date: Fri, 15 Nov 2024 12:21:23 +0100 Subject: [PATCH 2/2] [Bugfix] Fix noisy simulation pulser and test (#612) --- qadence/backends/pulser/backend.py | 27 +++++++-------------------- tests/conftest.py | 2 +- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/qadence/backends/pulser/backend.py b/qadence/backends/pulser/backend.py index 7eb383de..8d086af3 100644 --- a/qadence/backends/pulser/backend.py +++ b/qadence/backends/pulser/backend.py @@ -351,27 +351,14 @@ def expectation( noise=noise, ) support = sorted(list(circuit.abstract.register.support)) - # TODO: There should be a better check for batched density matrices. - if dms.size()[0] > 1: - res_list = [ - [ - obs.native( - dm.squeeze(), param_values, qubit_support=support, noise=noise - ) - for dm in dms - ] - for obs in observable - ] - res = torch.stack( - [torch.transpose(torch.stack(res), 0, -1) for res in res_list] - ) - - else: - res_list = [ - obs.native(dms, param_values, qubit_support=support) for obs in observable + res_list = [ + [ + obs.native(dm.squeeze(), param_values, qubit_support=support, noise=noise) + for dm in dms ] - res = torch.transpose(torch.stack(res_list), 0, 1) - res = res if len(res.shape) > 0 else res.reshape(1) + for obs in observable + ] + res = torch.stack([torch.transpose(torch.stack(res), 0, -1) for res in res_list]) return res.real elif mitigation is not None: logger.warning( diff --git a/tests/conftest.py b/tests/conftest.py index fbbb6364..9b0b9f91 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -33,7 +33,7 @@ def batched_noisy_pulser_sim() -> Tensor: @fixture def noisy_pulser_sim() -> Tensor: - return tensor([[[0.3043, 0.0000, 0.0000, -0.0038]]]) + return tensor([[0.3597]]) @fixture