Skip to content

Add Harrow-Hassidim-Lloyd (HHL) algorithm#177

Merged
sesmart merged 16 commits into
amazon-braket:mainfrom
axif0:documentation
Mar 4, 2026
Merged

Add Harrow-Hassidim-Lloyd (HHL) algorithm#177
sesmart merged 16 commits into
amazon-braket:mainfrom
axif0:documentation

Conversation

@axif0
Copy link
Copy Markdown
Contributor

@axif0 axif0 commented Feb 15, 2026

Issue #, if available:
#1194
Description of changes:
Added HHL algorithm implementation and a demonstration notebook. This includes the circuit construction logic, result processing, and examples solving 2x2 linear systems with fidelity checks against classical solutions.
Testing done:
Validated on LocalSimulator with high fidelity results in the provided notebook.

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@axif0 axif0 requested a review from a team as a code owner February 15, 2026 19:54
@sesmart
Copy link
Copy Markdown
Contributor

sesmart commented Feb 17, 2026

Hi @axif0, thanks for the contribution here as well. Mentioned in the other PR - updating from main should fix the readthedocs issue, but you likely need to run tox -e linters as well.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (641055c) to head (4a56503).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #177    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           32        34     +2     
  Lines         1358      1535   +177     
  Branches       174       200    +26     
==========================================
+ Hits          1358      1535   +177     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/braket/experimental/algorithms/hhl/__init__.py Outdated
@@ -0,0 +1,7 @@
The Harrow-Hassidim-Lloyd (HHL) algorithm is a quantum algorithm for solving systems of linear equations of the form Ax = b. Given an N×N Hermitian matrix A and a unit vector b, the algorithm produces a quantum state |x⟩ whose amplitudes encode the solution vector x = A⁻¹b. The HHL algorithm is one of the fundamental quantum algorithms expected to provide an exponential speedup over classical methods: for sparse, well-conditioned matrices, HHL runs in O(log(N) κ²) time versus O(Nκ) classically, where κ is the condition number of A. Applications include machine learning, computational finance, solving differential equations, and quantum chemistry.
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.

Maybe would tone down the comment about exponential speedup - I think for HHL it definitely depends on the state preparation, as well as readout.

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.

Thanks for the update, Can you add the same caveat to the intro of the notebook as well? The place where you mentioned " It can provide an exponential speedup over classical methods for certain classes of problems." without the same caveat.

Comment thread src/braket/experimental/algorithms/hhl/hhl.py Outdated
Comment thread src/braket/experimental/algorithms/hhl/hhl.py Outdated
Comment thread src/braket/experimental/algorithms/hhl/hhl.py
Comment thread src/braket/experimental/algorithms/hhl/hhl.py Outdated
Comment thread src/braket/experimental/algorithms/hhl/hhl.py
Comment thread src/braket/experimental/algorithms/hhl/hhl.py Outdated
Comment thread notebooks/advanced_algorithms/HHL_Algorithm.ipynb Outdated
Comment thread notebooks/advanced_algorithms/HHL_Algorithm.ipynb
@yitchen-tim
Copy link
Copy Markdown
Contributor

@sesmart I have resolved the comments that are solved by @axif0 's update. There are couple still open that I will defer to you.

@axif0 I added one more comment about mirroring the caveat to exponential advantage claim to notebook.

@axif0
Copy link
Copy Markdown
Contributor Author

axif0 commented Feb 26, 2026

@sesmart, @yitchen-tim hello, Is there anything else for improvement?

@axif0 axif0 requested review from sesmart and yitchen-tim February 26, 2026 15:34
Comment thread src/braket/experimental/algorithms/hhl/hhl.py
…rics and success probabilities within the example notebook.
@axif0
Copy link
Copy Markdown
Contributor Author

axif0 commented Feb 26, 2026

I replaced the opaque circ.unitary() calls by leveraging qiskit-braket-provider. I created a new helper function that constructs the controlled-U gate using Qiskit's UnitaryGate(unitary).control(1) and its preset pass manager to compile it down to native 1q/2q basis gates (['cx', 'u', 'id', 'rz', 'sx', 'x']) before translating it back to a Braket Circuit.

Also ~

  • Added qiskit-braket-provider as a dependency.
  • Added qiskit-braket-provider as a dependency.
  • Cleaned up the obsolete unitary matrix construction function and its related tests

@sesmart

@axif0
Copy link
Copy Markdown
Contributor Author

axif0 commented Feb 27, 2026

Updated and cleaned up a small local lint warning where circ = Circuit() was unused in the pre-existing test_controlled_rotation_zeros .

Is there anything else to be done?

@sesmart @yitchen-tim

@sesmart sesmart merged commit bcf25c1 into amazon-braket:main Mar 4, 2026
13 checks passed
@axif0
Copy link
Copy Markdown
Contributor Author

axif0 commented Mar 4, 2026

@sesmart thank you so much for the marge. And for the conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants