159 lines
7.2 KiB
Plaintext
159 lines
7.2 KiB
Plaintext
---
|
||
title: CQCExtractor
|
||
description: API reference for qiskit.providers.ibmq.random.CQCExtractor
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.providers.ibmq.random.CQCExtractor
|
||
---
|
||
|
||
<span id="qiskit-providers-ibmq-random-cqcextractor" />
|
||
|
||
# qiskit.providers.ibmq.random.CQCExtractor
|
||
|
||
<Class id="qiskit.providers.ibmq.random.CQCExtractor" isDedicatedPage={true} github="https://github.com/qiskit/qiskit-ibmq-provider/tree/stable/0.12/qiskit/providers/ibmq/random/cqcextractor.py" signature="CQCExtractor(name, provider, client, methods)" modifiers="class">
|
||
Class for interfacing with a CQC remote extractor.
|
||
|
||
There are two extractor methods - Dodis (extractor 1) and Hayashi (extractor 2). These methods can be invoked synchronously or asynchronously. To invoke them synchronously:
|
||
|
||
```python
|
||
random_bits = extractor.run(*cqc_parameters)
|
||
```
|
||
|
||
To invoke them asynchronously:
|
||
|
||
```python
|
||
import numpy as np
|
||
extractor1_out = extractor.run_async_ext1(*ext1_parameters).block_until_ready()
|
||
extractor2_out = extractor.run_async_ext2(
|
||
ext2_seed=extractor1_out, *ext2_parameters).block_until_ready()
|
||
random_bits = np.append(extractor1_out, extractor2_out)
|
||
```
|
||
|
||
Running them asynchronously takes more steps because extractor 2 uses the output of extractor 1 as its seed, so it must wait for extractor 1 to finish first.
|
||
|
||
BaseRandomService constructor.
|
||
|
||
**Parameters**
|
||
|
||
* **name** (`str`) – Name of the extractor.
|
||
* **provider** (`AccountProvider`) – IBM Quantum Experience account provider.
|
||
* **client** (`RandomClient`) – Client used to communicate with the server.
|
||
* **methods** (`List`) – Service methods.
|
||
|
||
### \_\_init\_\_
|
||
|
||
<Function id="qiskit.providers.ibmq.random.CQCExtractor.__init__" signature="__init__(name, provider, client, methods)">
|
||
BaseRandomService constructor.
|
||
|
||
**Parameters**
|
||
|
||
* **name** (`str`) – Name of the extractor.
|
||
* **provider** (`AccountProvider`) – IBM Quantum Experience account provider.
|
||
* **client** (`RandomClient`) – Client used to communicate with the server.
|
||
* **methods** (`List`) – Service methods.
|
||
</Function>
|
||
|
||
## Methods
|
||
|
||
| | |
|
||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
|
||
| [`__init__`](#qiskit.providers.ibmq.random.CQCExtractor.__init__ "qiskit.providers.ibmq.random.CQCExtractor.__init__")(name, provider, client, methods) | BaseRandomService constructor. |
|
||
| [`retrieve_job`](#qiskit.providers.ibmq.random.CQCExtractor.retrieve_job "qiskit.providers.ibmq.random.CQCExtractor.retrieve_job")(job\_id) | Retrieve a previously submitted job. |
|
||
| [`run`](#qiskit.providers.ibmq.random.CQCExtractor.run "qiskit.providers.ibmq.random.CQCExtractor.run")(ext1\_input\_num\_bits, …\[, …]) | Process input data synchronously. |
|
||
| [`run_async_ext1`](#qiskit.providers.ibmq.random.CQCExtractor.run_async_ext1 "qiskit.providers.ibmq.random.CQCExtractor.run_async_ext1")(ext1\_input\_num\_bits, …) | Run the first extractor asynchronously. |
|
||
| [`run_async_ext2`](#qiskit.providers.ibmq.random.CQCExtractor.run_async_ext2 "qiskit.providers.ibmq.random.CQCExtractor.run_async_ext2")(ext2\_seed, …\[, …]) | Run the second extractor asynchronously. |
|
||
|
||
### retrieve\_job
|
||
|
||
<Function id="qiskit.providers.ibmq.random.CQCExtractor.retrieve_job" signature="retrieve_job(job_id)">
|
||
Retrieve a previously submitted job.
|
||
|
||
**Parameters**
|
||
|
||
**job\_id** (`str`) – Job ID.
|
||
|
||
**Return type**
|
||
|
||
`CQCExtractorJob`
|
||
|
||
**Returns**
|
||
|
||
A `CQCExtractorJob` instance.
|
||
</Function>
|
||
|
||
### run
|
||
|
||
<Function id="qiskit.providers.ibmq.random.CQCExtractor.run" signature="run(ext1_input_num_bits, ext1_output_num_bits, ext1_raw_bytes, ext1_wsr_bytes, ext2_seed_num_bits, ext2_wsr_multiplier, ext2_wsr_generator=None)">
|
||
Process input data synchronously.
|
||
|
||
**Parameters**
|
||
|
||
* **ext1\_input\_num\_bits** (`int`) – Number of input bits, for extractor 1.
|
||
* **ext1\_output\_num\_bits** (`int`) – Number of output bits, for extractor 1.
|
||
* **ext1\_raw\_bytes** (`bytes`) – Initial random numbers, in bytes, for extractor 1.
|
||
* **ext1\_wsr\_bytes** (`bytes`) – Initial WSRs, in bytes, for extractor 1.
|
||
* **ext2\_seed\_num\_bits** (`int`) – Number of bits in the seed, for extractor 2.
|
||
* **ext2\_wsr\_multiplier** (`int`) – WSR multiplier, for extractor 2. The number of bits used by extractor 2 is ext2\_seed\_num\_bits\*ext2\_wsr\_multiplier.
|
||
* **ext2\_wsr\_generator** (`Optional`\[`Callable`]) – WSR generator used for extractor 2. It must take the number of bits as the input and a list of random bits (0s and 1s) as the output. If `None`, :func:`generate_wsr` is used.
|
||
|
||
**Return type**
|
||
|
||
`List`\[`int`]
|
||
|
||
**Returns**
|
||
|
||
An instance of `CQCExtractorJob` which can be used to retrieve the results later.
|
||
</Function>
|
||
|
||
### run\_async\_ext1
|
||
|
||
<Function id="qiskit.providers.ibmq.random.CQCExtractor.run_async_ext1" signature="run_async_ext1(ext1_input_num_bits, ext1_output_num_bits, ext1_raw_bytes, ext1_wsr_bytes)">
|
||
Run the first extractor asynchronously.
|
||
|
||
**Parameters**
|
||
|
||
* **ext1\_input\_num\_bits** (`int`) – Number of input bits, for extractor 1.
|
||
* **ext1\_output\_num\_bits** (`int`) – Number of output bits, for extractor 1.
|
||
* **ext1\_raw\_bytes** (`bytes`) – Initial random numbers, in bytes, for extractor 1.
|
||
* **ext1\_wsr\_bytes** (`bytes`) – Initial WSRs, in bytes, for extractor 1.
|
||
|
||
**Return type**
|
||
|
||
`CQCExtractorJob`
|
||
|
||
**Returns**
|
||
|
||
An instance of `CQCExtractorJob` which can be used to retrieve the results later.
|
||
|
||
**Raises**
|
||
|
||
**ValueError** – If an invalid argument values are specified.
|
||
</Function>
|
||
|
||
### run\_async\_ext2
|
||
|
||
<Function id="qiskit.providers.ibmq.random.CQCExtractor.run_async_ext2" signature="run_async_ext2(ext2_seed, ext2_seed_num_bits, ext2_wsr_multiplier, ext2_wsr_generator=None)">
|
||
Run the second extractor asynchronously.
|
||
|
||
**Parameters**
|
||
|
||
* **ext2\_seed** (`List`\[`int`]) – Seed used for extractor 2, such as the output of extractor 1.
|
||
* **ext2\_seed\_num\_bits** (`int`) – Number of bits in the seed, for extractor 2.
|
||
* **ext2\_wsr\_multiplier** (`int`) – WSR multiplier, for extractor 2. The number of bits used by extractor 2 is ext2\_seed\_num\_bits\*ext2\_wsr\_multiplier.
|
||
* **ext2\_wsr\_generator** (`Optional`\[`Callable`]) – WSR generator used for extractor 2. It must take the number of bits as the input and a list of random bits (0s and 1s) as the output. If `None`, :func:`generate_wsr` is used.
|
||
|
||
**Return type**
|
||
|
||
`CQCExtractorJob`
|
||
|
||
**Returns**
|
||
|
||
An instance of `CQCExtractorJob` which can be used to retrieve the results later.
|
||
|
||
**Raises**
|
||
|
||
**ValueError** – If an invalid argument values are specified.
|
||
</Function>
|
||
</Class>
|
||
|