strangeworks_qiskit_runtime package¶
Submodules¶
strangeworks_qiskit_runtime.runtime_client module¶
Strangeworks Runtime Client.
- class StrangeworksRuntimeClient(channel, rsc: Resource | None = None, sdk_client: SWClient | None = None, **kwargs)¶
Bases:
RuntimeClient
- backend_configuration(backend_name: str) Dict[str, Any] ¶
Return the configuration of the IBM backend.
- Parameters:
backend_name – The name of the IBM backend.
- Returns:
Backend configuration.
- backend_properties(backend_name: str, datetime: datetime | None = None) Dict[str, Any] ¶
Return the properties of the IBM backend.
- Parameters:
backend_name – The name of the IBM backend.
datetime – Date and time for additional filtering of backend properties.
- Returns:
Backend properties.
- Raises:
NotImplementedError – If datetime is specified.
- backend_pulse_defaults(backend_name: str)¶
Return the pulse defaults of the IBM backend.
- Parameters:
backend_name – The name of the IBM backend.
- Returns:
Backend pulse defaults.
- close_session(session_id: str) None ¶
Close the runtime session.
- Parameters:
session_id – Session ID.
- create_session(backend: str | None = None, instance: str | None = None, max_time: int | None = None, channel: str | None = None, mode: str | None = None) None ¶
Create the runtime session.
- Parameters:
session_id – Session ID.
- job_get(job_slug, **kwargs)¶
Get job data.
- Parameters:
job_id – Job ID.
- Returns:
JSON response.
- jobs_get(**kwargs)¶
Get job data for all jobs.
- Parameters:
limit – Number of results to return.
skip – Number of results to skip.
backend_name – Name of the backend to retrieve jobs from.
pending – Returns ‘QUEUED’ and ‘RUNNING’ jobs if True, returns ‘DONE’, ‘CANCELLED’ and ‘ERROR’ jobs if False.
program_id – Filter by Program ID.
hub – Filter by hub - hub, group, and project must all be specified.
group – Filter by group - hub, group, and project must all be specified.
project – Filter by project - hub, group, and project must all be specified.
job_tags – Filter by tags assigned to jobs. Matched jobs are associated with all tags.
session_id – Job ID of the first job in a runtime session.
created_after – Filter by the given start date, in local time. This is used to find jobs whose creation dates are after (greater than or equal to) this local date/time.
created_before – Filter by the given end date, in local time. This is used to find jobs whose creation dates are before (less than or equal to) this local date/time.
descending – If
True
, return the jobs in descending order of the job creation date (i.e. newest first) until the limit is reached.
- Returns:
JSON response.
- program_run(program_id: str, backend_name: str | None, params: Dict, image: str | None, log_level: str | None, session_id: str | None, job_tags: List[str] | None = None, max_execution_time: int | None = None, start_session: bool | None = False, session_time: int | None = None, channel_strategy: str | None = None) Dict ¶
Execute the program.
- Parameters:
program_id – Program ID.
backend_name – Name of the backend.
params – Program parameters.
image – Runtime image.
hub – Hub to be used.
group – Group to be used.
project – Project to be used.
log_level – Log level to use.
session_id – ID of the first job in a runtime session.
job_tags – Tags to be assigned to the job.
max_execution_time – Maximum execution time in seconds.
start_session – Set to True to explicitly start a runtime session.
False. (Defaults to)
session_time – Length of session in seconds.
- Returns:
JSON response.
strangeworks_qiskit_runtime.service module¶
Strangeworks Qiskit Runtime Service.
- class StrangeworksQiskitRuntimeService(resource_slug: str | None = None, channel: Literal['ibm_cloud', 'ibm_quantum', 'local'] | None = 'ibm_cloud')¶
Bases:
object
Class for interacting with the Qiskit Runtime service.
Qiskit Runtime is a new architecture offered by IBM Quantum that streamlines computations requiring many iterations. These experiments will execute significantly faster within its improved hybrid quantum/classical process.
- backend(name: str | None = None, instance: str | None = None) IBMBackend ¶
Return a single backend matching the specified filtering.
- backend_options(name: str | None = None, combined: Dict[str, Any] | None = None, min_num_qubits: int | None = None, instance: str | None = None, filters: Callable[[List[IBMBackend]], bool] | None = None, **kwargs: Any) List[IBMBackend] ¶
Return all backends accessible via this account, subject to optional filtering.
- backends() IBMBackend ¶
Return a list of available backends.
- job(job_id: str) StrangeworksRuntimeJob ¶
Retrieve a runtime job.
- Parameters:
job_id – Job ID.
- Returns:
Runtime job retrieved.
- Raises:
RuntimeJobNotFound – If the job doesn’t exist.
IBMRuntimeError – If the request failed.
- jobs() List[StrangeworksRuntimeJob] ¶
Retrieve all runtime jobs, subject to optional filtering for the product
strangeworks_qiskit_runtime.sw_runtime_job module¶
Strangeworks runtime job.
- class Backend(name)¶
Bases:
object
Backend Object
- class StrangeworksRuntimeJob(job_slug: str, service: Any | None = None, backend: str | None = None, params: Dict | None = None, session_id: str | None = None, tags: List | None = None)¶
Bases:
object
Strangeworks runtime program execution.
- backend() str ¶
backend.
- Returns:
Backend where job was run job.
- cancel() None ¶
Cancel the job.
- Raises:
RuntimeInvalidStateError – If the job is in a state that cannot be cancelled.
IBMRuntimeError – If unable to cancel job.
- error_message() str | None ¶
Returns the reason if the job failed.
- Returns:
Error message string or
None
.
- interim_results(decoder: Type[ResultDecoder] | None = None) Any ¶
Return the interim results of the job.
- Parameters:
decoder – A
ResultDecoder
subclass used to decode interim results.- Returns:
Runtime job interim results.
- Raises:
RuntimeJobFailureError – If the job failed.
- job_id() str ¶
Return a unique id identifying the job.
- property job_slug: str¶
job_slug.
- Returns:
Job slug of strangeworks job.
- result(timeout: float | None = None, decoder: Type[ResultDecoder] | None = None) Any ¶
Return the results of the job.
- Parameters:
timeout – Number of seconds to wait for job.
decoder – A
ResultDecoder
subclass used to decode job results.
- Returns:
Runtime job result.
- Raises:
RuntimeJobFailureError – If the job failed.
RuntimeJobMaxTimeoutError – If the job does not complete within given
timeout. –
- property session_id: str¶
Session ID.
- Returns:
Job ID of the first job in a runtime session.
- status() JobStatus ¶
Return the status of the job.
- Returns:
Status of this job.
- property tags: List¶
Job tags.
- Returns:
Tags assigned to the job that can be used for filtering.
strangeworks_qiskit_runtime.sw_session module¶
- class StrangeworksSession(service: StrangeworksQiskitRuntimeService | None = None, backend: str | BackendV1 | BackendV2 | None = None, max_time: int | str | None = 1440)¶
Bases:
Session
Class for interacting with the Qiskit Runtime service.
Qiskit Runtime is a new architecture offered by IBM Quantum that streamlines computations requiring many iterations. These experiments will execute significantly faster within its improved hybrid quantum/classical process.
- close() None ¶
Close the session so new jobs will no longer be accepted, but existing queued or running jobs will run to completion. The session will be terminated once there # noqa are no more pending jobs.
- run(program_id: str, inputs: Dict, options: Dict | None = None, callback: Callable | None = None, result_decoder: Type[ResultDecoder] | None = None) RuntimeJobV2 ¶
Run a program in the session.
- Parameters:
program_id – Program ID.
inputs – Program input parameters. These input values are passed to the runtime program.
options – Runtime options that control the execution environment.
callback – Callback function to be invoked for any interim results and final result. # noqa
- Returns:
Submitted job.
Module contents¶
Strangeworks Qiskit Runtime SDK