-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V0.17.0 deprecations #1522
V0.17.0 deprecations #1522
Conversation
[ch8061] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my end @antalszava, however it seems that some tests are now failing!
Also, this may break some demos(?)
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #1522 +/- ##
==========================================
- Coverage 98.21% 98.21% -0.01%
==========================================
Files 184 184
Lines 13218 13209 -9
==========================================
- Hits 12982 12973 -9
Misses 236 236
Continue to review full report at Codecov.
|
Thank you Josh!
Changed to have Manually the following demos seem to be the ones with
dev_x = qml.device("default.qubit", wires=n_qubits, shots=n_shots)
@qml.qnode(dev_x)
def prepare_and_sample(weights):
# Variational circuit generating a guess for the solution vector |x>
variational_block(weights)
# We assume that the system is measured in the computational basis.
# If we label each basis state with a decimal integer j = 0, 1, ... 2 ** n_qubits - 1,
# this is equivalent to a measurement of the following diagonal observable.
basis_obs = qml.Hermitian(np.diag(range(2 ** n_qubits)), wires=range(n_qubits))
return qml.sample(basis_obs)
dev = qml.device("default.qubit.jax", wires=2, shots=10, prng_key=key)
# Now we can create our qnode within the circuit function.
@qml.qnode(dev, interface="jax")
def my_circuit():
qml.RX(param, wires=0)
qml.CNOT(wires=[0, 1])
return qml.sample(qml.PauliZ(0))
dev = qml.device("default.qubit", wires=n_wires, shots=1)
@qml.qnode(dev)
def circuit(gammas, betas, edge=None, n_layers=1):
# apply Hadamards to get the n qubit |+> state
for wire in range(n_wires):
qml.Hadamard(wires=wire)
# p instances of unitary operators
for i in range(n_layers):
U_C(gammas[i])
U_B(betas[i])
if edge is None:
# measurement phase
return qml.sample(comp_basis_measurement(range(n_wires)))
dev = qml.device('cirq.qsim', wires=wires, qubits=qubits, shots=shots)
@qml.qnode(dev)
def circuit(seed=42, return_probs=False):
np.random.seed(seed)
gate_idx = generate_single_qubit_gate_list()
# m full cycles - single-qubit gates & two-qubit gate
for i, gs in enumerate(gate_sequence):
for w in range(wires):
single_qubit_gates[gate_idx[i][w]](wires=w)
for qb_1, qb_2 in gate_order[gs]:
ops.ISWAP(wires=(qb_1, qb_2))
ops.CPhase(-np.pi/6, wires=(qb_1, qb_2))
# one half-cycle - single-qubit gates only
for w in range(wires):
single_qubit_gates[gate_idx[-1][w]](wires=w)
if return_probs:
return qml.probs(wires=range(wires))
else:
return [qml.sample(qml.PauliZ(i)) for i in range(wires)]
dev_x = qml.device("default.qubit", wires=n_qubits, shots=n_shots)
dev_x = qml.device("default.qubit", wires=n_qubits, shots=n_shots)
@qml.qnode(dev_x)
def prepare_and_sample(weights):
# Variational circuit generating a guess for the solution vector |x>
variational_block(weights)
# We assume that the system is measured in the computational basis.
# If we label each basis state with a decimal integer j = 0, 1, ... 2 ** n_qubits - 1,
# this is equivalent to a measurement of the following diagonal observable.
basis_obs = qml.Hermitian(np.diag(range(2 ** n_qubits)), wires=range(n_qubits))
return qml.sample(basis_obs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good as far as I can tell. 💯 Nice to get the deprecated functions out of the way.
I guess we'd like this to be merged into the rc branch though, right?
@@ -12,6 +12,7 @@ help: | |||
@echo " wheel to build the PennyLane wheel" | |||
@echo " dist to package the source distribution" | |||
@echo " clean to delete all temporary, cache, and build files" | |||
@echo " docs to build the PennyLane documentation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
Thank you for the review @thisac! My plan would be to merge first into Edit: created the rc version: #1524. Once the CI checks are okay with this version in |
get_resources
andget_depth
as they are superseded by specs;qml.sample
whenshots=None
: raise an error inQubitDevice
instead of a warning