Repository: PennyLaneAI/pennylane
Pull request #3429 (2022-11-28 17:23:12)

Replace make_tape with make_qscript
**Context:**
`make_tape` returns a `QuantumTape`, but we're moving away from those and instead prefer `QuantumScript` instances, using `AnnotatedQueue` objects when necessary to generate one.

**Description of the Change:**
- Adds `make_qscript`, which queues operations, then turns them in to a `QuantumScript` as required.
- Replaces `make_tape` with `make_qscript` everywhere (not: this does _not_ remove `make_tape`)

**Benefits:**
We are using preferred pennylane classes. This will later allow us to replace all instances of `with QuantumTape() as tape` with `make_qscript()`.

**Possible Drawbacks:**
Probably none. Maybe someone is expecting a tape (which has the queuing functionality) when using something like `@qml.qfunc_transform`, which is now internally built using QuantumScripts rather than QuantumTapes.

github-actions[bot]: Hello. You may have forgotten to update the changelog!
Please edit [`doc/releases/changelog-dev.md`](/PennyLaneAI/pennylane/blob/master/doc/releases/changelog-dev.md) with:
* A one-to-two sentence description of the change. You may include a small working example for new features.
* A link back to this PR.
* Your name (or GitHub username) in the contributors section.
codecov[bot]: # [Codecov](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) Report
> Merging [#3429](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) (2291145) into [master](https://codecov.io/gh/PennyLaneAI/pennylane/commit/9096023b355772b016f6bd59718b34b75158a288?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) (9096023) will **decrease** coverage by `0.02%`.
> The diff coverage is `98.11%`.

> :exclamation: Current head 2291145 differs from pull request most recent head f281781. Consider uploading reports for the commit f281781 to get more accurate results

```diff
@@            Coverage Diff             @@
##           master    #3429      +/-   ##
==========================================
- Coverage   99.70%   99.68%   -0.03%     
==========================================
  Files         299      299              
  Lines       26637    26636       -1     
==========================================
- Hits        26558    26551       -7     
- Misses         79       85       +6     
```


| [Impacted Files](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) | Coverage Δ | |
|---|---|---|
| [pennylane/transforms/tape\_expand.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RyYW5zZm9ybXMvdGFwZV9leHBhbmQucHk=) | `100.00% <ø> (ø)` | |
| [pennylane/transforms/qfunc\_transforms.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RyYW5zZm9ybXMvcWZ1bmNfdHJhbnNmb3Jtcy5weQ==) | `92.85% <88.88%> (-7.15%)` | :arrow_down: |
| [pennylane/ops/functions/simplify.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL29wcy9mdW5jdGlvbnMvc2ltcGxpZnkucHk=) | `100.00% <100.00%> (ø)` | |
| [pennylane/ops/op\_math/control.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL29wcy9vcF9tYXRoL2NvbnRyb2wucHk=) | `100.00% <100.00%> (ø)` | |
| [pennylane/tape/\_\_init\_\_.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RhcGUvX19pbml0X18ucHk=) | `100.00% <100.00%> (ø)` | |
| [pennylane/tape/qscript.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RhcGUvcXNjcmlwdC5weQ==) | `100.00% <100.00%> (ø)` | |
| [pennylane/templates/subroutines/hilbert\_schmidt.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RlbXBsYXRlcy9zdWJyb3V0aW5lcy9oaWxiZXJ0X3NjaG1pZHQucHk=) | `100.00% <100.00%> (ø)` | |
| [pennylane/transforms/commutation\_dag.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RyYW5zZm9ybXMvY29tbXV0YXRpb25fZGFnLnB5) | `100.00% <100.00%> (ø)` | |
| [pennylane/transforms/condition.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RyYW5zZm9ybXMvY29uZGl0aW9uLnB5) | `100.00% <100.00%> (ø)` | |
| [pennylane/transforms/op\_transforms.py](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#diff-cGVubnlsYW5lL3RyYW5zZm9ybXMvb3BfdHJhbnNmb3Jtcy5weQ==) | `100.00% <100.00%> (ø)` | |
| ... and [3 more](https://codecov.io/gh/PennyLaneAI/pennylane/pull/3429/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI)


Patch:
diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md
index c5670f455..f27bc4b98 100644
--- a/doc/releases/changelog-dev.md
+++ b/doc/releases/changelog-dev.md
@@ -160,6 +160,10 @@
   its functionality from the `QuantumTape` class.
   [(#3401)](https://github.com/PennyLaneAI/pennylane/pull/3401)
 
+* Adds `qml.tape.make_qscript` for converting a quantum function into a quantum script.
+  Replaces `qml.transforms.make_tape` with `make_qscript`.
+  [(#3429)](https://github.com/PennyLaneAI/pennylane/pull/3429)
+
 <h4>Return types project</h4>
 
 * The autograd interface for the new return types now supports devices with shot vectors.
diff --git a/pennylane/ops/functions/simplify.py b/pennylane/ops/functions/simplify.py
index 9b13793df..89abafa9f 100644
--- a/pennylane/ops/functions/simplify.py
+++ b/pennylane/ops/functions/simplify.py
@@ -23,8 +23,7 @@ from pennylane.measurements import MeasurementProcess
 from pennylane.operation import Operator
 from pennylane.qnode import QNode
 from pennylane.queuing import QueuingManager
-from pennylane.tape import QuantumScript
-from pennylane.transforms import make_tape
+from pennylane.tape import QuantumScript, make_qscript
 
 
 def simplify(input: Union[Operator, MeasurementProcess, QuantumScript, QNode, Callable]):
@@ -104,9 +103,9 @@ def simplify(input: Union[Operator, MeasurementProcess, QuantumScript, QNode, Ca
 
         @wraps(old_qfunc)
         def qfunc(*args, **kwargs):
-            tape = make_tape(old_qfunc)(*args, **kwargs)
-            _ = [qml.simplify(op) for op in tape.operations]
-            m = tuple(qml.simplify(m) for m in tape.measurements)
+            qs = make_qscript(old_qfunc)(*args, **kwargs)
+            _ = [qml.simplify(op) for op in qs.operations]
+            m = tuple(qml.simplify(m) for m in qs.measurements)
             return m[0] if len(m) == 1 else m
 
         if isinstance(input, QNode):
diff --git a/pennylane/ops/op_math/control.py b/pennylane/ops/op_math/control.py
index 1b1c6e212..cdcca7551 100644
--- a/pennylane/ops/op_math/control.py
+++ b/pennylane/ops/op_math/control.py
@@ -91,10 +91,10 @@ def ctrl(op, control, control_values=None, work_wires=None):
 
     @wraps(op)
     def wrapper(*args, **kwargs):
-        tape = qml.transforms.make_tape(op)(*args, **kwargs)
+        qscript = qml.tape.make_qscript(op)(*args, **kwargs)
 
         # flip control_values == 0 wires here, so we don't have to do it for each individual op.
-        flip_control_on_zero = (len(tape) > 1) and (control_values is not None)
+        flip_control_on_zero = (len(qscript) > 1) and (control_values is not None)
         op_control_values = None if flip_control_on_zero else control_values
         if flip_control_on_zero:
             _ = [qml.PauliX(w) for w, val in zip(control, control_values) if not val]
@@ -103,15 +103,15 @@ def ctrl(op, control, control_values=None, work_wires=None):
             Controlled(
                 op, control_wires=control, control_values=op_control_values, work_wires=work_wires
             )
-            for op in tape.operations
+            for op in qscript.operations
         ]
 
         if flip_control_on_zero:
             _ = [qml.PauliX(w) for w, val in zip(control, control_values) if not val]
 
         if qml.QueuingManager.recording():
-            _ = [qml.apply(m) for m in tape.measurements]
+            _ = [qml.apply(m) for m in qscript.measurements]
 
-        return tape.measurements
+        return qscript.measurements
 
     return wrapper
diff --git a/pennylane/tape/__init__.py b/pennylane/tape/__init__.py
index 156dd026a..1174aaceb 100644
--- a/pennylane/tape/__init__.py
+++ b/pennylane/tape/__init__.py
@@ -18,5 +18,5 @@ validates quantum operations and measurements.
 
 from .tape import QuantumTape, TapeError
 from .operation_recorder import OperationRecorder
-from .qscript import QuantumScript
+from .qscript import QuantumScript, make_qscript
 from .unwrap import Unwrap, UnwrapTape
diff --git a/pennylane/tape/qscript.py b/pennylane/tape/qscript.py
index f3d19622f..0fdf00d4d 100644
--- a/pennylane/tape/qscript.py
+++ b/pennylane/tape/qscript.py
@@ -32,6 +32,7 @@ from pennylane.measurements import (
     ShadowExpval,
 )
 from pennylane.operation import Observable, Operator
+from pennylane.queuing import AnnotatedQueue, process_queue
 
 _empty_wires = qml.wires.Wires([])
 
@@ -774,16 +775,7 @@ class QuantumScript:
 
             wires_num_set = {len(meas.wires) for meas in mps}
             same_num_wires = len(wires_num_set) == 1
-            if same_num_wires:
-                # All probability measurements have the same number of
-                # wires, gather the length from the first one
-
-                len_wires = len(mps[0].wires)
-                dim = mps[0]._get_num_basis_states(len_wires, device)
-                shot_copies_sum = sum(s.copies for s in shot_vector)
-                shape = (shot_copies_sum, len(mps), dim)
-
-            else:
+            if not same_num_wires:
                 # There is a varying number of wires that the probability
                 # measurement processes act on
                 # TODO: revisit when issues with this case are resolved
@@ -792,6 +784,13 @@ class QuantumScript:
                     "along with a device that defines a shot vector is not supported."
                 )
 
+            # All probability measurements have the same number of
+            # wires, gather the length from the first one
+
+            len_wires = len(mps[0].wires)
+            dim = mps[0]._get_num_basis_states(len_wires, device)
+            shape = sum(s.copies for s in shot_vector), len(mps), dim
+
         elif ret_type == qml.measurements.Sample:
             shape = []
             for shot_val in device.shot_vector:
@@ -849,7 +848,7 @@ class QuantumScript:
 
         if device._shot_vector is None and self.batch_size is not None:
             # insert the batch dimension
-            output_shape = output_shape[0:1] + (self.batch_size,) + output_shape[1:]
+            output_shape = output_shape[:1] + (self.batch_size,) + output_shape[1:]
 
         return output_shape
 
@@ -1293,3 +1292,54 @@ class QuantumScript:
                 qasm_str += f"measure q[{wire_indx}] -> c[{wire_indx}];\n"
 
         return qasm_str
+
+
+def make_qscript(fn):
+    """Returns a function that generates a qscript from a quantum function without any
+    operation queuing taking place.
+
+    This is useful when you would like to manipulate or transform
+    the qscript created by a quantum function without evaluating it.
+
+    Args:
+        fn (function): the quantum function to generate the qscript from
+
+    Returns:
+        function: The returned function takes the same arguments as the quantum
+        function. When called, it returns the generated quantum script
+        without any queueing occuring.
+
+    **Example**
+
+    Consider the following quantum function:
+
+    .. code-block:: python
+
+        def qfunc(x):
+            qml.Hadamard(wires=0)
+            qml.CNOT(wires=[0, 1])
+            qml.RX(x, wires=0)
+
+    We can use ``make_qscript`` to extract the qscript generated by this
+    quantum function, without any of the operations being queued by
+    any existing queuing contexts:
+
+    >>> with qml.queuing.AnnotatedQueue() as active_queue:
+    ...     _ = qml.RY(1.0, wires=0)
+    ...     qs = make_qscript(qfunc)(0.5)
+    >>> qs.operations
+    [Hadamard(wires=[0]), CNOT(wires=[0, 1]), RX(0.5, wires=[0])]
+
+    Note that the currently recording queue did not queue any of these quantum operations:
+
+    >>> active_queue.queue
+    [RY(1.0, wires=[0])]
+    """
+
+    def wrapper(*args, **kwargs):
+        with qml.QueuingManager.stop_recording(), AnnotatedQueue() as q:
+            fn(*args, **kwargs)
+
+        return QuantumScript(*process_queue(q))
+
+    return wrapper
diff --git a/pennylane/transforms/commutation_dag.py b/pennylane/transforms/commutation_dag.py
index bc80d4d46..cc6f01f16 100644
--- a/pennylane/transforms/commutation_dag.py
+++ b/pennylane/transforms/commutation_dag.py
@@ -22,7 +22,7 @@ import networkx as nx
 from networkx.drawing.nx_pydot import to_pydot
 
 import pennylane as qml
-from pennylane.tape import QuantumScript
+from pennylane.tape import QuantumScript, make_qscript
 from pennylane.wires import Wires
 
 
@@ -107,7 +107,7 @@ def commutation_dag(circuit):
 
         elif callable(circuit):
             # user passed something that is callable but not a tape or qnode.
-            tape = qml.transforms.make_tape(circuit)(*args, **kwargs)
+            tape = make_qscript(circuit)(*args, **kwargs)
             # raise exception if it is not a quantum function
             if len(tape.operations) == 0:
                 raise ValueError("Function contains no quantum operation")
diff --git a/pennylane/transforms/condition.py b/pennylane/transforms/condition.py
index 8fb9f2169..766f00959 100644
--- a/pennylane/transforms/condition.py
+++ b/pennylane/transforms/condition.py
@@ -19,7 +19,7 @@ from typing import Type
 
 from pennylane.measurements import MeasurementValue
 from pennylane.operation import AnyWires, Operation
-from pennylane.transforms import make_tape
+from pennylane.tape import make_qscript
 
 
 class ConditionalTransformError(ValueError):
@@ -43,7 +43,7 @@ class Conditional(Operation):
         expr (MeasurementValue): the measurement outcome value to consider
         then_op (Operation): the PennyLane operation to apply conditionally
         do_queue (bool): indicates whether the operator should be
-            recorded when created in a tape context
+            recorded when created in a qscript context
         id (str): custom label given to an operator instance,
             can be useful for some applications where the instance has to be identified
     """
@@ -251,24 +251,24 @@ def cond(condition, true_fn, false_fn=None):
             # We assume that the callable is a quantum function
 
             # 1. Apply true_fn conditionally
-            tape = make_tape(true_fn)(*args, **kwargs)
+            qscript = make_qscript(true_fn)(*args, **kwargs)
 
-            if tape.measurements:
+            if qscript.measurements:
                 raise ConditionalTransformError(with_meas_err)
 
-            for op in tape.operations:
+            for op in qscript.operations:
                 Conditional(condition, op)
 
             if false_fn is not None:
                 # 2. Apply false_fn conditionally
-                else_tape = make_tape(false_fn)(*args, **kwargs)
+                else_qscript = make_qscript(false_fn)(*args, **kwargs)
 
-                if else_tape.measurements:
+                if else_qscript.measurements:
                     raise ConditionalTransformError(with_meas_err)
 
                 inverted_condition = ~condition
 
-                for op in else_tape.operations:
+                for op in else_qscript.operations:
                     Conditional(inverted_condition, op)
 
     else:
diff --git a/pennylane/transforms/op_transforms.py b/pennylane/transforms/op_transforms.py
index e8fe73547..9cdc1bd2d 100644
--- a/pennylane/transforms/op_transforms.py
+++ b/pennylane/transforms/op_transforms.py
@@ -495,7 +495,7 @@ class op_transform:
 
         elif callable(obj):
             # user passed something that is callable but not a tape or QNode.
-            tape = qml.transforms.make_tape(obj)(*args, **kwargs)
+            tape = qml.tape.make_qscript(obj)(*args, **kwargs)
             wires = tape.wires
 
             # raise exception if it is not a quantum function
diff --git a/pennylane/transforms/qfunc_transforms.py b/pennylane/transforms/qfunc_transforms.py
index b698f47a4..b49334e6a 100644
--- a/pennylane/transforms/qfunc_transforms.py
+++ b/pennylane/transforms/qfunc_transforms.py
@@ -20,6 +20,7 @@ import os
 import warnings
 
 import pennylane as qml
+from pennylane.tape import make_qscript
 
 
 def make_tape(fn):
@@ -65,9 +66,7 @@ def make_tape(fn):
     """
 
     def wrapper(*args, **kwargs):
-        active_tape = qml.QueuingManager.active_context()
-        new_tape = qml.tape.QuantumTape() if active_tape is None else active_tape.__class__()
-        with qml.QueuingManager.stop_recording(), new_tape:
+        with qml.QueuingManager.stop_recording(), qml.tape.QuantumTape() as new_tape:
             fn(*args, **kwargs)
 
         return new_tape
@@ -75,20 +74,6 @@ def make_tape(fn):
     return wrapper
 
 
-class NonQueuingTape(qml.queuing.AnnotatedQueue):
-    """Mixin class that creates a tape that does not queue
-    itself to the current queuing context."""
-
-    def _process_queue(self):
-        # accesses the parent of the target class that NonQueingTape is mixed into
-        super()._process_queue()  # pylint:disable=no-member
-
-        for obj, info in self.items():
-            qml.queuing.QueuingManager.append(obj, **info)
-
-        qml.queuing.QueuingManager.remove(self)
-
-
 class single_tape_transform:
     """For registering a tape transform that takes a tape and outputs a single new tape.
 
@@ -159,16 +144,12 @@ class single_tape_transform:
         functools.update_wrapper(self, transform_fn)
 
     def __call__(self, tape, *args, **kwargs):
-        tape_class = type(tape.__class__.__name__, (NonQueuingTape, tape.__class__), {})
-
-        # new_tape, when first created, is of the class (NonQueuingTape, tape.__class__), so that it
-        # doesn't result in a nested tape
-        with tape_class() as new_tape:
+        with qml.queuing.AnnotatedQueue() as q:
             self.transform_fn(tape, *args, **kwargs)
-
-        # Once we're done, revert it back to be simply an instance of tape.__class__.
-        new_tape.__class__ = tape.__class__
-        return new_tape
+        qs = qml.tape.QuantumScript(*qml.queuing.process_queue(q))
+        for obj, info in q.items():
+            qml.queuing.QueuingManager.append(obj, **info)
+        return qs
 
 
 def _create_qfunc_internal_wrapper(fn, tape_transform, transform_args, transform_kwargs):
@@ -184,7 +165,7 @@ def _create_qfunc_internal_wrapper(fn, tape_transform, transform_args, transform
 
         return new_dev
 
-    if isinstance(fn, qml.tape.QuantumTape):
+    if isinstance(fn, qml.tape.QuantumScript):
         return tape_transform(fn, *transform_args, **transform_kwargs)
 
     if not callable(fn):
@@ -195,7 +176,7 @@ def _create_qfunc_internal_wrapper(fn, tape_transform, transform_args, transform
 
     @functools.wraps(fn)
     def internal_wrapper(*args, **kwargs):
-        tape = make_tape(fn)(*args, **kwargs)
+        tape = make_qscript(fn)(*args, **kwargs)
         tape = tape_transform(tape, *transform_args, **transform_kwargs)
 
         if len(tape.measurements) == 1:
@@ -352,15 +333,15 @@ def qfunc_transform(tape_transform):
 
             def transform(old_qfunc, params):
                 def new_qfunc(*args, **kwargs):
-                    # 1. extract the tape from the old qfunc, being
+                    # 1. extract the QuantumScript from the old qfunc, being
                     # careful *not* to have it queued.
-                    tape = make_tape(old_qfunc)(*args, **kwargs)
+                    qscript = make_qscript(old_qfunc)(*args, **kwargs)
 
-                    # 2. transform the tape
-                    new_tape = tape_transform(tape, params)
+                    # 2. transform the qscript
+                    new_script = tape_transform(qscript, params)
 
-                    # 3. queue the *new* tape to the active queuing context
-                    new_tape.queue()
+                    # 3. queue the *new* qscript to the active queuing context
+                    new_script.queue()
                 return new_qfunc
 
         *Note: this is pseudocode; the actual implementation is significantly more complicated!*
diff --git a/pennylane/transforms/tape_expand.py b/pennylane/transforms/tape_expand.py
index f9a4c1d03..36d943309 100644
--- a/pennylane/transforms/tape_expand.py
+++ b/pennylane/transforms/tape_expand.py
@@ -28,11 +28,6 @@ from pennylane.operation import (
     not_tape,
 )
 
-# Needed for custom decomposition context manager
-from pennylane.transforms.qfunc_transforms import NonQueuingTape
-
-NonQueuingTape = type("NonQueuingTape", (NonQueuingTape, qml.tape.QuantumTape), {})
-
 
 def _update_trainable_params(tape):
     params = tape.get_parameters(trainable_only=False)


Test patch:
diff --git a/tests/tape/test_qscript.py b/tests/tape/test_qscript.py
index 364479cd7..5d5156601 100644
--- a/tests/tape/test_qscript.py
+++ b/tests/tape/test_qscript.py
@@ -148,7 +148,7 @@ class TestUpdate:
             qml.measurements.Shadow,
             qml.measurements.ShadowExpval,
         )
-        assert qs.samples_computational_basis is (True if shadow_mp else False)
+        assert qs.samples_computational_basis is shadow_mp
 
         qs = QuantumScript(measurements=[sample_ms, sample_ms, qml.sample()])
         assert qs.is_sampled is True
@@ -725,3 +725,60 @@ class TestQScriptDraw:
 
         assert qs.draw() == qml.drawer.tape_text(qs)
         assert qs.draw(max_length=20) == qml.drawer.tape_text(qs, max_length=20)
+
+
+class TestMakeQscript:
+    """Test the make_qscript method."""
+
+    def test_ops_are_recorded_to_qscript(self):
+        """Test make_qscript records operations from the quantum function passed to it."""
+
+        def qfunc():
+            qml.Hadamard(0)
+            qml.CNOT([0, 1])
+            qml.expval(qml.PauliX(0))
+
+        qscript = qml.tape.make_qscript(qfunc)()
+        assert len(qscript.operations) == 2
+        assert len(qscript.measurements) == 1
+
+    def test_qfunc_is_recording_during_make_qscript(self):
+        """Test that quantum functions passed to make_qscript run in a recording context."""
+
+        def assert_recording():
+            assert qml.QueuingManager.recording()
+
+        qml.tape.make_qscript(assert_recording)()
+
+    def test_ops_are_not_recorded_to_surrounding_context(self):
+        """Test that ops are not recorded to any surrounding context during make_qscript."""
+
+        def qfunc():
+            qml.Hadamard(0)
+            qml.CNOT([0, 1])
+
+        with qml.queuing.AnnotatedQueue() as q:
+            recorded_op = qml.PauliX(0)
+            qscript = qml.tape.make_qscript(qfunc)()
+        assert q.queue == [recorded_op]
+        assert len(qscript.operations) == 2
+
+    def test_make_qscript_returns_callable(self):
+        """Test that make_qscript returns a callable."""
+
+        def qfunc():
+            qml.Hadamard(0)
+
+        assert callable(qml.tape.make_qscript(qfunc))
+
+    def test_non_queued_ops_are_not_recorded(self):
+        """Test that ops are not recorded to the qscript when recording is disabled."""
+
+        def qfunc():
+            qml.PauliX(0)
+            with qml.QueuingManager.stop_recording():
+                qml.Hadamard(0)
+
+        qscript = qml.tape.make_qscript(qfunc)()
+        assert len(qscript.operations) == 1
+        assert qscript.operations[0].name == "PauliX"
diff --git a/tests/transforms/test_op_transform.py b/tests/transforms/test_op_transform.py
index 5eefa98b2..e29b28966 100644
--- a/tests/transforms/test_op_transform.py
+++ b/tests/transforms/test_op_transform.py
@@ -234,9 +234,7 @@ class TestTransformParameters:
 
         @qml.op_transform
         def my_transform(op, lower=False):
-            if lower:
-                return op.name.lower()
-            return op.name
+            return op.name.lower() if lower else op.name
 
         op = qml.RX(0.5, wires=0)
         res = my_transform(op, lower=True)
@@ -247,9 +245,7 @@ class TestTransformParameters:
 
         @qml.op_transform
         def my_transform(op, lower=False):
-            if lower:
-                return op.name.lower()
-            return op.name
+            return op.name.lower() if lower else op.name
 
         res = my_transform(qml.RX, lower=True)(0.5, wires=0)
         assert res == "rx"
@@ -260,9 +256,7 @@ class TestTransformParameters:
 
         @qml.op_transform
         def my_transform(op, lower=False):
-            if lower:
-                return op.name.lower()
-            return op.name
+            return op.name.lower() if lower else op.name
 
         @my_transform.tape_transform
         def my_transform(tape, lower=False):
diff --git a/tests/transforms/test_optimization/test_cancel_inverses.py b/tests/transforms/test_optimization/test_cancel_inverses.py
index 542156b95..f1eb42746 100644
--- a/tests/transforms/test_optimization/test_cancel_inverses.py
+++ b/tests/transforms/test_optimization/test_cancel_inverses.py
@@ -32,7 +32,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        new_tape = qml.transforms.make_tape(transformed_qfunc)()
+        new_tape = qml.tape.make_qscript(transformed_qfunc)()
 
         assert len(new_tape.operations) == 0
 
@@ -45,7 +45,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        new_tape = qml.transforms.make_tape(transformed_qfunc)()
+        new_tape = qml.tape.make_qscript(transformed_qfunc)()
 
         assert len(new_tape.operations) == 0
 
@@ -58,7 +58,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        new_tape = qml.transforms.make_tape(transformed_qfunc)()
+        new_tape = qml.tape.make_qscript(transformed_qfunc)()
 
         assert len(new_tape.operations) == 0
 
@@ -71,7 +71,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        new_tape = qml.transforms.make_tape(transformed_qfunc)()
+        new_tape = qml.tape.make_qscript(transformed_qfunc)()
 
         assert len(new_tape.operations) == 0
 
@@ -84,7 +84,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        new_tape = qml.transforms.make_tape(transformed_qfunc)()
+        new_tape = qml.tape.make_qscript(transformed_qfunc)()
 
         assert len(new_tape.operations) == 0
 
@@ -98,7 +98,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["Hadamard", "RZ", "Hadamard"]
         wires_expected = [Wires(0)] * 3
@@ -113,7 +113,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["Hadamard"] * 2
         wires_expected = [Wires(0), Wires(1)]
@@ -131,7 +131,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["Hadamard", "CNOT", "RZ"]
         wires_expected = [Wires(0), Wires([0, 2]), Wires(2)]
@@ -149,7 +149,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["Hadamard", "PauliX", "CNOT", "RZ", "PauliX"]
         wires_expected = [Wires(0), Wires(1), Wires([0, 1]), Wires(2), Wires(1)]
@@ -169,7 +169,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["Toffoli"] * 3
         wires_expected = [Wires(["a", "b", "c"]), Wires(["a", "c", "b"]), Wires(["a", "c", "d"])]
@@ -184,7 +184,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == 0
 
@@ -197,7 +197,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["CNOT"] * 2
         wires_expected = [Wires([0, 1]), Wires([1, 0])]
@@ -212,7 +212,7 @@ class TestCancelInverses:
 
         transformed_qfunc = cancel_inverses(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == 0
 
diff --git a/tests/transforms/test_optimization/test_commute_controlled.py b/tests/transforms/test_optimization/test_commute_controlled.py
index a634c942e..9e347be42 100644
--- a/tests/transforms/test_optimization/test_commute_controlled.py
+++ b/tests/transforms/test_optimization/test_commute_controlled.py
@@ -38,7 +38,7 @@ class TestCommuteControlled:
         transformed_qfunc = commute_controlled(direction="sideways")(qfunc)
 
         with pytest.raises(ValueError, match="must be 'left' or 'right'"):
-            ops = qml.transforms.make_tape(transformed_qfunc)().operations
+            ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
     @pytest.mark.parametrize("direction", [("left"), ("right")])
     def test_gate_with_no_basis(self, direction):
@@ -51,7 +51,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled(direction=direction)(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["PauliX", "ControlledQubitUnitary", "PauliX"]
         wires_expected = [Wires(2), Wires([0, 2]), Wires(2)]
@@ -68,7 +68,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled(direction=direction)(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["PauliZ", "CNOT", "PauliY"]
         wires_expected = [Wires("b"), Wires([2, "b"]), Wires("b")]
@@ -88,7 +88,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["CNOT", "Toffoli", "PauliX", "RX", "CRX", "SX", "PauliX"]
         wires_expected = [
@@ -116,7 +116,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled(direction="left")(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = [
             "PauliX",
@@ -150,7 +150,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled(direction=direction)(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["PauliX", "CNOT", "RX", "Toffoli"]
         wires_expected = [Wires("a"), Wires(["a", "c"]), Wires("a"), Wires(["c", "a", "b"])]
@@ -168,7 +168,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["CRY", "PauliY", "CNOT", "CY", "RY"]
         wires_expected = [Wires(["a", 2]), Wires(2), Wires([1, 2]), Wires(["a", 1]), Wires(1)]
@@ -186,7 +186,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled(direction="left")(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["PauliY", "CRY", "CNOT", "RY", "CY"]
         wires_expected = [Wires(2), Wires(["a", 2]), Wires([1, 2]), Wires(1), Wires(["a", 1])]
@@ -205,7 +205,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["CRY", "PauliY", "CNOT", "CY", "RY"]
         wires_expected = [Wires(["a", 2]), Wires("a"), Wires([1, 2]), Wires(["a", 1]), Wires("a")]
@@ -228,7 +228,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["CZ", "PauliZ", "CNOT", "PhaseShift", "CRZ", "S", "T", "PauliZ"]
         wires_expected = (
@@ -255,7 +255,7 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled(direction="left")(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["PauliZ", "S", "RZ", "T", "PauliZ", "CZ", "CNOT", "CRZ"]
         wires_expected = [Wires(2), Wires(0), Wires(2), Wires(0), Wires(0), Wires([0, 2])] + [
@@ -287,8 +287,8 @@ class TestCommuteControlled:
 
         transformed_qfunc = commute_controlled()(qfunc)
 
-        original_ops = qml.transforms.make_tape(qfunc)().operations
-        transformed_ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        original_ops = qml.tape.make_qscript(qfunc)().operations
+        transformed_ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(original_ops) == len(transformed_ops)
 
diff --git a/tests/transforms/test_optimization/test_merge_amplitude_embedding.py b/tests/transforms/test_optimization/test_merge_amplitude_embedding.py
index a5a3c6861..d3e61bfcb 100644
--- a/tests/transforms/test_optimization/test_merge_amplitude_embedding.py
+++ b/tests/transforms/test_optimization/test_merge_amplitude_embedding.py
@@ -34,7 +34,7 @@ class TestMergeAmplitudeEmbedding:
             qml.state()
 
         transformed_qfunc = merge_amplitude_embedding(qfunc)
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == 3
 
diff --git a/tests/transforms/test_optimization/test_merge_rotations.py b/tests/transforms/test_optimization/test_merge_rotations.py
index d1e5edcd7..829ebc17c 100644
--- a/tests/transforms/test_optimization/test_merge_rotations.py
+++ b/tests/transforms/test_optimization/test_merge_rotations.py
@@ -41,7 +41,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == len(expected_ops)
 
@@ -67,7 +67,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == len(expected_ops)
 
@@ -85,7 +85,7 @@ class TestMergeRotations:
         # Try with default tolerance; these ops should still be applied
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == 1
         assert ops[0].name == "RZ"
@@ -93,7 +93,7 @@ class TestMergeRotations:
 
         # Now try with higher tolerance threshold; the ops should cancel
         transformed_qfunc = merge_rotations(atol=1e-5)(qfunc)
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
         assert len(ops) == 0
 
     @pytest.mark.parametrize(
@@ -114,7 +114,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == len(expected_ops)
 
@@ -142,7 +142,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == len(expected_ops)
 
@@ -164,7 +164,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations(include_gates=["RX", "CRX"])(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["CRX", "RY", "RY", "RX", "RZ"]
         wires_expected = [Wires([0, 1]), Wires("a"), Wires("a"), Wires(2), Wires(2)]
@@ -185,7 +185,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["RX", "Hadamard", "RX"]
         wires_expected = [Wires(0)] * 3
@@ -205,7 +205,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["RX", "CNOT", "RX"]
         wires_expected = [Wires(0), Wires([0, 1]), Wires(0)]
@@ -230,7 +230,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == len(expected_ops)
 
@@ -248,7 +248,7 @@ class TestMergeRotations:
 
         transformed_qfunc = merge_rotations()(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["CRX", "CRX"]
         wires_expected = [Wires(["w1", "w2"]), Wires(["w2", "w1"])]
diff --git a/tests/transforms/test_optimization/test_single_qubit_fusion.py b/tests/transforms/test_optimization/test_single_qubit_fusion.py
index 198eaafe9..8a8391b2a 100644
--- a/tests/transforms/test_optimization/test_single_qubit_fusion.py
+++ b/tests/transforms/test_optimization/test_single_qubit_fusion.py
@@ -53,7 +53,7 @@ class TestSingleQubitFusion:
             qml.Hadamard(wires=1)
 
         transformed_qfunc = single_qubit_fusion()(qfunc)
-        transformed_ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        transformed_ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["RZ", "Hadamard"]
         wires_expected = [Wires(0), Wires(1)]
@@ -69,7 +69,7 @@ class TestSingleQubitFusion:
             qml.RZ(-0.1, wires=0)
 
         transformed_qfunc = single_qubit_fusion(atol=1e-7)(qfunc)
-        transformed_ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        transformed_ops = qml.tape.make_qscript(transformed_qfunc)().operations
         assert len(transformed_ops) == 0
 
     def test_single_qubit_fusion_not_implemented(self):
@@ -86,7 +86,7 @@ class TestSingleQubitFusion:
             qml.Hadamard(wires=0)
 
         transformed_qfunc = single_qubit_fusion()(qfunc)
-        transformed_ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        transformed_ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["Rot", "PauliRot", "Rot"]
         wires_expected = [Wires(0)] * 3
@@ -111,10 +111,10 @@ class TestSingleQubitFusion:
             # Excluded gate after multiple others
             qml.RZ(0.2, wires=1)
 
-        original_ops = qml.transforms.make_tape(qfunc)().operations
+        original_ops = qml.tape.make_qscript(qfunc)().operations
 
         transformed_qfunc = single_qubit_fusion(exclude_gates=["RZ"])(qfunc)
-        transformed_ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        transformed_ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["RZ", "Rot", "RZ", "CNOT", "Hadamard", "RZ", "Rot", "RZ"]
         wires_expected = (
@@ -143,8 +143,8 @@ class TestSingleQubitFusion:
 
         transformed_qfunc = single_qubit_fusion()(qfunc)
 
-        original_ops = qml.transforms.make_tape(qfunc)().operations
-        transformed_ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        original_ops = qml.tape.make_qscript(qfunc)().operations
+        transformed_ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         names_expected = ["Rot", "Rot", "CNOT", "Rot"]
         wires_expected = [Wires("a"), Wires("b"), Wires(["b", "a"]), Wires("b")]
diff --git a/tests/transforms/test_optimization/test_undo_swaps.py b/tests/transforms/test_optimization/test_undo_swaps.py
index 9df9b82de..b4ddfa9b2 100644
--- a/tests/transforms/test_optimization/test_undo_swaps.py
+++ b/tests/transforms/test_optimization/test_undo_swaps.py
@@ -35,7 +35,7 @@ class TestUndoSwaps:
 
         transformed_qfunc = undo_swaps(qfunc)
 
-        tape = qml.transforms.make_tape(transformed_qfunc)()
+        tape = qml.tape.make_qscript(transformed_qfunc)()
         res = qml.device("default.qubit", wires=2).execute(tape)
         assert len(tape.operations) == 2
         assert np.allclose(res[0][0], 0.5)
@@ -51,7 +51,7 @@ class TestUndoSwaps:
 
         transformed_qfunc = undo_swaps(qfunc)
 
-        tape = qml.transforms.make_tape(transformed_qfunc)()
+        tape = qml.tape.make_qscript(transformed_qfunc)()
         res = qml.device("default.qubit", wires=2).execute(tape)
         assert len(tape.operations) == 2
         assert np.allclose(res[0][2], 1.0)
@@ -74,10 +74,10 @@ class TestUndoSwaps:
 
         transformed_qfunc = undo_swaps(qfunc1)
 
-        tape1 = qml.transforms.make_tape(transformed_qfunc)()
+        tape1 = qml.tape.make_qscript(transformed_qfunc)()
         res1 = qml.device("default.qubit", wires=3).execute(tape1)
 
-        tape2 = qml.transforms.make_tape(qfunc2)()
+        tape2 = qml.tape.make_qscript(qfunc2)()
         res2 = qml.device("default.qubit", wires=3).execute(tape2)
 
         assert np.allclose(res1, res2)
@@ -101,10 +101,10 @@ class TestUndoSwaps:
 
         transformed_qfunc = undo_swaps(qfunc1)
 
-        tape1 = qml.transforms.make_tape(transformed_qfunc)()
+        tape1 = qml.tape.make_qscript(transformed_qfunc)()
         res1 = qml.device("default.qubit", wires=3).execute(tape1)
 
-        tape2 = qml.transforms.make_tape(qfunc2)()
+        tape2 = qml.tape.make_qscript(qfunc2)()
         res2 = qml.device("default.qubit", wires=3).execute(tape2)
 
         assert np.allclose(res1, res2)
diff --git a/tests/transforms/test_qfunc_transform.py b/tests/transforms/test_qfunc_transform.py
index 64e0dfc39..424bf8691 100644
--- a/tests/transforms/test_qfunc_transform.py
+++ b/tests/transforms/test_qfunc_transform.py
@@ -116,7 +116,7 @@ class TestQFuncTransforms:
         new_qfunc = my_transform(qfunc)
         x = 0.543
 
-        ops = qml.transforms.make_tape(new_qfunc)(x).operations
+        ops = qml.tape.make_qscript(new_qfunc)(x).operations
         assert len(ops) == 4
         assert ops[0].name == "Hadamard"
 
@@ -150,7 +150,7 @@ class TestQFuncTransforms:
             qml.CRX(x, wires=[0, 1])
 
         x = 0.543
-        ops = qml.transforms.make_tape(qfunc)(x).operations
+        ops = qml.tape.make_qscript(qfunc)(x).operations
         assert len(ops) == 4
         assert ops[0].name == "Hadamard"
 
@@ -188,7 +188,7 @@ class TestQFuncTransforms:
         x = 0.543
         new_qfunc = my_transform(a, b)(qfunc)
 
-        ops = qml.transforms.make_tape(new_qfunc)(x).operations
+        ops = qml.tape.make_qscript(new_qfunc)(x).operations
         assert len(ops) == 4
         assert ops[0].name == "Hadamard"
 
@@ -225,7 +225,7 @@ class TestQFuncTransforms:
             qml.Hadamard(wires=0)
             qml.CRX(x, wires=[0, 1])
 
-        ops = qml.transforms.make_tape(qfunc)(x).operations
+        ops = qml.tape.make_qscript(qfunc)(x).operations
         assert len(ops) == 4
         assert ops[0].name == "Hadamard"
 
@@ -265,7 +265,7 @@ class TestQFuncTransforms:
         def ansatz():
             qml.CNOT(wires=[0, 1])
 
-        ops = qml.transforms.make_tape(ansatz)().operations
+        ops = qml.tape.make_qscript(ansatz)().operations
         assert len(ops) == 2
         assert ops[0].name == "RZ"
         assert ops[0].parameters == [x]
diff --git a/tests/transforms/test_unitary_to_rot.py b/tests/transforms/test_unitary_to_rot.py
index 54e28d06b..15a2f1a73 100644
--- a/tests/transforms/test_unitary_to_rot.py
+++ b/tests/transforms/test_unitary_to_rot.py
@@ -73,7 +73,7 @@ class TestDecomposeSingleQubitUnitaryTransform:
         """Test that the transform works in the autograd interface."""
         transformed_qfunc = unitary_to_rot(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)(U).operations
+        ops = qml.tape.make_qscript(transformed_qfunc)(U).operations
 
         assert len(ops) == 3
 
@@ -99,7 +99,7 @@ class TestDecomposeSingleQubitUnitaryTransform:
 
         transformed_qfunc = unitary_to_rot(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)().operations
+        ops = qml.tape.make_qscript(transformed_qfunc)().operations
 
         assert len(ops) == 2
 
@@ -119,7 +119,7 @@ class TestDecomposeSingleQubitUnitaryTransform:
 
         transformed_qfunc = unitary_to_rot(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)(U).operations
+        ops = qml.tape.make_qscript(transformed_qfunc)(U).operations
 
         assert len(ops) == 3
 
@@ -143,7 +143,7 @@ class TestDecomposeSingleQubitUnitaryTransform:
 
         transformed_qfunc = unitary_to_rot(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)(U).operations
+        ops = qml.tape.make_qscript(transformed_qfunc)(U).operations
 
         assert len(ops) == 3
 
@@ -173,7 +173,7 @@ class TestDecomposeSingleQubitUnitaryTransform:
 
         transformed_qfunc = unitary_to_rot(qfunc)
 
-        ops = qml.transforms.make_tape(transformed_qfunc)(U).operations
+        ops = qml.tape.make_qscript(transformed_qfunc)(U).operations
 
         assert len(ops) == 3
 
@@ -265,11 +265,11 @@ class TestQubitUnitaryDifferentiability:
         transformed_qfunc = unitary_to_rot(qfunc_with_qubit_unitary)
         transformed_qnode = qml.QNode(transformed_qfunc, dev, diff_method=diff_method)
 
-        input = np.array(rot_angles, requires_grad=True)
-        assert qml.math.allclose(original_qnode(input), transformed_qnode(input), atol=1e-7)
+        angles = np.array(rot_angles, requires_grad=True)
+        assert qml.math.allclose(original_qnode(angles), transformed_qnode(angles), atol=1e-7)
 
-        original_grad = qml.grad(original_qnode)(input)
-        transformed_grad = qml.grad(transformed_qnode)(input)
+        original_grad = qml.grad(original_qnode)(angles)
+        transformed_grad = qml.grad(transformed_qnode)(angles)
 
         assert qml.math.allclose(original_grad, transformed_grad, atol=1e-7)
 
@@ -408,29 +408,29 @@ class TestQubitUnitaryDifferentiability:
             return qml.expval(qml.PauliX(wires="a"))
 
         # Setting the dtype to complex64 causes the gradients to be complex...
-        input = jnp.array(rot_angles, dtype=jnp.float64)
+        angles = jnp.array(rot_angles, dtype=jnp.float64)
 
         dev = qml.device("default.qubit", wires=["a", "b"])
 
         original_qnode = qml.QNode(
             original_qfunc_for_grad, dev, interface="jax", diff_method=diff_method
         )
-        original_result = original_qnode(input)
+        original_result = original_qnode(angles)
 
         transformed_qfunc = unitary_to_rot(qfunc_with_qubit_unitary)
         transformed_qnode = qml.QNode(
             transformed_qfunc, dev, interface="jax", diff_method=diff_method
         )
-        transformed_result = transformed_qnode(input)
+        transformed_result = transformed_qnode(angles)
         assert qml.math.allclose(original_result, transformed_result)
 
-        original_grad = jax.grad(original_qnode)(input)
-        transformed_grad = jax.grad(transformed_qnode)(input)
+        original_grad = jax.grad(original_qnode)(angles)
+        transformed_grad = jax.grad(transformed_qnode)(angles)
         assert qml.math.allclose(original_grad, transformed_grad, atol=1e-7)
 
         # Check that we can also JIT
-        grad_of_jit = jax.grad(jax.jit(transformed_qnode))(input)
-        jit_of_grad = jax.jit(jax.grad(transformed_qnode))(input)
+        grad_of_jit = jax.grad(jax.jit(transformed_qnode))(angles)
+        jit_of_grad = jax.jit(jax.grad(transformed_qnode))(angles)
         assert np.allclose(original_grad, jit_of_grad, atol=1e-7)
         assert np.allclose(original_grad, grad_of_jit, atol=1e-7)