Skip to content

Commit

Permalink
Merge branch 'master' into nts-exponential-extrap
Browse files Browse the repository at this point in the history
  • Loading branch information
natestemen authored Jul 17, 2024
2 parents b1c57b6 + ddeb50c commit 169d53e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/install_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
tensorflow_version:
description: The version of TensorFlow to install for any job that requires TensorFlow
required: false
default: 2.16
default: 2.16.0
install_pytorch:
description: Indicate if PyTorch should be installed or not
required: false
Expand Down
16 changes: 11 additions & 5 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

<h3>New features since last release</h3>

* Resolved the bug in `qml.ThermalRelaxationError` where there was a typo from `tq` to `tg`.
[(#5988)](https://github.com/PennyLaneAI/pennylane/issues/5988)

* A new method `process_density_matrix` has been added to the `ProbabilityMP` and `DensityMatrixMP` classes, allowing for more efficient handling of quantum density matrices, particularly with batch processing support. This method simplifies the calculation of probabilities from quantum states represented as density matrices.
[(#5830)](https://github.com/PennyLaneAI/pennylane/pull/5830)

* The `qml.PrepSelPrep` template is added. The template implements a block-encoding of a linear
* The `qml.PrepSelPrep` template is added. The template implements a block-encoding of a linear
combination of unitaries.
[(#5756)](https://github.com/PennyLaneAI/pennylane/pull/5756)

* The `split_to_single_terms` transform is added. This transform splits expectation values of sums
into multiple single-term measurements on a single tape, providing better support for simulators
* The `split_to_single_terms` transform is added. This transform splits expectation values of sums
into multiple single-term measurements on a single tape, providing better support for simulators
that can handle non-commuting observables but don't natively support multi-term observables.
[(#5884)](https://github.com/PennyLaneAI/pennylane/pull/5884)

Expand All @@ -22,9 +25,12 @@
* New functionality has been added to natively support exponential extrapolation when using the `mitigate_with_zne`. This allows
users to have more control over the error mitigation protocol without needing to add further dependencies.
[(#5972)](https://github.com/PennyLaneAI/pennylane/pull/5972)

<h3>Improvements 🛠</h3>

* `StateMP.process_state` defines rules in `cast_to_complex` for complex casting, avoiding a superfluous state vector copy in Lightning simulations
[(#5995)](https://github.com/PennyLaneAI/pennylane/pull/5995)

* Port the fast `apply_operation` implementation of `PauliZ` to `PhaseShift`, `S` and `T`.
[(#5876)](https://github.com/PennyLaneAI/pennylane/pull/5876)

Expand All @@ -38,7 +44,7 @@

* The representation for `Wires` has now changed to be more copy-paste friendly.
[(#5958)](https://github.com/PennyLaneAI/pennylane/pull/5958)

* Observable validation for `default.qubit` is now based on execution mode (analytic vs. finite shots) and measurement type (sample measurement vs. state measurement).
[(#5890)](https://github.com/PennyLaneAI/pennylane/pull/5890)

Expand Down
14 changes: 11 additions & 3 deletions pennylane/measurements/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,18 @@ def shape(self, device, shots):

def process_state(self, state: Sequence[complex], wire_order: Wires):
# pylint:disable=redefined-outer-name
is_tf_interface = qml.math.get_deep_interface(state) == "tensorflow"
def cast_to_complex(state):
dtype = str(state.dtype)
if "complex" in dtype:
return state
if qml.math.get_interface(state) == "tensorflow":
return qml.math.cast(state, "complex128")
floating_single = "float32" in dtype or "complex64" in dtype
return qml.math.cast(state, "complex64" if floating_single else "complex128")

wires = self.wires
if not wires or wire_order == wires:
return qml.math.cast(state, "complex128") if is_tf_interface else state + 0.0j
return cast_to_complex(state)

if set(wires) != set(wire_order):
raise WireError(
Expand All @@ -190,7 +198,7 @@ def process_state(self, state: Sequence[complex], wire_order: Wires):
state = qml.math.reshape(state, shape)
state = qml.math.transpose(state, desired_axes)
state = qml.math.reshape(state, flat_shape)
return qml.math.cast(state, "complex128") if is_tf_interface else state + 0.0j
return cast_to_complex(state)

def process_density_matrix(self, density_matrix: Sequence[complex], wire_order: Wires):
# pylint:disable=redefined-outer-name
Expand Down
4 changes: 2 additions & 2 deletions pennylane/ops/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,8 @@ class ThermalRelaxationError(Channel):
num_wires = 1
grad_method = "F"

def __init__(self, pe, t1, t2, tq, wires, id=None):
super().__init__(pe, t1, t2, tq, wires=wires, id=id)
def __init__(self, pe, t1, t2, tg, wires, id=None):
super().__init__(pe, t1, t2, tg, wires=wires, id=id)

@staticmethod
def compute_kraus_matrices(pe, t1, t2, tg): # pylint:disable=arguments-differ
Expand Down

0 comments on commit 169d53e

Please sign in to comment.