Skip to content

Commit

Permalink
Merge branch 'master' into contextuality_demo
Browse files Browse the repository at this point in the history
  • Loading branch information
KetpuntoG authored Sep 1, 2023
2 parents 54acbfe + 9bc3331 commit caca8a5
Show file tree
Hide file tree
Showing 23 changed files with 1,135 additions and 1,206 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ jobs:
# Adding this install outside of poetry as the dependencies conflict with existing other packages.
# TODO: This needs to be revisited.
# The following needs to be done in order for this dependency to be moved into pyproject.toml:
# - PennyLane-Cirq needs to support cirq >= 1.1.0
# - PennyLane needs to support numpy ~> 1.24
${{ steps.venv.outputs.location }}/bin/python3 -m pip install --no-deps mitiq==0.25.0
- name: Download Worker Load Data Artifact
Expand Down Expand Up @@ -432,17 +435,6 @@ jobs:
retention-days: 1
path: /tmp/execution_times

# These are files that are generated as part of sphinx-build but are not needed and supported on the live website
# There does not seem to be an option to "not" generate them, therefore this step deletes these files before they
# are published to the live website.
- name: Update sitemap.xml
run: |
${{ steps.venv.outputs.location }}/bin/qml_pipeline_utils \
clean-sitemap \
--build-dir="${{ github.workspace }}/_build/html" \
--html-files="demos/sg_execution_times.html" \
--verbose
# Removes built html files that are not relevant to current node
# See documentation in github_job_scheduler.py for more details.
- name: Clean HTML Files
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ Add the new dependency in the `[tool.poetry.group.executable-dependencies.depend

Once pyproject.toml files have been updated, the poetry.lock file needs to be refreshed:
```bash
poetry lock
poetry lock --no-update
```
This command will ensure that there are no dependency conflicts with any other package, and everything works.

The `--no-update` ensures existing package versions are not bumped as part of the locking process.

If the dependency change is required in prod, open the PR against `master`, or if it's only required in dev, then open
the PR against the `dev` branch, which will be synced to master on the next release of PennyLane.

Expand Down
3 changes: 1 addition & 2 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.ifconfig",
"sphinx_gallery.gen_gallery",
"sphinx_sitemap",
"sphinx_gallery.gen_gallery"
]


Expand Down
2 changes: 1 addition & 1 deletion demonstrations/ahs_aquila.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def circuit(params):
start_val = amplitude[0]
stop_val = amplitude[-1]
max_val = np.max(amplitude)
max_rate = np.max([(amplitude[i + 1] - amplitude[i]) / timestep for i in range(len(times))])
max_rate = np.max([(amplitude[i + 1] - amplitude[i]) / timestep for i in range(len(times)-1)])

print(f"start value: {start_val:.3} MHz")
print(f"stop value: {stop_val:.3} MHz")
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/quantum_neural_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def quantum_neural_net(var, x):
for v in var:
layer(v)

return qml.expval(qml.X(0))
return qml.expval(qml.QuadX(0))


##############################################################################
Expand Down
6 changes: 3 additions & 3 deletions demonstrations/tutorial_QGAN.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def gen_cost(gen_weights):
# We begin by creating the optimizer:

opt = tf.keras.optimizers.SGD(0.4)

opt.build([disc_weights, gen_weights])

##############################################################################
# In the first stage of training, we optimize the discriminator while
Expand All @@ -213,7 +213,7 @@ def gen_cost(gen_weights):
cost = lambda: disc_cost(disc_weights)

for step in range(50):
opt.minimize(cost, disc_weights)
opt.minimize(cost, [disc_weights])
if step % 5 == 0:
cost_val = cost().numpy()
print("Step {}: cost = {}".format(step, cost_val))
Expand Down Expand Up @@ -243,7 +243,7 @@ def gen_cost(gen_weights):
cost = lambda: gen_cost(gen_weights)

for step in range(50):
opt.minimize(cost, gen_weights)
opt.minimize(cost, [gen_weights])
if step % 5 == 0:
cost_val = cost().numpy()
print("Step {}: cost = {}".format(step, cost_val))
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/tutorial_apply_qsvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def real_u(A, phi):

@qml.qnode(qml.device("default.qubit", wires=["ancilla1", "ancilla2", 0, 1, 2]))
def linear_system_solver_circuit(phi):
qml.QubitStateVector(normalized_b, wires=[1, 2])
qml.StatePrep(normalized_b, wires=[1, 2])
real_u(A.T, phi) # invert the singular values of A transpose to get A^-1
return qml.state()

Expand Down
2 changes: 1 addition & 1 deletion demonstrations/tutorial_expressivity_fourier_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def quantum_model(weights, x):
W(weights[0])
S(x)
W(weights[1])
return qml.expval(qml.X(wires=0))
return qml.expval(qml.QuadX(wires=0))

def random_weights():
return np.random.normal(size=(2, 5 * n_ansatz_layers), loc=0, scale=var)
Expand Down
2 changes: 1 addition & 1 deletion demonstrations/tutorial_general_parshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def make_cost(N, seed):
@qml.qnode(dev, interface="jax")
def cost(x):
"""Cost function on N qubits with N frequencies."""
qml.QubitStateVector(random_state(N, seed), wires=dev.wires)
qml.StatePrep(random_state(N, seed), wires=dev.wires)
for w in dev.wires:
qml.RZ(x, wires=w, id="x")
return qml.expval(qml.Hermitian(random_observable(N, seed), wires=dev.wires))
Expand Down
14 changes: 7 additions & 7 deletions demonstrations/tutorial_mbqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def cluster_state():
@qml.qnode(dev, interface="autograd")
def one_bit_teleportation(input_state):
# Prepare the input state
qml.QubitStateVector(input_state, wires=0)
qml.StatePrep(input_state, wires=0)

# Prepare the cluster state
qml.Hadamard(wires=1)
Expand Down Expand Up @@ -305,7 +305,7 @@ def generate_random_state(n=1):
@qml.qnode(dev, interface="autograd")
def RZ(theta, input_state):
# Prepare the input state
qml.QubitStateVector(input_state, wires=0)
qml.StatePrep(input_state, wires=0)

# Perform the Rz rotation
qml.RZ(theta, wires=0)
Expand All @@ -326,7 +326,7 @@ def RZ(theta, input_state):
@qml.qnode(mbqc_dev, interface="autograd")
def RZ_MBQC(theta, input_state):
# Prepare the input state
qml.QubitStateVector(input_state, wires=0)
qml.StatePrep(input_state, wires=0)

# Prepare the cluster state
qml.Hadamard(wires=1)
Expand Down Expand Up @@ -367,7 +367,7 @@ def RZ_MBQC(theta, input_state):
@qml.qnode(dev, interface="autograd")
def RX(theta, input_state):
# Prepare the input state
qml.QubitStateVector(input_state, wires=0)
qml.StatePrep(input_state, wires=0)

# Perform the Rz rotation
qml.RX(theta, wires=0)
Expand All @@ -382,7 +382,7 @@ def RX(theta, input_state):
@qml.qnode(mbqc_dev, interface="autograd")
def RX_MBQC(theta, input_state):
# Prepare the input state
qml.QubitStateVector(input_state, wires=0)
qml.StatePrep(input_state, wires=0)

# Prepare the cluster state
qml.Hadamard(wires=1)
Expand Down Expand Up @@ -447,7 +447,7 @@ def RX_MBQC(theta, input_state):
@qml.qnode(dev, interface="autograd")
def CNOT(input_state):
# Prepare the input state
qml.QubitStateVector(input_state, wires=[0, 1])
qml.StatePrep(input_state, wires=[0, 1])
qml.CNOT(wires=[0, 1])

return qml.density_matrix(wires=[0, 1])
Expand All @@ -459,7 +459,7 @@ def CNOT(input_state):
@qml.qnode(mbqc_dev, interface="autograd")
def CNOT_MBQC(input_state):
# Prepare the input state
qml.QubitStateVector(input_state, wires=[0, 1])
qml.StatePrep(input_state, wires=[0, 1])

# Prepare the cluster state
qml.Hadamard(wires=2)
Expand Down
Loading

0 comments on commit caca8a5

Please sign in to comment.