From 6678bf03ad4c8ef99dada44b20b5318326798853 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Fri, 29 Sep 2023 14:45:23 +0900 Subject: [PATCH 1/8] add tests for unreleased Qiskit --- .github/workflows/tests.yml | 51 +++++++++++++++++++ qiskit_aer/backends/aer_compiler.py | 2 +- test/benchmark/simulator_benchmark.py | 2 +- .../backends/aer_simulator/test_fusion.py | 2 +- .../terra/backends/test_parameterized_qobj.py | 4 +- test/terra/primitives/test_estimator.py | 4 +- 6 files changed, 58 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 471ecfe0ee..b99ce269db 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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"] + 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 + - 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 + \ No newline at end of file diff --git a/qiskit_aer/backends/aer_compiler.py b/qiskit_aer/backends/aer_compiler.py index 4909f73537..95e0e3e0fd 100644 --- a/qiskit_aer/backends/aer_compiler.py +++ b/qiskit_aer/backends/aer_compiler.py @@ -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) diff --git a/test/benchmark/simulator_benchmark.py b/test/benchmark/simulator_benchmark.py index c7cd605486..bf1230a53f 100644 --- a/test/benchmark/simulator_benchmark.py +++ b/test/benchmark/simulator_benchmark.py @@ -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: diff --git a/test/terra/backends/aer_simulator/test_fusion.py b/test/terra/backends/aer_simulator/test_fusion.py index d2d5c42289..bf281e4324 100644 --- a/test/terra/backends/aer_simulator/test_fusion.py +++ b/test/terra/backends/aer_simulator/test_fusion.py @@ -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 diff --git a/test/terra/backends/test_parameterized_qobj.py b/test/terra/backends/test_parameterized_qobj.py index 4ca2c809ca..e08c697ccf 100644 --- a/test/terra/backends/test_parameterized_qobj.py +++ b/test/terra/backends/test_parameterized_qobj.py @@ -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) @@ -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() diff --git a/test/terra/primitives/test_estimator.py b/test/terra/primitives/test_estimator.py index 96c13cf59b..399ab43f5b 100644 --- a/test/terra/primitives/test_estimator.py +++ b/test/terra/primitives/test_estimator.py @@ -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], @@ -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) From b2f49ecda141ad27b0acb6ede0f85c4e504384f0 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Mon, 2 Oct 2023 10:54:40 +0900 Subject: [PATCH 2/8] Update .github/workflows/tests.yml Co-authored-by: Matthew Treinish --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b99ce269db..61ce56b491 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -313,7 +313,7 @@ jobs: - 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 + pip install -U git+https://github.com/Qiskit/qiskit.git - name: Install openblas run: | set -e From e7cede702f0c374cd74b53c03e59b761d47e75b4 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Wed, 4 Oct 2023 17:39:37 +0900 Subject: [PATCH 3/8] Scheduled test for latest Qiskit --- .github/workflows/tests.yml | 50 ----------------- .../workflows/unit-tests-latest-qiskit.yml | 53 +++++++++++++++++++ 2 files changed, 53 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/unit-tests-latest-qiskit.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 61ce56b491..a5efe586ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -280,54 +280,4 @@ 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"] - 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.git - - 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 \ No newline at end of file diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml new file mode 100644 index 0000000000..ce18996f7a --- /dev/null +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -0,0 +1,53 @@ +name: Unit Tests for latest Qiskit +on: + schedule: + - cron: '0 5 * * *' + workflow_dispatch: +jobs: + unit-tests-latest-qiskit: + runs-on: "ubuntu-latest" + needs: [sdist, lint] + timeout-minutes: 60 + 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 3.11 + uses: actions/setup-python@v2 + with: + python-version: 3.11 + - 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.git + - 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 + \ No newline at end of file From f1a6b1e763c6f78b5fa5e65f38c63184b826d68b Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Fri, 6 Oct 2023 09:57:24 +0900 Subject: [PATCH 4/8] run latest Qiskit test at push --- .github/workflows/unit-tests-latest-qiskit.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml index ce18996f7a..dd00911cd1 100644 --- a/.github/workflows/unit-tests-latest-qiskit.yml +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -1,8 +1,11 @@ name: Unit Tests for latest Qiskit on: + push: + branches: [main, 'stable/*'] + pull_request: + branches: [main, 'stable/*'] schedule: - cron: '0 5 * * *' - workflow_dispatch: jobs: unit-tests-latest-qiskit: runs-on: "ubuntu-latest" From 0ddbda45ec6e09a710f0b5de99b9b117af237d35 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Fri, 6 Oct 2023 10:05:42 +0900 Subject: [PATCH 5/8] fix test --- .github/workflows/unit-tests-latest-qiskit.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml index dd00911cd1..50cf929f41 100644 --- a/.github/workflows/unit-tests-latest-qiskit.yml +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -6,6 +6,9 @@ on: branches: [main, 'stable/*'] schedule: - cron: '0 5 * * *' +concurrency: + group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }} + cancel-in-progress: true jobs: unit-tests-latest-qiskit: runs-on: "ubuntu-latest" From 68c8d39af689ff4d98f72a1f42eacfcddbb9145e Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Fri, 6 Oct 2023 10:43:37 +0900 Subject: [PATCH 6/8] fix qiskit test again --- .github/workflows/unit-tests-latest-qiskit.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml index 50cf929f41..f7c05f819f 100644 --- a/.github/workflows/unit-tests-latest-qiskit.yml +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -11,8 +11,7 @@ concurrency: cancel-in-progress: true jobs: unit-tests-latest-qiskit: - runs-on: "ubuntu-latest" - needs: [sdist, lint] + runs-on: ubuntu-latest timeout-minutes: 60 env: AER_THRUST_BACKEND: OMP From 982d890ee73d69dbfa74ca17788489bb0c78158f Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Fri, 6 Oct 2023 13:59:55 +0900 Subject: [PATCH 7/8] fix test case for runtime parameter binding --- test/terra/backends/test_runtime_parameterization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/terra/backends/test_runtime_parameterization.py b/test/terra/backends/test_runtime_parameterization.py index 353d7178da..e2c8af659f 100644 --- a/test/terra/backends/test_runtime_parameterization.py +++ b/test/terra/backends/test_runtime_parameterization.py @@ -456,7 +456,7 @@ def test_run_path_with_truncation(self, method, device): 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, From 049beddde901c6690afd3ba6e6a7aea6890bf524 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Thu, 19 Oct 2023 16:12:08 +0900 Subject: [PATCH 8/8] remove on push/pull request from latest Qiskit unit test --- .github/workflows/unit-tests-latest-qiskit.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml index f7c05f819f..425538529c 100644 --- a/.github/workflows/unit-tests-latest-qiskit.yml +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -1,9 +1,5 @@ name: Unit Tests for latest Qiskit on: - push: - branches: [main, 'stable/*'] - pull_request: - branches: [main, 'stable/*'] schedule: - cron: '0 5 * * *' concurrency: