Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Update stable/0.7 (#758)
Browse files Browse the repository at this point in the history
* Update main 0.7.1 (#719)

* Fix typing in `DAGCircuit.apply_operation_back` (#721)

It is not valid typing (per the documentation) to pass `None` to
`DAGCircuit.apply_operation_back` in either the `qargs` or `cargs`
field, though this has been silently accepted previously to support
mistaken code in the Terra schedulers, which this repository has
inherited.

* Update serialization for non-basic types (#715)

* Update json.py

* Update json.py

* Added test for metadata serialization

* added release notes

* Moved test here from qiskit-ibm-runtime (#722)

* Moved here from qiskit-ibm-runtime

* Fixed imports

* Removed code related to Schedule (#724)

* Removed code related to Schedule, qubit_lo_freq, mea_lo_freq, schedule_los

* black and lint

* Returned lines in documentation that were removed by mistake

* Fixed documentation

* Put back range parameters

* Removed auth parameter and migrate method (#727)

* Removed auth parameter and migrate method

* Updated documentation

* black

* Remove `qiskit-ibmq-provider` from `requirements-dev.txt` (#729)

* Remove qiskit-ibmq-provider from requirements-dev.txt

* Remove IBMQ

* Breaking change in Qiskit 0.45 - Gate.duration setting (#732)

* breaking change in Qiskit 0.45

* black

* Bit.index is deprecated since Apr 2021 (#733)

Co-authored-by: Kevin Tian <[email protected]>

* Update hms_to_seconds to support times greater than 1 day (#731)

* Update hms_to_seconds

* add reno

* Add option to no pad idle qubits in scheduling passes (#725)

* Add option to no pad idle qubits in scheduling passes

This commit adds a new flag to the scheduling padding passes,
schedule_idle_qubits, which is used to opt-in to scheduling idle qubits.
By default these passes will only schedule qubits which are active. This
is a change in behavior from before where the previous default is all
qubits were scheduled. This was undesireable because it's adding
uneceesary instructions to the job payload which will need to be
processed which are effectively a no-op. The only real use case for
adding delays to idle wires is visualization, so it's left as an option
to re-enable the previous default.

Fixes #723

Co-authored-by: Thomas Alexander <[email protected]>

* Add missing inline type hint

* Don't put barriers on idle qubits either

* Fix formatting

* Add schedule_idle_qubits to parent constructor

* Reneable padding in control flow

* Omit idle qubits in control flow

* Run black

---------

Co-authored-by: Thomas Alexander <[email protected]>
Co-authored-by: Diego Ristè <[email protected]>
Co-authored-by: Kevin Tian <[email protected]>

* Update test_jobs_filter (#738)

* readjust test_convert_id_to_delay (#739)

* readjust test_convert_id_to_delay

* disable not-context-manager

* duplicated entry

* Exceptions should inherit from Terra where suitable (#741)

* Changed inheritance of exception classes

* Changed error type

* Support method job.properties() (#742)

* Implemented job.properties() method

* release note

* Updated documentation

* Improved the tests

---------

Co-authored-by: Kevin Tian <[email protected]>

* Use job creation date when returning backend properties in `job.properties()` (#746)

* use job creation date in properties

* add reno

* remove datetime param

* update test_job_backend_properties (#747)

* Support shots as np.int64 (#744)

* Fixed bug where shots defined as np.number

* Added test

* black

* add reno

---------

Co-authored-by: Kevin Tian <[email protected]>

* use qpy.load from terra (#751)

* remove print statement in test (#752)

* Prepare release 0.7.1 (#753)

* Update main branch 0.7.2 (#754)

* migrate pypi trusted publisher (#750)

---------

Co-authored-by: Jake Lishman <[email protected]>
Co-authored-by: ItamarGoldman <[email protected]>
Co-authored-by: merav-aharoni <[email protected]>
Co-authored-by: Luciano Bello <[email protected]>
Co-authored-by: Matthew Treinish <[email protected]>
Co-authored-by: Thomas Alexander <[email protected]>
Co-authored-by: Diego Ristè <[email protected]>
  • Loading branch information
8 people authored Oct 25, 2023
1 parent 94fe136 commit a9f6652
Show file tree
Hide file tree
Showing 37 changed files with 601 additions and 384 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
jobs:
Deploy:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
strategy:
matrix:
python-version: [3.9]
Expand All @@ -28,12 +31,12 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install deps
run: pip install -U pip setuptools build
- name: Build sdist
run: python3 -m build
- uses: actions/upload-artifact@v3
with:
path: ./dist/*
- name: Deploy to Pypi
env:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
TWINE_USERNAME: qiskit
run : |
pip install -U twine pip setuptools virtualenv wheel
python3 setup.py sdist bdist_wheel
twine upload dist/qiskit*
shell: bash
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ disable=arguments-renamed, # more readable and clear
too-many-public-methods, # too verbose
too-many-statements, # too verbose
unnecessary-pass, # allow for methods with just "pass", for clarity
not-context-manager, # terra is not fully type-safe

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '0.7.0'
release = '0.7.2'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_provider/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.0
0.7.2
33 changes: 1 addition & 32 deletions qiskit_ibm_provider/accounts/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def save(
overwrite: Optional[bool] = False,
) -> None:
"""Save account on disk."""
cls.migrate()
name = name or cls._default_account_name_ibm_quantum
return save_config(
filename=cls._default_account_config_json_file,
Expand All @@ -70,7 +69,6 @@ def list(
name: Optional[str] = None,
) -> Dict[str, Account]:
"""List all accounts saved on disk."""
AccountManager.migrate()

def _matching_name(account_name: str) -> bool:
return name is None or name == account_name
Expand Down Expand Up @@ -120,7 +118,7 @@ def get(
"""Read account from disk.
Args:
name: Account name. Takes precedence if `auth` is also specified.
name: Account name. Takes precedence.
channel: Channel type.
Returns:
Expand All @@ -129,7 +127,6 @@ def get(
Raises:
AccountNotFoundError: If the input value cannot be found on disk.
"""
cls.migrate()
if name:
saved_account = read_config(
filename=cls._default_account_config_json_file, name=name
Expand Down Expand Up @@ -167,37 +164,9 @@ def delete(
name: Optional[str] = None,
) -> bool:
"""Delete account from disk."""
cls.migrate()
name = name or cls._default_account_name_ibm_quantum
return delete_config(name=name, filename=cls._default_account_config_json_file)

@classmethod
def migrate(cls) -> None:
"""Migrate accounts on disk by removing `auth` and adding `channel`."""
data = read_config(filename=cls._default_account_config_json_file)
for key, value in data.items():
if key == cls._default_account_name_legacy:
value.pop("auth", None)
value.update(channel="ibm_quantum")
delete_config(filename=cls._default_account_config_json_file, name=key)
save_config(
filename=cls._default_account_config_json_file,
name=cls._default_account_name_ibm_quantum,
config=value,
overwrite=False,
)
else:
if hasattr(value, "auth"):
if value["auth"] == "legacy":
value.update(channel="ibm_quantum")
value.pop("auth", None)
save_config(
filename=cls._default_account_config_json_file,
name=key,
config=value,
overwrite=True,
)

@classmethod
def _from_env_variables(cls, channel: Optional[ChannelType]) -> Optional[Account]:
"""Read account from environment variable."""
Expand Down
45 changes: 6 additions & 39 deletions qiskit_ibm_provider/ibm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
PulseBackendConfiguration,
)
from qiskit.providers.options import Options
from qiskit.pulse import Schedule, LoConfig
from qiskit.pulse.channels import (
PulseChannel,
AcquireChannel,
ControlChannel,
DriveChannel,
Expand Down Expand Up @@ -332,24 +330,14 @@ def target_history(self, datetime: Optional[python_datetime] = None) -> Target:

def run(
self,
circuits: Union[
QuantumCircuit, Schedule, str, List[Union[QuantumCircuit, Schedule, str]]
],
circuits: Union[QuantumCircuit, str, List[Union[QuantumCircuit, str]]],
dynamic: bool = None,
job_tags: Optional[List[str]] = None,
init_circuit: Optional[QuantumCircuit] = None,
init_num_resets: Optional[int] = None,
header: Optional[Dict] = None,
shots: Optional[Union[int, float]] = None,
memory: Optional[bool] = None,
qubit_lo_freq: Optional[List[int]] = None,
meas_lo_freq: Optional[List[int]] = None,
schedule_los: Optional[
Union[
List[Union[Dict[PulseChannel, float], LoConfig]],
Union[Dict[PulseChannel, float], LoConfig],
]
] = None,
meas_level: Optional[Union[int, MeasLevel]] = None,
meas_return: Optional[Union[str, MeasReturnType]] = None,
rep_delay: Optional[float] = None,
Expand All @@ -366,10 +354,6 @@ def run(
Args:
circuits: An individual or a
list of :class:`~qiskit.circuits.QuantumCircuit`.
:class:`~qiskit.pulse.Schedule` is no longer supported. Use ``pulse gates`` instead.
See `tutorial
<https://qiskit.org/documentation/tutorials/circuits_advanced/05_pulse_gates.html>`_
on how to use pulse gates.
dynamic: Whether the circuit is dynamic (uses in-circuit conditionals)
job_tags: Tags to be assigned to the job. The tags can subsequently be used
as a filter in the :meth:`jobs()` function call.
Expand All @@ -389,11 +373,6 @@ def run(
memory: If ``True``, per-shot measurement bitstrings are returned as well
(provided the backend supports it). For OpenPulse jobs, only
measurement level 2 supports this option.
qubit_lo_freq: List of default qubit LO frequencies in Hz. Will be overridden by
``schedule_los`` if set.
meas_lo_freq: List of default measurement LO frequencies in Hz. Will be overridden
by ``schedule_los`` if set.
schedule_los: Experiment LO configurations, frequencies are given in Hz.
meas_level: Level of the measurement output for pulse experiments. See
`OpenPulse specification <https://arxiv.org/pdf/1809.03452.pdf>`_ for details:
Expand Down Expand Up @@ -498,9 +477,6 @@ def run(
header=header,
shots=shots,
memory=memory,
qubit_lo_freq=qubit_lo_freq,
meas_lo_freq=meas_lo_freq,
schedule_los=schedule_los,
meas_level=meas_level,
meas_return=meas_return,
rep_delay=rep_delay,
Expand Down Expand Up @@ -769,17 +745,16 @@ def __repr__(self) -> str:
return "<{}('{}')>".format(self.__class__.__name__, self.name)

def _deprecate_id_instruction(
self, circuits: List[Union[QuantumCircuit, Schedule]]
) -> List[Union[QuantumCircuit, Schedule]]:
self, circuits: List[QuantumCircuit]
) -> List[QuantumCircuit]:
"""Raise a DeprecationWarning if any circuit contains an 'id' instruction.
Additionally, if 'delay' is a 'supported_instruction', replace each 'id'
instruction (in-place) with the equivalent ('sx'-length) 'delay' instruction.
Args:
circuits: The individual or list of :class:`~qiskit.circuits.QuantumCircuit` or
:class:`~qiskit.pulse.Schedule` objects passed to
:meth:`IBMBackend.run()<IBMBackend.run>`. Modified in-place.
circuits: The individual or list of :class:`~qiskit.circuits.QuantumCircuit`
passed to :meth:`IBMBackend.run()<IBMBackend.run>`. Modified in-place.
Returns:
A modified copy of the original circuit where 'id' instructions are replaced with
Expand Down Expand Up @@ -844,22 +819,14 @@ def _check_circuits_attributes(self, circuits: List[QuantumCircuit]) -> None:
"""Check that circuits can be executed on backend.
Raises:
IBMBackendValueError:
- If Schedule is given as an input circuit.
- If one of the circuits contains more qubits than on the backend."""
schedule_error_msg = (
"Class 'Schedule' is no longer supported as an input circuit. "
"Use 'pulse gates' instead. See `tutorial "
"https://qiskit.org/documentation/tutorials/circuits_advanced/05_pulse_gates.html` "
"on how to use pulse gates."
)

if len(circuits) > self._max_circuits:
raise IBMBackendValueError(
f"Number of circuits, {len(circuits)} exceeds the "
f"maximum for this backend, {self._max_circuits})"
)
for circ in circuits:
if isinstance(circ, Schedule):
raise IBMBackendValueError(schedule_error_msg)
if isinstance(circ, QuantumCircuit):
if circ.num_qubits > self._configuration.num_qubits:
raise IBMBackendValueError(
Expand Down
6 changes: 3 additions & 3 deletions qiskit_ibm_provider/ibm_backend_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def jobs(
descending: If ``True``, return the jobs in descending order of the job
creation date (i.e. newest first) until the limit is reached.
instance: The provider in the hub/group/project format.
legacy: If ``True``, only retrieve jobs run from the deprecated ``qiskit-ibmq-provider``.
legacy: If ``True``, only retrieve jobs run from the archived ``qiskit-ibmq-provider``.
Otherwise, only retrieve jobs run from ``qiskit-ibm-provider``.
Returns:
Expand Down Expand Up @@ -383,7 +383,7 @@ def _get_jobs(
skip: Starting index for the job retrieval.
descending: If ``True``, return the jobs in descending order of the job
creation date (i.e. newest first) until the limit is reached.
legacy: Filter to only retrieve jobs run from the deprecated `qiskit-ibmq-provider`.
legacy: Filter to only retrieve jobs run from the archived ``qiskit-ibmq-provider``.
Returns:
A list of raw API response.
Expand Down Expand Up @@ -435,7 +435,7 @@ def _restore_circuit_job(
job_info: Job info in dictionary format.
raise_error: Whether to raise an exception if `job_info` is in
an invalid format.
legacy: Filter to only retrieve jobs run from the deprecated `qiskit-ibmq-provider`.
legacy: Filter to only retrieve jobs run from the archived ``qiskit-ibmq-provider``.
Returns:
Circuit job restored from the data, or ``None`` if format is invalid.
Expand Down
9 changes: 4 additions & 5 deletions qiskit_ibm_provider/job/ibm_circuit_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import queue
from concurrent import futures
from datetime import datetime
from typing import Dict, Optional, Any, List, Union
from typing import Dict, Optional, Any, List
import re
import requests

Expand All @@ -27,7 +27,6 @@
from qiskit.circuit.quantumcircuit import QuantumCircuit

from qiskit.result import Result
from qiskit.pulse import Schedule

from qiskit_ibm_provider import ibm_backend # pylint: disable=unused-import
from .constants import IBM_COMPOSITE_JOB_TAG_PREFIX, IBM_MANAGED_JOB_ID_PREFIX
Expand Down Expand Up @@ -611,11 +610,11 @@ def header(self) -> Dict:
return self._params.get("header")
return {}

def circuits(self) -> List[Union[QuantumCircuit, Schedule]]:
"""Return the circuits or pulse schedules for this job.
def circuits(self) -> List[QuantumCircuit]:
"""Return the circuits for this job.
Returns:
The circuits or pulse schedules for this job. An empty list
The circuits or for this job. An empty list
is returned if the circuits cannot be retrieved (for example, if
the job uses an old format that is no longer supported).
"""
Expand Down
29 changes: 16 additions & 13 deletions qiskit_ibm_provider/job/ibm_composite_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import uuid
from collections import defaultdict
from concurrent import futures
from datetime import datetime
from datetime import datetime as python_datetime
from functools import wraps
from typing import Dict, Optional, Tuple, Any, List, Callable, Union

Expand All @@ -30,7 +30,6 @@
from qiskit.compiler import assemble
from qiskit.providers.jobstatus import JOB_FINAL_STATES, JobStatus
from qiskit.providers.models import BackendProperties
from qiskit.pulse import Schedule
from qiskit.qobj import QasmQobj, PulseQobj
from qiskit.result import Result
from qiskit.result.models import ExperimentResult
Expand Down Expand Up @@ -123,11 +122,9 @@ def __init__(
backend: "ibm_backend.IBMBackend",
api_client: AccountClient,
job_id: Optional[str] = None,
creation_date: Optional[datetime] = None,
creation_date: Optional[python_datetime] = None,
jobs: Optional[List[IBMCircuitJob]] = None,
circuits_list: Optional[
List[Union[List[QuantumCircuit], List[Schedule]]]
] = None,
circuits_list: Optional[List[List[QuantumCircuit]]] = None,
run_config: Optional[Dict] = None,
name: Optional[str] = None,
tags: Optional[List[str]] = None,
Expand Down Expand Up @@ -259,7 +256,7 @@ def from_jobs(

def _submit_circuits(
self,
circuit_lists: List[Union[List[QuantumCircuit], List[Schedule]]],
circuit_lists: List[List[QuantumCircuit]],
run_config: Dict,
) -> None:
"""Assemble and submit circuits.
Expand Down Expand Up @@ -376,9 +373,15 @@ def _async_submit(self, sub_job: SubJob) -> None:
pass

@_requires_submit
def properties(self) -> Optional[Union[List[BackendProperties], BackendProperties]]:
def properties(
self, refresh: bool = False
) -> Optional[Union[List[BackendProperties], BackendProperties]]:
"""Return the backend properties for this job.
Args:
refresh: If ``True``, re-query the server for the backend properties.
Otherwise, return a cached version.
Note:
This method blocks until all sub-jobs are submitted.
Expand All @@ -395,7 +398,7 @@ def properties(self) -> Optional[Union[List[BackendProperties], BackendPropertie
self._properties = []
properties_ts = []
for job in self._get_circuit_jobs():
props = job.properties()
props = job.properties(refresh)
if props.last_update_date not in properties_ts:
self._properties.append(props)
properties_ts.append(props.last_update_date)
Expand Down Expand Up @@ -755,7 +758,7 @@ def queue_info(self) -> Optional[QueueInfo]:
self._queue_info = None
return self._queue_info

def creation_date(self) -> Optional[datetime]:
def creation_date(self) -> Optional[python_datetime]:
"""Return job creation date, in local time.
Returns:
Expand Down Expand Up @@ -873,11 +876,11 @@ def refresh(self) -> None:
if job.status() not in JOB_FINAL_STATES:
job.refresh()

def circuits(self) -> List[Union[QuantumCircuit, Schedule]]:
"""Return the circuits or pulse schedules for this job.
def circuits(self) -> List[QuantumCircuit]:
"""Return the circuits for this job.
Returns:
The circuits or pulse schedules for this job.
The circuits for this job.
"""
if not self._circuits:
qobj = self._get_qobj()
Expand Down
Loading

0 comments on commit a9f6652

Please sign in to comment.