Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .coveragerc

This file was deleted.

4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import datetime

import pkg_resources
from importlib.metadata import version as pkg_version

# Sphinx configuration below.
project = "amazon-braket-algorithm-library"
version = pkg_resources.require(project)[0].version
version = pkg_version(project)
release = version
copyright = f"{datetime.datetime.now().year}, Amazon.com"

Expand Down
32 changes: 11 additions & 21 deletions notebooks/textbook/Quantum_Counting_Algorithm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@
"# This phase shift is corrected in get_quantum_counting_results.\n",
"theta = 2 * np.arcsin(np.sqrt(len(marked_states) / N))\n",
"print(f\"\\nGrover angle theta = {theta:.4f} rad\")\n",
"print(f\"Ideal eigenvalues in solution subspace: \"\n",
" f\"e^(+i*theta) = {np.exp(1j * theta):.4f}, \"\n",
" f\"e^(-i*theta) = {np.exp(-1j * theta):.4f}\")\n",
"print(\n",
" f\"Ideal eigenvalues in solution subspace: \"\n",
" f\"e^(+i*theta) = {np.exp(1j * theta):.4f}, \"\n",
" f\"e^(-i*theta) = {np.exp(-1j * theta):.4f}\"\n",
")\n",
"print(f\"Circuit eigenvalues (with -1 global phase): {np.round(nontrivial, 4)}\")"
]
},
Expand Down Expand Up @@ -479,17 +481,13 @@
"search_qubits_2 = list(range(n_counting, n_counting + n_search))\n",
"\n",
"circ_2 = Circuit()\n",
"circ_2 = quantum_counting_circuit(\n",
" circ_2, counting_qubits_2, search_qubits_2, marked_states_2\n",
")\n",
"circ_2 = quantum_counting_circuit(circ_2, counting_qubits_2, search_qubits_2, marked_states_2)\n",
"\n",
"device = LocalSimulator()\n",
"task_2 = run_quantum_counting(circ_2, device, shots=2000)\n",
"\n",
"print(f\"Quantum Counting Results (N={N_2}, M={len(marked_states_2)}):\")\n",
"results_2 = get_quantum_counting_results(\n",
" task_2, counting_qubits_2, search_qubits_2, verbose=True\n",
")\n",
"results_2 = get_quantum_counting_results(task_2, counting_qubits_2, search_qubits_2, verbose=True)\n",
"\n",
"print(f\"\\nActual M = {len(marked_states_2)}\")\n",
"print(f\"Estimated M = {results_2['best_estimate']:.4f}\")"
Expand Down Expand Up @@ -586,16 +584,12 @@
"search_qubits_3 = list(range(n_counting, n_counting + n_search))\n",
"\n",
"circ_3 = Circuit()\n",
"circ_3 = quantum_counting_circuit(\n",
" circ_3, counting_qubits_3, search_qubits_3, marked_states_3\n",
")\n",
"circ_3 = quantum_counting_circuit(circ_3, counting_qubits_3, search_qubits_3, marked_states_3)\n",
"\n",
"device = LocalSimulator()\n",
"task_3 = run_quantum_counting(circ_3, device, shots=1000)\n",
"\n",
"results_3 = get_quantum_counting_results(\n",
" task_3, counting_qubits_3, search_qubits_3, verbose=True\n",
")\n",
"results_3 = get_quantum_counting_results(task_3, counting_qubits_3, search_qubits_3, verbose=True)\n",
"\n",
"print(\"\\nActual M = 0\")\n",
"print(f\"Estimated M = {results_3['best_estimate']:.4f}\")"
Expand Down Expand Up @@ -650,16 +644,12 @@
"search_qubits_4 = list(range(n_counting, n_counting + n_search))\n",
"\n",
"circ_4 = Circuit()\n",
"circ_4 = quantum_counting_circuit(\n",
" circ_4, counting_qubits_4, search_qubits_4, marked_states_4\n",
")\n",
"circ_4 = quantum_counting_circuit(circ_4, counting_qubits_4, search_qubits_4, marked_states_4)\n",
"\n",
"device = LocalSimulator()\n",
"task_4 = run_quantum_counting(circ_4, device, shots=1000)\n",
"\n",
"results_4 = get_quantum_counting_results(\n",
" task_4, counting_qubits_4, search_qubits_4, verbose=True\n",
")\n",
"results_4 = get_quantum_counting_results(task_4, counting_qubits_4, search_qubits_4, verbose=True)\n",
"\n",
"print(f\"\\nActual M = {N_4}\")\n",
"print(f\"Estimated M = {results_4['best_estimate']:.4f}\")"
Expand Down
98 changes: 93 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,96 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "amazon-braket-algorithm-library"
dynamic = ["version"]
description = "An open source library of quantum computing algorithms implemented on Amazon Braket"
readme = "README.md"
license = "Apache-2.0"
requires-python = ">= 3.11"
authors = [
{ name = "Amazon Web Services" },
]
keywords = ["Amazon", "AWS", "Quantum"]
classifiers = [
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"amazon-braket-sdk>=1.35.1",
"numpy",
"openfermion>=1.5.1",
"pennylane>=0.34.0",
"scipy>=1.5.2",
# Sympy 1.13 produces different results for Simon's algorithm
"sympy<1.13",
"qiskit-braket-provider",
]

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov",
"pytest-rerunfailures",
"pytest-xdist",
"ruff",
"sphinx",
"sphinx-rtd-theme",
"sphinxcontrib-apidoc",
"tox",
]

[project.urls]
Homepage = "https://github.com/amazon-braket/amazon-braket-algorithm-library"

[tool.setuptools.packages.find]
where = ["src"]
exclude = ["test"]

[tool.setuptools.dynamic]
version = { attr = "braket._algos._version.__version__" }

[tool.setuptools.package-data]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just limiting the include_package_data=True option from before to .md files or is there more impact?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but we can remove this scoped changed

"*" = ["*.md"]

[tool.pytest.ini_options]
xfail_strict = true
# removing pytest-xdist config currently since that conflicts with -s option in --mock-level=LEAST tests
addopts = "--verbose -n auto --durations=0 --durations-min=1"
testpaths = ["test/unit_tests"]

[tool.coverage.run]
parallel = true
branch = true
source = ["braket.experimental"]

[tool.coverage.paths]
source = [
"src/braket",
".tox/*/lib/python*/site-packages/braket",
]

[tool.coverage.report]
show_missing = true

[tool.coverage.html]
directory = "build/coverage"

[tool.coverage.xml]
output = "build/coverage/coverage.xml"

[tool.ruff]
target-version = "py311"
line-length = 100
lint.isort = { known-first-party = [
"braket",
] }
lint.extend-select = ["I", "PERF"]
lint.preview = false #TODO: set back to true

[tool.ruff.lint]
extend-select = ["I", "PERF"]
preview = false #TODO: set back to true

[tool.ruff.lint.isort]
known-first-party = ["braket"]
10 changes: 0 additions & 10 deletions setup.cfg

This file was deleted.

70 changes: 0 additions & 70 deletions setup.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ def controlled_grover_circuit(
)

# Controlled diffusion
circ.add_circuit(
_controlled_diffusion_circuit(control, search_qubits, decompose_ccnot)
)
circ.add_circuit(_controlled_diffusion_circuit(control, search_qubits, decompose_ccnot))

return circ

Expand Down Expand Up @@ -292,9 +290,7 @@ def quantum_counting_circuit(
"""
new_circuit = Circuit().add_circuit(counting_circ)
new_circuit.add_circuit(
quantum_counting(
counting_qubits, search_qubits, marked_states, decompose_ccnot
)
quantum_counting(counting_qubits, search_qubits, marked_states, decompose_ccnot)
)
return new_circuit.probability(counting_qubits)

Expand Down Expand Up @@ -338,9 +334,7 @@ def quantum_counting(
for ii, qubit in enumerate(reversed(counting_qubits)):
power = 2**ii
qc_circ.add_circuit(
controlled_grover_circuit(
qubit, search_qubits, marked_states, power, decompose_ccnot
)
controlled_grover_circuit(qubit, search_qubits, marked_states, power, decompose_ccnot)
)

# Inverse QFT on counting qubits
Expand Down Expand Up @@ -436,9 +430,7 @@ def get_quantum_counting_results(

if verbose:
print(f"Search space size N = {N}")
sorted_cr = sorted(
counting_register_results.items(), key=lambda x: x[1], reverse=True
)
sorted_cr = sorted(counting_register_results.items(), key=lambda x: x[1], reverse=True)
print("\nCounting register distribution (top outcomes):")
for bitstring, count in sorted_cr[:6]:
y_val = int(bitstring, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,8 @@ def test_count_with_marked_initial_state():

# Controlled-G^(2^k) using gate-level circuit
for ii, qubit in enumerate(reversed(counting_qubits)):
power = 2 ** ii
circ.add_circuit(
qc.controlled_grover_circuit(qubit, search_qubits, marked_states, power)
)
power = 2**ii
circ.add_circuit(qc.controlled_grover_circuit(qubit, search_qubits, marked_states, power))

# Inverse QFT on counting qubits
circ.add_circuit(qc.inverse_qft_for_counting(counting_qubits))
Expand Down
Loading