qurriumยถ

Qurrium - A Qiskit Macro (qurry.qurrium.qurrium)

class qurry.qurrium.qurrium.QurriumPrototype[source]ยถ

Qurrium, A qiskit Macro. ~ Create countless adventure, legacy and tales. ~

accessor: RemoteAccessor | Noneยถ

The accessor of extra backend. It will be None if no extra backend is loaded.

add(wave: QuantumCircuit, key: Hashable | None = None, replace: Literal[True, False, 'duplicate'] = True) Hashable[source]ยถ

Add new wave function to measure.

Parameters:
  • wave (QuantumCircuit) โ€“ The wave functions or circuits want to measure.

  • key (Optional[Hashable], optional) โ€“ Given a specific key to add to the wave function or circuit, if key == None, then generate a number as key. Defaults to None.

  • replace (Literal[True, False, 'duplicate'], optional) โ€“ If the key is already in the wave function or circuit, then replace the old wave function or circuit when True, or duplicate the wave function or circuit when โ€˜duplicateโ€™. Defaults to True.

Returns:

Key of given wave function in .waves.

Return type:

Optional[Hashable]

build(circuits: list[QuantumCircuit | Hashable], shots: int = 1024, backend: Backend | None = None, exp_name: str = 'experiment', run_args: BaseRunArgs | dict[str, Any] | None = None, transpile_args: TranspileArgs | None = None, passmanager: str | PassManager | tuple[str, PassManager] | None = None, tags: tuple[str, ...] | None = None, qasm_version: Literal['qasm2', 'qasm3'] = 'qasm3', export: bool = False, save_location: str | Path | None = None, pbar: tqdm | None = None, **custom_and_main_kwargs: Any) str[source]ยถ

Build the experiment.

Parameters:
  • circuits (list[Union[QuantumCircuit, Hashable]]) โ€“ The circuits or keys of circuits in .waves.

  • shots (int, optional) โ€“ Shots of the job. Defaults to 1024.

  • backend (Backend, optional) โ€“ The quantum backend. Defaults to AerSimulator().

  • exp_name (str, optional) โ€“ The name of the experiment. Naming this experiment to recognize it when the jobs are pending to IBMQ Service. This name is also used for creating a folder to store the exports. Defaults to โ€˜experimentโ€™.

  • run_args (RunArgsType, optional) โ€“ Arguments for Backend.run(). Defaults to None.

  • transpile_args (Optional[TranspileArgs], optional) โ€“ Arguments of transpile() from qiskit.compiler.transpiler. Defaults to None.

  • passmanager (PassManagerType, optional) โ€“ The passmanager. Defaults to None.

  • tags (Optional[tuple[str, ...]], optional) โ€“ Given the experiment multiple tags to make a dictionary for recongnizing it.

  • qasm_version (Literal["qasm2", "qasm3"], optional) โ€“ The export version of OpenQASM. Defaults to โ€˜qasm3โ€™.

  • export (bool, optional) โ€“ Whether to export the experiment. Defaults to False.

  • save_location (Optional[Union[Path, str]], optional) โ€“ The location to save the experiment. Defaults to None.

  • pbar (Optional[tqdm.tqdm], optional) โ€“ The progress bar for showing the progress of the experiment. Defaults to None.

  • custom_and_main_kwargs (Any) โ€“ Other custom arguments.

Returns:

The experiment.

Return type:

ExperimentPrototype

abstract property experiment_instance: Type[_E]ยถ

The instance of experiment.

exps: ExperimentContainerWrapper[_E]ยถ

The wrapper of experiments container from orphan_exps and multimanagers.

has(wavename: Hashable) bool[source]ยถ

Is there a wave with specific name.

Parameters:

wavename (Hashable) โ€“ Name of wave which is used in .waves

Returns:

Exist or not.

Return type:

bool

abstract measure() str[source]ยถ

Execute the experiment.

abstract measure_to_output() _OA[source]ยถ

Trasnform measure() arguments form into output() form.

multiAnalysis(summoner_id: str, *, analysis_name: str = 'report', no_serialize: bool = False, specific_analysis_args: dict[Hashable, _RA | dict[str, Any] | bool] | None = None, skip_write: bool = False, multiprocess_write: bool = False, **analysis_args: Any) str[source]ยถ

Run the analysis for multiple experiments.

Parameters:
  • summoner_id (str) โ€“ The summoner_id of multimanager.

  • analysis_name (str, optional) โ€“ The name of analysis. Defaults to โ€˜reportโ€™.

  • no_serialize (bool, optional) โ€“ Whether to serialize the analysis. Defaults to False.

  • specific_analysis_args (SpecificAnalsisArgs[_RA, optional) โ€“ The specific arguments for analysis. Defaults to None.

  • skip_write (bool, optional) โ€“ Whether to skip the file writing during the analysis. Defaults to False.

  • multiprocess_write (bool, optional) โ€“ Whether use multiprocess for writing. Defaults to False.

  • analysis_args (Any, optional) โ€“ Other arguments for analysis.

Returns:

The summoner_id of multimanager.

Return type:

str

multiBuild(config_list: list[dict[str, ~typing.Any]] | list[~qurry.declare.qurrium._MA] | list[~qurry.declare.qurrium._MA | dict[str, ~typing.Any]], summoner_name: str | None = None, summoner_id: str | None = None, shots: int = 1024, backend: ~qiskit.providers.backend.Backend = <AerSimulator('aer_simulator')>, tags: tuple[str, ...] | None = None, manager_run_args: ~qurry.declare.run.base_run.BaseRunArgs | dict[str, ~typing.Any] | None = None, save_location: ~pathlib.Path | str = PosixPath('.'), jobstype: ~typing.Literal['local', 'IBMQ', 'IBM', 'IBMRuntime', 'Qulacs', 'AWS_Bracket', 'Azure_Q'] = 'local', pending_strategy: ~typing.Literal['onetime', 'each', 'tags'] = 'tags', skip_build_write: bool = True, multiprocess_build: bool = False, multiprocess_write: bool = True) str[source]ยถ

Build the multimanager.

Parameters:
  • config_list (ConfigListType[_BA]) โ€“ The list of default configurations of multiple experiment.

  • summoner_name (Optional[str], optional) โ€“ Name for multimanager. Defaults to None. When None, it will be set to their coresponding short_name.

  • summoner_id (Optional[str], optional) โ€“ Id for multimanager. Defaults to None.

  • shots (int, optional) โ€“ Shots of the job. Defaults to 1024.

  • backend (Backend, optional) โ€“ The backend to run. Defaults to GeneralSimulator().

  • tags (Optional[tuple[str, ...]], optional) โ€“ Tags of experiment of :cls:`MultiManager`. Defaults to None.

  • manager_run_args (Optional[Union[BaseRunArgs, dict[str, Any]]], optional) โ€“ The extra arguments for running the job, but for all experiments in the multimanager. For backend.run() from :cls:`qiskit.providers.backend`. Defaults to {}.

  • save_location (Union[Path, str], optional) โ€“ Where to save the export content as json file. If save_location == None, then cancelled the file to be exported. Defaults to Path(โ€˜./โ€™).

  • jobstype (Union[Literal['local'], PendingTargetProviderLiteral], optional) โ€“ Type of jobs to run multiple experiments. - jobstype: โ€œlocalโ€, โ€œIBMQโ€, โ€œIBMโ€, โ€œAWS_Bracketโ€, โ€œAzure_Qโ€ Defaults to โ€œlocalโ€.

  • pending_strategy (PendingStrategyLiteral, optional) โ€“ Type of pending strategy. - pendingStrategy: โ€œdefaultโ€, โ€œonetimeโ€, โ€œeachโ€, โ€œtagsโ€ Defaults to โ€œtagsโ€.

  • skip_build_write (bool, optional) โ€“ Whether to skip the file writing during the building. Defaults to True.

  • multiprocess_build (bool, optional) โ€“ Whether use multiprocess for building. Defaults to False.

  • multiprocess_write (bool, optional) โ€“ Whether use multiprocess for writing. Defaults to True.

Returns:

The summoner_id of multimanager.

Return type:

str

multiOutput(config_list: list[dict[str, ~typing.Any]] | list[~qurry.declare.qurrium._MA] | list[~qurry.declare.qurrium._MA | dict[str, ~typing.Any]], summoner_name: str | None = None, summoner_id: str | None = None, shots: int = 1024, backend: ~qiskit.providers.backend.Backend = <AerSimulator('aer_simulator')>, tags: tuple[str, ...] | None = None, manager_run_args: ~qurry.declare.run.base_run.BaseRunArgs | dict[str, ~typing.Any] | None = None, save_location: ~pathlib.Path | str = PosixPath('.'), skip_build_write: bool = True, skip_output_write: bool = False, multiprocess_build: bool = False, multiprocess_write: bool = True) str[source]ยถ

Output the multiple experiments.

Parameters:
  • config_list (ConfigListType[_BA]) โ€“ The list of default configurations of multiple experiment.

  • summoner_name (Optional[str], optional) โ€“ Name for multimanager. Defaults to None. When None, it will be set to their coresponding short_name.

  • summoner_id (Optional[str], optional) โ€“ Id for multimanager. Defaults to None.

  • shots (int, optional) โ€“ Shots of the job. Defaults to 1024.

  • backend (Backend, optional) โ€“ The backend to run. Defaults to GeneralSimulator().

  • tags (Optional[tuple[str, ...]], optional) โ€“ Tags of experiment of :cls:`MultiManager`. Defaults to None.

  • manager_run_args (Optional[Union[BaseRunArgs, dict[str, Any]]], optional) โ€“ The extra arguments for running the job, but for all experiments in the multimanager. For backend.run() from :cls:`qiskit.providers.backend`. Defaults to {}.

  • save_location (Union[Path, str], optional) โ€“ Where to save the export content as json file. If save_location == None, then cancelled the file to be exported. Defaults to Path(โ€˜./โ€™).

  • skip_build_write (bool, optional) โ€“ Whether to skip the file writing during the building. Defaults to True.

  • skip_output_write (bool, optional) โ€“ Whether to skip the file writing during the output. Defaults to False.

  • multiprocess_build (bool, optional) โ€“ Whether use multiprocess for building. Defaults to False.

  • multiprocess_write (bool, optional) โ€“ Whether use multiprocess for writing. Defaults to True.

Returns:

The summoner_id of multimanager.

Return type:

str

multiPending(config_list: list[dict[str, ~typing.Any]] | list[~qurry.declare.qurrium._MA] | list[~qurry.declare.qurrium._MA | dict[str, ~typing.Any]], summoner_name: str = 'qurrium', summoner_id: str | None = None, shots: int = 1024, backend: ~qiskit.providers.backend.Backend = <AerSimulator('aer_simulator')>, provider: ~typing.Any | None = None, tags: tuple[str, ...] | None = None, manager_run_args: dict[str, ~typing.Any] | None = None, save_location: ~pathlib.Path | str = PosixPath('.'), jobstype: ~typing.Literal['local', 'IBMQ', 'IBM', 'IBMRuntime', 'Qulacs', 'AWS_Bracket', 'Azure_Q'] = 'IBM', pending_strategy: ~typing.Literal['onetime', 'each', 'tags'] = 'tags') str[source]ยถ

Pending the multiple experiments.

Parameters:
  • config_list (ConfigListType[_BA]) โ€“ The list of default configurations of multiple experiment.

  • summoner_name (str, optional) โ€“ Name for multimanager. Defaults to their coresponding short_name.

  • summoner_id (Optional[str], optional) โ€“ Id for multimanager. Defaults to None.

  • shots (int, optional) โ€“ Shots of the job. Defaults to 1024.

  • backend (Backend, optional) โ€“ The quantum backend. Defaults to GeneralSimulator().

  • provider (Optional[Any], optional) โ€“ The provider. Defaults to None.

  • tags (Optional[tuple[str, ...]], optional) โ€“ Tags of experiment of :cls:`MultiManager`. Defaults to None.

  • manager_run_args (Optional[dict[str, Any]], optional) โ€“ The extra arguments for running the job, but for all experiments in the multimanager. For backend.run() from :cls:`qiskit.providers.backend`. Defaults to {}.

  • save_location (Union[Path, str], optional) โ€“ Where to save the export content as json file. If save_location == None, then cancelled the file to be exported. Defaults to Path(โ€˜./โ€™).

  • jobstype (PendingTargetProviderLiteral, optional) โ€“ Type of jobs to run multiple experiments. - jobstype: โ€œlocalโ€, โ€œIBMQโ€, โ€œIBMโ€, โ€œAWS_Bracketโ€, โ€œAzure_Qโ€ Defaults to โ€œIBMโ€.

  • pending_strategy (PendingStrategyLiteral, optional) โ€“ Type of pending strategy. - pendingStrategy: โ€œdefaultโ€, โ€œonetimeโ€, โ€œeachโ€, โ€œtagsโ€ Defaults to โ€œtagsโ€.

Returns:

The summoner_id of multimanager.

Return type:

str

multiRead(summoner_name: str, save_location: Path | str = PosixPath('.'), reload: bool = False, read_from_tarfile: bool = False) str[source]ยถ

Read the multimanager from the file.

Parameters:
  • summoner_name (str) โ€“ Name for multimanager.

  • save_location (Union[Path, str], optional) โ€“ Where to save the export content as json file. If save_location == None, then cancelled the file to be exported. Defaults to Path(โ€˜./โ€™).

  • reload (bool, optional) โ€“ Whether to reload the multimanager. Defaults to False.

  • read_from_tarfile (bool, optional) โ€“ Whether to read from the tarfile. Defaults to False.

Returns:

The summoner_id of multimanager.

Return type:

str

multiRetrieve(summoner_name: str | None = None, summoner_id: str | None = None, backend: Backend | None = None, provider: Any | None = None, save_location: Path | str = PosixPath('.'), refresh: bool = False, overwrite: bool = False, reload: bool = False, read_from_tarfile: bool = False) str[source]ยถ

Retrieve the multiple experiments.

Parameters:
  • summoner_name (Optional[str], optional) โ€“ Name for multimanager. Defaults to None.

  • summoner_id (Optional[str], optional) โ€“ Id for multimanager. Defaults to None.

  • backend (Optional[Backend], optional) โ€“ The quantum backend. Defaults to None.

  • provider (Optional[Any], optional) โ€“ The provider. Defaults to None.

  • save_location (Union[Path, str], optional) โ€“ Where to save the export content as json file. If save_location == None, then cancelled the file to be exported. Defaults to Path(โ€˜./โ€™).

  • refresh (bool, optional) โ€“ Whether to refresh the retrieve. Defaults to False.

  • overwrite (bool, optional) โ€“ Whether to overwrite the retrieve. Defaults to False.

  • reload (bool, optional) โ€“ Whether to reload the multimanager. Defaults to False.

  • read_from_tarfile (bool, optional) โ€“ Whether to read from the tarfile. Defaults to False.

Raises:
  • ValueError โ€“ No summoner_name or summoner_id given.

  • ValueError โ€“ Both summoner_name and summoner_id are given.

  • ValueError โ€“ No such summoner_id in multimanagers.

  • TypeError โ€“ summoner_name or summoner_id is not str.

  • ValueError โ€“ No backend or provider given.

Returns:

The summoner_id of multimanager.

Return type:

str

multiWrite(summoner_id: str, save_location: str | Path | None = None, compress: bool = False, compress_overwrite: bool = False, remain_only_compressed: bool = False, export_transpiled_circuit: bool = False, skip_before_and_after: bool = False, skip_exps: bool = False, skip_quantities: bool = False, multiprocess_write: bool = True) str[source]ยถ

Write the multimanager to the file.

Parameters:
  • summoner_id (str) โ€“ The summoner_id of multimanager.

  • save_location (Union[Path, str], optional) โ€“ Where to save the export content as json file. If save_location == None, then cancelled the file to be exported. Defaults to Path(โ€˜./โ€™).

  • compress (bool, optional) โ€“ Whether to compress the export file. Defaults to False.

  • compress_overwrite (bool, optional) โ€“ Whether to overwrite the compressed file. Defaults to False.

  • remain_only_compressed (bool, optional) โ€“ Whether to remain only compressed file. Defaults to False.

  • export_transpiled_circuit (bool, optional) โ€“ Whether to export the transpiled circuit. Defaults to False.

  • skip_before_and_after (bool, optional) โ€“ Skip the beforewards and afterwards. Defaults to False.

  • skip_exps (bool, optional) โ€“ Skip the experiments. Defaults to False.

  • skip_quantities (bool, optional) โ€“ Skip the quantities container. Defaults to False.

  • multiprocess_write (bool, optional) โ€“ Whether to use multiprocess to write the file. Defaults to True.

Raises:

ValueError โ€“ summoner_id not in multimanagers.

Returns:

The summoner_id of multimanager.

Return type:

str

multimanagers: MultiManagerContainer[_E]ยถ

The last multimanager be called.

orphan_exps: ExperimentContainer[_E]ยถ

The orphan experiments container.

output(circuits: list[QuantumCircuit | Hashable] | None = None, shots: int = 1024, backend: Backend | None = None, exp_name: str = 'experiment', run_args: BaseRunArgs | dict[str, Any] | None = None, transpile_args: TranspileArgs | None = None, passmanager: str | PassManager | tuple[str, PassManager] | None = None, tags: tuple[str, ...] | None = None, exp_id: str | None = None, qasm_version: Literal['qasm2', 'qasm3'] = 'qasm3', export: bool = False, save_location: str | Path | None = None, pbar: tqdm | None = None, **custom_and_main_kwargs: Any) str[source]ยถ

Output the experiment.

Parameters:
  • circuits (Optional[list[Union[QuantumCircuit, Hashable]]], optional) โ€“ The circuits or keys of circuits in .waves. Defaults to None.

  • shots (int, optional) โ€“ Shots of the job. Defaults to 1024.

  • backend (Optional[Backend], optional) โ€“ The quantum backend. Defaults to None.

  • exp_name (str, optional) โ€“ Naming this experiment to recognize it when the jobs are pending to IBMQ Service. This name is also used for creating a folder to store the exports. Defaults to โ€˜experimentโ€™.

  • run_args (RunArgsType, optional) โ€“ Arguments for Backend.run(). Defaults to None.

  • transpile_args (Optional[TranspileArgs], optional) โ€“ Arguments of transpile() from qiskit.compiler.transpiler. Defaults to None.

  • passmanager (PassManagerType, optional) โ€“ The passmanager. Defaults to None.

  • tags (Optional[tuple[str, ...]], optional) โ€“ Given the experiment multiple tags to make a dictionary for recongnizing it. Defaults to None.

  • exp_id (Optional[str], optional) โ€“ The ID of experiment. Defaults to None.

  • qasm_version (Literal["qasm2", "qasm3"], optional) โ€“ The export version of OpenQASM. Defaults to โ€˜qasm3โ€™.

  • export (bool, optional) โ€“ Whether to export the experiment. Defaults to False.

  • save_location (Optional[Union[Path, str]], optional) โ€“ The location to save the experiment. Defaults to None.

  • pbar (Optional[tqdm.tqdm], optional) โ€“ The progress bar for showing the progress of the experiment. Defaults to None.

  • custom_and_main_kwargs (Any) โ€“ Other custom arguments.

Returns:

The experiment ID.

Return type:

str

passmanagers: PassManagerContainerยถ

The collection of pass managers.

remove(key: Hashable) None[source]ยถ

Remove wave function from .waves.

Parameters:

wave (Hashable) โ€“ The key of wave in .waves.

short_name = 'qurrium'ยถ

The short name of Qurrium.

waves: WaveContainerยถ

The wave functions container.