Skip to content
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

Merge dev main3 #691

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f03f3b5
Added the time-marching differential equations solver example
orsa-classiq Dec 25, 2024
e73e6ce
added missing timeouts
orsa-classiq Dec 25, 2024
67063af
time marching latex fix
orsa-classiq Dec 26, 2024
c17fc0f
Rename notebook: hamiltonian simulation guide
classiqdor Dec 12, 2024
d7ea12e
Rename notebook: hamiltonian evolution
classiqdor Dec 12, 2024
062ffa2
Rename notebook: exponentiation example
classiqdor Dec 12, 2024
b8e9c36
Rename notebook: hhl example
classiqdor Dec 12, 2024
02242c4
Rename notebook: application option pricing
classiqdor Dec 12, 2024
ef9dfb5
Rename notebook: example prepare state
classiqdor Dec 12, 2024
8bc03f1
Fix rename
classiqdor Dec 12, 2024
55410da
Add test for unique notebook names
classiqdor Dec 12, 2024
fc27c4b
Update timeouts to be relative paths
classiqdor Dec 12, 2024
e35dd91
Update test to test for relative paths
classiqdor Dec 12, 2024
ad8c7f9
Fix
classiqdor Dec 12, 2024
3c475c2
Update error message
classiqdor Dec 12, 2024
f0f0de9
Allow functions qmods to have duplicates
classiqdor Dec 12, 2024
c2f731d
changed dqi notebook name
orsa-classiq Dec 15, 2024
c40908b
refactored set_partition, max_clique, ilp, ising
orsa-classiq Dec 8, 2024
2d58dbd
removed knapsack binary notebook
orsa-classiq Dec 8, 2024
9f8c7e7
with max_k_vertex_cover
orsa-classiq Dec 8, 2024
abf0393
updated notebooks accord\ing to CR comments and new CombiProblem inte…
orsa-classiq Dec 16, 2024
873f51c
updated timeouts
orsa-classiq Dec 16, 2024
79fa6ab
with portfolio optimization as well
orsa-classiq Dec 16, 2024
aef6c5c
fixed failing notebooks
orsa-classiq Dec 16, 2024
d048f90
Fix imports
ori-opher Dec 16, 2024
8d4c363
Update qmods
OriRothClassiq Dec 17, 2024
5f9f492
Update qmods
OriRothClassiq Dec 17, 2024
1a13e18
Update dqi Qmod
OriRothClassiq Dec 18, 2024
f295c69
adjusted integer using notebooks
orsa-classiq Dec 18, 2024
5af6e2e
test commit
orsa-classiq Dec 19, 2024
ce5a6c0
Fix file rename
classiqdor Dec 19, 2024
e61651c
adding SKEAPED_URLS list
Dec 19, 2024
7b9cb17
delete outdated note (also required to match the suggested solution)
Dec 17, 2024
9f9398f
delete unnecesarry note
Dec 17, 2024
6cd1a23
delete outdated hint
Dec 17, 2024
e71044d
fix probabilities to sum up to 1
Dec 17, 2024
d4471a8
Made suggestions for the English
AnnePicus Dec 19, 2024
2b17d53
updating notebook and tests requirements
Dec 22, 2024
18d7e26
fixed control with variable in both arguments issue
orsa-classiq Dec 24, 2024
b296658
English suggestions to Introducing Quantum Functions with Quantum Mon…
AnnePicus Dec 24, 2024
63792e2
install classiq separately, for dev environment
classiqdor Dec 19, 2024
984c63a
Merge branch 'dev' into merge_dev_main3
orsa-classiq Dec 29, 2024
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
57 changes: 45 additions & 12 deletions .github/workflows/Test-CI-dev-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,18 @@ jobs:
runs-on: ubuntu-latest

steps:
#
# Setup Repository
#
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Debug
run: git status

- name: Install dependencies
run: |
set -e
python -m pip install -U pip
python -m pip install --extra-index-url https://pypi.org/simple --pre -U -r requirements.txt
python -m pip install --extra-index-url https://pypi.org/simple -U -r requirements_tests.txt

#
# Setup Environment
#
# Configure AWS credentials
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
Expand All @@ -54,6 +48,45 @@ jobs:
IS_DEV: "true"
M2M_SECRET_ARN: "${{ secrets.NIGHTLY_M2M_SECRET_ARN }}"

#
# Setup Python
# (needs to run after "Setup Environment", since we install classiq's version from aws)
#
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
# Some weird behavior, that we should understand soon:
# "pip" defaults to use the aws url, and doesn't use the normal url
# so we need to add the normal pip url to every line..
set -e

python -m pip install -U pip \
--extra-index-url https://pypi.org/simple

# Install "classiq" separately
export CODEARTIFACT_AUTH_TOKEN="$( \
aws codeartifact get-authorization-token \
--domain ${{ secrets.CODEARTIFACT_DOMAIN }} \
--domain-owner ${{ secrets.CODEARTIFACT_OWNER }} \
--region ${{ secrets.CODEARTIFACT_REGION }} \
--query authorizationToken \
--output text \
)"
python -m pip install -U --pre \
--extra-index-url "https://aws:$CODEARTIFACT_AUTH_TOKEN@${{ secrets.CODEARTIFACT_DOMAIN }}-${{ secrets.CODEARTIFACT_OWNER }}.d.codeartifact.${{ secrets.CODEARTIFACT_REGION }}.amazonaws.com/pypi/${{ secrets.PYPI_NIGHTLY_NAME }}/simple/" \
--extra-index-url https://pypi.org/simple \
classiq

# Install everything from the requirements, other than "classiq".
python -m pip install -U $(grep -ivE "classiq" requirements.txt) \
--extra-index-url https://pypi.org/simple
python -m pip install -U -r requirements_tests.txt \
--extra-index-url https://pypi.org/simple

# Run Notebook Tests
- name: Run Notebooks
run: python -m pytest --log-cli-level=INFO tests
Expand Down
57 changes: 40 additions & 17 deletions .github/workflows/Test-CI-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,6 @@ jobs:
echo "==== Git status after checkout ===="
git status

#
# Setup Python
#
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
set -e
python -m pip install -U pip
# The `--pre` allows the installation of pre-release versions of packages (needed for Dev)
python -m pip install --extra-index-url https://pypi.org/simple --pre -U -r requirements.txt
python -m pip install --extra-index-url https://pypi.org/simple -U -r requirements_tests.txt

#
# Setup Environment
#
Expand All @@ -108,6 +91,46 @@ jobs:
IS_DEV: "true"
M2M_SECRET_ARN: "${{ secrets.NIGHTLY_M2M_SECRET_ARN }}"

#
# Setup Python
# (needs to run after "Setup Environment", since we install classiq's version from aws)
#
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
# Some weird behavior, that we should understand soon:
# "pip" defaults to use the aws url, and doesn't use the normal url
# so we need to add the normal pip url to every line..
set -e

python -m pip install -U pip \
--extra-index-url https://pypi.org/simple

# Install "classiq" separately
export CODEARTIFACT_AUTH_TOKEN="$( \
aws codeartifact get-authorization-token \
--domain ${{ secrets.CODEARTIFACT_DOMAIN }} \
--domain-owner ${{ secrets.CODEARTIFACT_OWNER }} \
--region ${{ secrets.CODEARTIFACT_REGION }} \
--query authorizationToken \
--output text \
)"
python -m pip install -U --pre \
--extra-index-url "https://aws:$CODEARTIFACT_AUTH_TOKEN@${{ secrets.CODEARTIFACT_DOMAIN }}-${{ secrets.CODEARTIFACT_OWNER }}.d.codeartifact.${{ secrets.CODEARTIFACT_REGION }}.amazonaws.com/pypi/${{ secrets.PYPI_NIGHTLY_NAME }}/simple/" \
--extra-index-url https://pypi.org/simple \
classiq

# Install everything from the requirements, other than "classiq".
python -m pip install -U $(grep -ivE "classiq" requirements.txt) \
--extra-index-url https://pypi.org/simple
python -m pip install -U -r requirements_tests.txt \
--extra-index-url https://pypi.org/simple

#
# Propagate CI information to python tests
#
Expand Down
1,066 changes: 1,066 additions & 0 deletions algorithms/differential_equations/time_marching/time_marching.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"friendly_name": "Time Marching Based Quantum Solver",
"description": "Solving time-dependent linear equations using a Time-Marching based strategy and QSVT",
"problem_domain_tags": ["linear equation"],
"qmod_type": ["algorithms"],
"level": ["advanced"]
}
106 changes: 106 additions & 0 deletions algorithms/differential_equations/time_marching/time_marching.qmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
qstruct TimeDependentBE {
index: qnum<2>;
time: qnum<2>;
block: qbit;
}

qstruct MagnusBE {
time_dependent: TimeDependentBE;
qsvt_exp_aux: qbit;
qsvt_exp_lcu: qbit;
}

qstruct LongSliceBE {
magnus: MagnusBE;
qsvt_amplification_aux: qbit;
}

qstruct FullBE {
time_slice: LongSliceBE;
counter: qnum<3.0>;
}

qfunc magnus_projector(qbe: MagnusBE, is_in_block: qbit) {
is_in_block ^= ((qbe.time_dependent.block == 0) and (qbe.time_dependent.time == 0)) and ((qbe.qsvt_exp_aux == 0) and (qbe.qsvt_exp_lcu == 0));
}

qfunc time_dependent_projector(qbe: TimeDependentBE, is_in_block: qbit) {
is_in_block ^= (qbe.block == 0) and (qbe.time == 0);
}

qfunc block_encode_time_dependent_A(a: real, b: real, qbe: TimeDependentBE) {
linear_pauli_rotations([Pauli::Y], [
(((b - a) * 2) / (2 ** qbe.time.size))
], [(2 * a)], qbe.time, qbe.block);
linear_pauli_rotations([Pauli::Y], [2], [0], qbe.index, qbe.block);
}

qfunc short_time_summation(a: real, b: real, qbe: TimeDependentBE) {
within {
hadamard_transform(qbe.time);
} apply {
block_encode_time_dependent_A(a, b, qbe);
}
}

qfunc short_time_magnus(a: real, b: real, qbe_st: MagnusBE) {
within {
H(qbe_st.qsvt_exp_lcu);
} apply {
qsvt_lcu([
4.7085,
3.0195,
0.0547,
4.7904,
0.0547,
3.0195,
(-17.2827)
], [
4.5651,
0.2495,
6.6887,
(-0.1862),
6.097,
0.4056,
0.2495,
(-20.5676)
], time_dependent_projector, time_dependent_projector, lambda(x) {
short_time_summation(a, b, x);
}, qbe_st.time_dependent, qbe_st.qsvt_exp_aux, qbe_st.qsvt_exp_lcu);
}
}

qfunc long_slice_evolution(a: real, b: real, qbe: LongSliceBE) {
qsvt([
4.1801,
2.3715,
4.6112,
4.5273,
(-1.7559),
4.6112,
8.6546,
(-20.9526)
], magnus_projector, magnus_projector, lambda(x) {
short_time_magnus(a, b, x);
}, qbe.magnus, qbe.qsvt_amplification_aux);
}

qfunc long_time_integrator_step(a: real, b: real, qbe_full: FullBE) {
long_slice_evolution(a, b, qbe_full.time_slice);
control ((((qbe_full.time_slice.magnus.time_dependent.block == 0) and (qbe_full.time_slice.magnus.time_dependent.time == 0)) and ((qbe_full.time_slice.magnus.qsvt_exp_aux == 0) and (qbe_full.time_slice.magnus.qsvt_exp_lcu == 0))) and (qbe_full.time_slice.qsvt_amplification_aux == 0)) {
qbe_full.counter += -1;
}
}

qfunc long_time_integrator(T: real, num_slices: int, qbe_full: FullBE) {
inplace_prepare_int(num_slices, qbe_full.counter);
repeat (i: num_slices) {
long_time_integrator_step((i * T) / num_slices, ((i + 1) * T) / num_slices, qbe_full);
}
}

qfunc main(output qbe: FullBE) {
allocate(qbe.size, qbe);
hadamard_transform(qbe.time_slice.magnus.time_dependent.index);
long_time_integrator(2, 4, qbe);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"cx",
"u2",
"y",
"ry",
"t",
"rx",
"cy",
"r",
"sxdg",
"cz",
"tdg",
"x",
"sdg",
"u1",
"u",
"h",
"sx",
"z",
"p",
"id",
"s",
"rz"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"optimization_level": 0,
"output_format": ["qasm"],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": 590453799
}
}
2 changes: 2 additions & 0 deletions requirements_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ testbook
torch
torchvision
galois
cvxpy
pyqsp==0.1.6
19 changes: 11 additions & 8 deletions tests/resources/timeouts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,14 @@ whitebox_fuzzing.qmod: 720
X.qmod: 10
Yasir_Mansour_HW3_VQE.ipynb: 30
Yasir_Mansour_HW4_molecule_eigensolver.ipynb: 600
classiq_discrete_quantum_walk.ipynb: 100
qiskit_discrete_quantum_walk.ipynb: 100
tket_discrete_quantum_walk.ipynb: 100
classiq_qsvt.ipynb: 100
pennylane_cat_qsvt_example.ipynb: 100
qiskit_qsvt.ipynb: 100
pennylane_catalyst_discrete_quantum_walk.ipynb: 100
tket_qsvt_example.ipynb: 100
classiq_discrete_quantum_walk.ipynb: 300
qiskit_discrete_quantum_walk.ipynb: 300
tket_discrete_quantum_walk.ipynb: 300
pennylane_catalyst_discrete_quantum_walk.ipynb: 300
tket_qsvt_example.ipynb: 300
classiq_qsvt.ipynb: 300
pennylane_cat_qsvt_example.ipynb: 300
qiskit_qsvt.ipynb: 300
time_marching.ipynb: 500
time_marching.qmod: 400

Loading