Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Qiskit/qiskit into transpil…
Browse files Browse the repository at this point in the history
…e-only-target-pipeline
  • Loading branch information
ElePT committed Jan 14, 2025
2 parents a46ec06 + 79f0e72 commit dafa66b
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 333 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/wheels-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ on:
default: "default"
required: false

wheels-32bit:
description: >-
The action to take for Tier 1 wheels.
Choose from 'default', 'build' or 'skip'.
This builds multiple artifacts, which all match 'wheels-32bit-*'.
type: string
default: "default"
required: false

wheels-linux-s390x:
description: >-
The action to take for Linux s390x wheels.
Expand Down Expand Up @@ -133,33 +124,6 @@ jobs:
path: ./wheelhouse/*.whl
name: ${{ inputs.artifact-prefix }}wheels-tier-1-${{ matrix.os }}

wheels-32bit:
name: "Wheels / 32bit"
if: (inputs.wheels-32bit == 'default' && inputs.default-action || inputs.wheels-32bit) == 'build'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SKIP: 'pp* cp36-* cp37-* cp38-* *musllinux* *amd64 *x86_64'
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: ${{ inputs.artifact-prefix }}wheels-32bit-${{ matrix.os }}

wheels-linux-s390x:
name: "Wheels / Linux s390x"
if: (inputs.wheels-linux-s390x == 'default' && inputs.default-action || inputs.wheels-linux-s390x) == 'build'
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
artifact-prefix: "deploy-core-"
default-action: "skip"
wheels-tier-1: "build"
wheels-32bit: "build"
sdist: "build"
upload-core:
name: Deploy core
Expand All @@ -39,7 +38,6 @@ jobs:
artifact-prefix: "deploy-others-"
default-action: "build"
wheels-tier-1: "skip"
wheels-32bit: "skip"
sdist: "skip"
upload-others:
name: Deploy other
Expand Down
6 changes: 6 additions & 0 deletions crates/accelerate/src/target_transpiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,12 @@ impl Target {

/// Checks whether an instruction is supported by the Target based on instruction name and qargs.
pub fn instruction_supported(&self, operation_name: &str, qargs: Option<&Qargs>) -> bool {
// Handle case where num_qubits is None by checking globally supported operations
let qargs: Option<&Qargs> = if self.num_qubits.is_none() {
None
} else {
qargs
};
if self.gate_map.contains_key(operation_name) {
if let Some(_qargs) = qargs {
let qarg_set: HashSet<&PhysicalQubit> = _qargs.iter().collect();
Expand Down
6 changes: 5 additions & 1 deletion crates/accelerate/src/unitary_synthesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ fn get_2q_decomposers_from_target(
let mut available_2q_props: IndexMap<&str, (Option<f64>, Option<f64>)> = IndexMap::new();

let mut qubit_gate_map = IndexMap::new();

match target.operation_names_for_qargs(Some(&qubits)) {
Ok(direct_keys) => {
qubit_gate_map.insert(&qubits, direct_keys);
Expand Down Expand Up @@ -597,7 +598,10 @@ fn get_2q_decomposers_from_target(
OperationRef::Standard(_) => (),
_ => continue,
}

// Filter out non-2q-gate candidates
if op.operation.num_qubits() != 2 {
continue;
}
available_2q_basis.insert(key, replace_parametrized_gate(op.clone()));

if target.contains_key(key) {
Expand Down
41 changes: 19 additions & 22 deletions qiskit/transpiler/preset_passmanagers/builtin_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ class BasicSwapPassManager(PassManagerStagePlugin):

def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager:
"""Build routing stage PassManager."""
seed_transpiler = pass_manager_config.seed_transpiler
target = pass_manager_config.target
coupling_map = pass_manager_config.coupling_map
backend_properties = pass_manager_config.backend_properties
Expand All @@ -257,7 +256,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
routing_pass,
target,
coupling_map=coupling_map,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
if optimization_level == 1:
Expand All @@ -268,7 +267,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
check_trivial=True,
use_barrier_before_measurement=True,
)
Expand All @@ -280,7 +279,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
if optimization_level == 3:
Expand All @@ -291,7 +290,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
Expand Down Expand Up @@ -324,7 +323,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
routing_pass,
target,
coupling_map=coupling_map,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
if optimization_level == 1:
Expand All @@ -335,7 +334,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
check_trivial=True,
use_barrier_before_measurement=True,
)
Expand All @@ -347,7 +346,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
Expand All @@ -358,7 +357,6 @@ class LookaheadSwapPassManager(PassManagerStagePlugin):

def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager:
"""Build routing stage PassManager."""
seed_transpiler = pass_manager_config.seed_transpiler
target = pass_manager_config.target
coupling_map = pass_manager_config.coupling_map
coupling_map_routing = target
Expand All @@ -376,7 +374,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
routing_pass,
target,
coupling_map=coupling_map,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
if optimization_level == 1:
Expand All @@ -388,7 +386,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
check_trivial=True,
use_barrier_before_measurement=True,
)
Expand All @@ -401,7 +399,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
if optimization_level == 3:
Expand All @@ -413,7 +411,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
Expand Down Expand Up @@ -448,7 +446,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
routing_pass,
target,
coupling_map=coupling_map,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
if optimization_level == 1:
Expand All @@ -466,7 +464,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
check_trivial=True,
use_barrier_before_measurement=True,
)
Expand All @@ -486,7 +484,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
if optimization_level == 3:
Expand All @@ -504,7 +502,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
vf2_call_limit=vf2_call_limit,
vf2_max_trials=vf2_max_trials,
backend_properties=backend_properties,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)
raise TranspilerError(f"Invalid optimization level specified: {optimization_level}")
Expand All @@ -515,7 +513,6 @@ class NoneRoutingPassManager(PassManagerStagePlugin):

def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager:
"""Build routing stage PassManager."""
seed_transpiler = pass_manager_config.seed_transpiler
target = pass_manager_config.target
coupling_map = pass_manager_config.coupling_map
routing_pass = Error(
Expand All @@ -527,7 +524,7 @@ def pass_manager(self, pass_manager_config, optimization_level=None) -> PassMana
routing_pass,
target,
coupling_map=coupling_map,
seed_transpiler=seed_transpiler,
seed_transpiler=-1,
use_barrier_before_measurement=True,
)

Expand Down Expand Up @@ -847,7 +844,7 @@ def _swap_mapped(property_set):
)
choose_layout_1 = VF2Layout(
coupling_map=pass_manager_config.coupling_map,
seed=pass_manager_config.seed_transpiler,
seed=-1,
call_limit=int(5e4), # Set call limit to ~100ms with rustworkx 0.10.2
properties=pass_manager_config.backend_properties,
target=pass_manager_config.target,
Expand Down Expand Up @@ -880,7 +877,7 @@ def _swap_mapped(property_set):
elif optimization_level == 2:
choose_layout_0 = VF2Layout(
coupling_map=pass_manager_config.coupling_map,
seed=pass_manager_config.seed_transpiler,
seed=-1,
call_limit=int(5e6), # Set call limit to ~10s with rustworkx 0.10.2
properties=pass_manager_config.backend_properties,
target=pass_manager_config.target,
Expand Down Expand Up @@ -915,7 +912,7 @@ def _swap_mapped(property_set):
elif optimization_level == 3:
choose_layout_0 = VF2Layout(
coupling_map=pass_manager_config.coupling_map,
seed=pass_manager_config.seed_transpiler,
seed=-1,
call_limit=int(3e7), # Set call limit to ~60s with rustworkx 0.10.2
properties=pass_manager_config.backend_properties,
target=pass_manager_config.target,
Expand Down
9 changes: 6 additions & 3 deletions qiskit/transpiler/preset_passmanagers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def generate_routing_passmanager(
coupling_map=None,
vf2_call_limit=None,
backend_properties=None,
seed_transpiler=None,
seed_transpiler=-1,
check_trivial=False,
use_barrier_before_measurement=True,
vf2_max_trials=None,
Expand All @@ -308,7 +308,10 @@ def generate_routing_passmanager(
backend_properties (BackendProperties): Properties of a backend to
synthesize for (e.g. gate fidelities).
seed_transpiler (int): Sets random seed for the stochastic parts of
the transpiler.
the transpiler. This is currently only used for :class:`.VF2PostLayout` and the
default value of ``-1`` is strongly recommended (which is no randomization).
If a value of ``None`` is provided this will seed from system
entropy.
check_trivial (bool): If set to true this will condition running the
:class:`~.VF2PostLayout` pass after routing on whether a trivial
layout was tried and was found to not be perfect. This is only
Expand Down Expand Up @@ -366,7 +369,7 @@ def _swap_condition(property_set):
target,
coupling_map,
backend_properties,
seed_transpiler,
seed=seed_transpiler,
call_limit=vf2_call_limit,
max_trials=vf2_max_trials,
strict_direction=False,
Expand Down
16 changes: 16 additions & 0 deletions releasenotes/notes/64-bit-only-4132f330ec7804b3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
upgrade:
- |
Qiskit no longer supports Linux i686 and 32 bit Windows. Starting in Qiskit
2.0 a 64 bit platform is needed to run Qiskit. The user base for 32bit
architectures is relatively small and as Qiskit continues to focus on
improving performance to handle the increased scale in the complexity
of quantum computing hardware maintaining support for 32 bit platforms
is proving increasingly difficult. This coupled with the larger
scientific/numeric Python community's trend away from 32 bit platform
support maintaining support for 32bit platforms is no longer viable.
Qiskit 1.x will still continue to support 32 bit platforms, but starting
in this 2.0.0 release Qiskit no longer supports these platforms, will
not publish pre-compiled binaries for these platforms any longer, and
there is no longer any guarantee of being able to build from source on
32 bit platforms.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fixed a bug in the :meth:`.Target.instruction_supported` method where
targets with ``self.num_qubits==None`` would always return ``false``
independently of the supported basis set.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
Fixed a bug in the :class:`.UnitarySynthesis` transpiler pass where
non-2-qubit gates would be included in the available 2 qubit basis,
causing the ``TwoQubitWeylDecomposition`` to panic because of
the dimension mismatch.
12 changes: 12 additions & 0 deletions releasenotes/notes/vf2-order-3ef2b4ca5ebd0588.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
upgrade_transpiler:
- |
The default value for the :func:`.generate_routing_passmanager` argument
``seed_transpiler`` has changed from ``None`` to ``-1``. This was done
because this flag was only used to configure the :class:`.VF2PostLayout`
transpiler pass in the output, and for that pass in particular the
randomization typically only hurts performance and is not desirable.
If you were relying on the previous default value you can restore this
behavior by explicitly setting the argument ``seed_transpiler=None``. If
you were explicitly setting a seed value for this parameter there is no
change in behavior.
2 changes: 1 addition & 1 deletion test/python/primitives/test_backend_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def test_layout(self, backend):
estimator.set_transpile_options(seed_transpiler=15, optimization_level=1)
value = estimator.run(qc, op, shots=10000).result().values[0]
if optionals.HAS_AER:
ref_value = -0.9954 if isinstance(backend, GenericBackendV2) else -0.916
ref_value = -0.9954 if isinstance(backend, GenericBackendV2) else -0.934
else:
ref_value = -1
self.assertEqual(value, ref_value)
Expand Down
8 changes: 8 additions & 0 deletions test/python/transpiler/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,14 @@ def test_instruction_supported_no_args(self):
def test_instruction_supported_no_operation(self):
self.assertFalse(self.ibm_target.instruction_supported(qargs=(0,), parameters=[math.pi]))

def test_instruction_supported_no_qubits(self):
"""Checks that instruction supported works when target.num_qubits is None."""
target = Target.from_configuration(["u", "cx", "rxx"])
self.assertTrue(target.instruction_supported("u", (0,)))
self.assertTrue(target.instruction_supported("cx", (0, 1)))
self.assertTrue(target.instruction_supported("cx", None))
self.assertTrue(target.instruction_supported("rxx", (2, 3)))

def test_target_serialization_preserve_variadic(self):
"""Checks that variadics are still seen as variadic after serialization"""

Expand Down
Loading

0 comments on commit dafa66b

Please sign in to comment.