-
Notifications
You must be signed in to change notification settings - Fork 874
Make some qmod natives great #1436
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a7b9e6a
add comment to qae
TomerGoldfriend a444410
add comment to bv
TomerGoldfriend 36dc35e
add comments to st
TomerGoldfriend 543eba4
add comments to qdrift
TomerGoldfriend f7e1377
rm write_qmod
TomerGoldfriend d3070ad
cr comments
TomerGoldfriend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
algorithms/foundational/bernstein_vazirani/bernstein_vazirani.qmod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 43 additions & 36 deletions
79
...iltonian_simulation/hamiltonian_simulation_guide/hamiltonian_simulation_guide_qdrift.qmod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,46 @@ | ||
| // Hamiltonian Simulation using qDRIFT | ||
|
|
||
| // This example demonstrates Hamiltonian time evolution using the qDRIFT | ||
| // algorithm, a randomized Hamiltonian simulation method. | ||
| // Given a Hamiltonian H expressed as a sum of Pauli strings, qDRIFT | ||
| // approximates exp(-i * H * t) by randomly sampling terms according to | ||
| // their weights and applying them sequentially. | ||
| // Here, t denotes the total evolution time of the system. | ||
| // The accuracy of the simulation is controlled by the total number of | ||
| // samples applied during the evolution. | ||
|
|
||
| // The Hamiltonian to be evolved | ||
| hamiltonian: SparsePauliOp = SparsePauliOp { | ||
| terms=[ | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { pauli=Pauli::Z, index=0 }, | ||
| IndexedPauli { pauli=Pauli::Z, index=1 } | ||
| ], | ||
| coefficient=0.3 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { pauli=Pauli::X, index=0 } | ||
| ], | ||
| coefficient=0.7 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { pauli=Pauli::X, index=1 } | ||
| ], | ||
| coefficient=0.2 | ||
| } | ||
| ], | ||
| num_qubits=2 | ||
| }; | ||
|
|
||
| qfunc main(output qba: qbit[]) { | ||
| allocate(2, qba); | ||
| qdrift(SparsePauliOp { | ||
| terms=[ | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { | ||
| pauli=Pauli::Z, | ||
| index=0 | ||
| }, | ||
| IndexedPauli { | ||
| pauli=Pauli::Z, | ||
| index=1 | ||
| } | ||
| ], | ||
| coefficient=0.3 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { | ||
| pauli=Pauli::X, | ||
| index=0 | ||
| } | ||
| ], | ||
| coefficient=0.7 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { | ||
| pauli=Pauli::X, | ||
| index=1 | ||
| } | ||
| ], | ||
| coefficient=0.2 | ||
| } | ||
| ], | ||
| num_qubits=2 | ||
| }, 1, 288, qba); | ||
| qdrift( | ||
| hamiltonian, | ||
| 1.0, // evolution time t | ||
| 288, // number of samples | ||
| qba // quantum variable | ||
| ); | ||
| } | ||
77 changes: 41 additions & 36 deletions
77
...ltonian_simulation/hamiltonian_simulation_guide/hamiltonian_simulation_guide_trotter.qmod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,44 @@ | ||
| // Hamiltonian Simulation using Suzuki–Trotter Product Formula | ||
|
|
||
| // This example demonstrates Hamiltonian time evolution, exp(-i * H * t), using the | ||
| // Suzuki–Trotter (ST) product formula, where the Hamiltonian H is given as a sum of | ||
| // Pauli strings, and t is the evolution time. | ||
| // The ST approximation is characterized by the product-formula order and the number | ||
| // of repetitions (Trotter steps). | ||
|
|
||
| // The Hamiltonian to be evolved | ||
TomerGoldfriend marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| hamiltonian: SparsePauliOp = SparsePauliOp { | ||
| terms=[ | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { pauli=Pauli::Z, index=0 }, | ||
| IndexedPauli { pauli=Pauli::Z, index=1 } | ||
| ], | ||
| coefficient=0.3 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { pauli=Pauli::X, index=0 } | ||
| ], | ||
| coefficient=0.7 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { pauli=Pauli::X, index=1 } | ||
| ], | ||
| coefficient=0.2 | ||
| } | ||
| ], | ||
| num_qubits=2 | ||
| }; | ||
|
|
||
| qfunc main(output qba: qbit[]) { | ||
| allocate(2, qba); | ||
| suzuki_trotter(SparsePauliOp { | ||
| terms=[ | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { | ||
| pauli=Pauli::Z, | ||
| index=0 | ||
| }, | ||
| IndexedPauli { | ||
| pauli=Pauli::Z, | ||
| index=1 | ||
| } | ||
| ], | ||
| coefficient=0.3 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { | ||
| pauli=Pauli::X, | ||
| index=0 | ||
| } | ||
| ], | ||
| coefficient=0.7 | ||
| }, | ||
| SparsePauliTerm { | ||
| paulis=[ | ||
| IndexedPauli { | ||
| pauli=Pauli::X, | ||
| index=1 | ||
| } | ||
| ], | ||
| coefficient=0.2 | ||
| } | ||
| ], | ||
| num_qubits=2 | ||
| }, 1.0, 1, 10, qba); | ||
| suzuki_trotter( | ||
| hamiltonian, | ||
| 1.0, // evolution time t | ||
| 1, // product-formula order | ||
| 10, // number of repetitions (Trotter steps) | ||
| qba // quantum variable | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.