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

Add test for unreleased Qiskit #1950

Merged
merged 12 commits into from
Oct 19, 2023
51 changes: 51 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,54 @@ jobs:
rm -rf qiskit_aer
stestr run --slowest
shell: bash
unit-tests-latest-qiskit-terra:
runs-on: ${{ matrix.os }}
needs: [sdist, lint]
timeout-minutes: 60
strategy:
matrix:
python-version: ["3.11"]
os: ["ubuntu-latest"]
Copy link
Member

Choose a reason for hiding this comment

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

Are you thinking we should run this on every commit? Or was the eventual plan to run this job periodically when it's no longer a WIP? We can set this up in a new workflow file and create a nightly cron job to run this test if we want to do it periodically, see: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to use this test case for testing deprecations and changes of Qiskit. I will remove this test case and only merge fixes in this PR.

env:
AER_THRUST_BACKEND: OMP
QISKIT_TEST_CAPTURE_STREAMS: 1
# Needed to suppress a warning in jupyter-core 5.x by eagerly migrating to
# a new internal interface that will be the default in jupyter-core 6.x.
# This variable should become redundant on release of jupyter-core 6.
JUPYTER_PLATFORM_DIRS: 1
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version}}-pip-test-${{ hashFiles('setup.py','requirements-dev.txt','constraints.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version}}-pip-test-
${{ runner.os }}-${{ matrix.python-version}}-pip-
${{ runner.os }}-${{ matrix.python-version}}-
- name: Install Deps
run: |
python -m pip install -U -c constraints.txt -r requirements-dev.txt wheel
pip install -U git+https://github.com/Qiskit/qiskit-terra.git
doichanj marked this conversation as resolved.
Show resolved Hide resolved
- name: Install openblas
run: |
set -e
sudo apt-get update
sudo apt-get install -y libopenblas-dev
shell: bash
- name: Install Aer
run: |
python -m pip install -U .
- name: Run Tests
run: |
set -e
pip check
rm -rf qiskit_aer
stestr run --slowest
shell: bash

2 changes: 1 addition & 1 deletion qiskit_aer/backends/aer_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _inline_for_loop_op(self, instruction, parent, bit_map):
continue_label = f"{loop_name}_{index}"
inlined_body = self._inline_circuit(body, continue_label, break_label, inner_bit_map)
if loop_parameter is not None:
inlined_body = inlined_body.bind_parameters({loop_parameter: index})
inlined_body = inlined_body.assign_parameters({loop_parameter: index})
parent.append(inlined_body, qargs, cargs)
parent.append(AerMark(continue_label, len(qargs), len(cargs)), qargs, cargs)

Expand Down
2 changes: 1 addition & 1 deletion test/benchmark/simulator_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def add_expval(base, num_terms):
param_binds = {}
for param in circuit.parameters:
param_binds[param] = np.random.random()
circuit = circuit.bind_parameters(param_binds)
circuit = circuit.assign_parameters(param_binds)

simulator = self.simulators[runtime]
if measure == self.MEASUREMENT_SAMPLING:
Expand Down
2 changes: 1 addition & 1 deletion test/terra/backends/aer_simulator/test_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def test_fusion_two_qubits(self):
for param in circuit.parameters:
param_binds[param] = np.random.random()

circuit = transpile(circuit.bind_parameters(param_binds), backend, optimization_level=0)
circuit = transpile(circuit.assign_parameters(param_binds), backend, optimization_level=0)

backend_options = self.fusion_options(enabled=True, threshold=1)
backend_options["fusion_verbose"] = True
Expand Down
4 changes: 2 additions & 2 deletions test/terra/backends/test_parameterized_qobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_run_path_with_truncation(self):
param_map = {theta: [0.1 * i for i in range(3)]}
param_sets = [{theta: 0.1 * i} for i in range(3)]

resolved_circuits = [circuit.bind_parameters(param_set) for param_set in param_sets]
resolved_circuits = [circuit.assign_parameters(param_set) for param_set in param_sets]

result = backend.run(circuit, parameter_binds=[param_map]).result()
self.assertSuccess(result)
Expand Down Expand Up @@ -480,7 +480,7 @@ def test_global_phase_parameters(self):

circs = []
for v in [1, 2, 3]:
circs.append(circ.bind_parameters({theta: v}))
circs.append(circ.assign_parameters({theta: v}))

expected = backend.run(circs, shots=10, seed_simulator=100).result()

Expand Down
4 changes: 2 additions & 2 deletions test/terra/primitives/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_estimator(self, abelian_grouping):
@data(True, False)
def test_init_observable_from_operator(self, abelian_grouping):
"""test for evaluate without parameters"""
circuit = self.ansatz.bind_parameters([0, 1, 1, 2, 3, 5])
circuit = self.ansatz.assign_parameters([0, 1, 1, 2, 3, 5])
matrix = Operator(
[
[-1.06365335, 0.0, 0.0, 0.1809312],
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_evaluate_multi_params(self, abelian_grouping):
@data(True, False)
def test_evaluate_no_params(self, abelian_grouping):
"""test for evaluate without parameters"""
circuit = self.ansatz.bind_parameters([0, 1, 1, 2, 3, 5])
circuit = self.ansatz.assign_parameters([0, 1, 1, 2, 3, 5])
est = Estimator(abelian_grouping=abelian_grouping)
result = est.run(circuit, self.observable, seed=15, shots=8192).result()
self.assertIsInstance(result, EstimatorResult)
Expand Down
Loading