Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into cm/call_setnoise_in_b…
Browse files Browse the repository at this point in the history
…ackend
  • Loading branch information
Charles MOUSSA committed Nov 15, 2024
2 parents ec4f614 + 4655065 commit 0a34191
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 7 additions & 20 deletions qadence/backends/pulser/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a34191

Please sign in to comment.