Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.
Important

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

CQCExtractor

class CQCExtractor(name, provider, client, methods)

GitHub

Bases: qiskit.providers.ibmq.random.baserandomservice.BaseRandomService

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:

random_bits = extractor.run(*cqc_parameters)

To invoke them asynchronously:

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.

Methods

retrieve_job

CQCExtractor.retrieve_job(job_id)

Retrieve a previously submitted job.

Parameters

job_id (str) – Job ID.

Return type

CQCExtractorJob

Returns

A CQCExtractorJob instance.

run

CQCExtractor.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.

run_async_ext1

CQCExtractor.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.

run_async_ext2

CQCExtractor.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.

Was this page helpful?
Report a bug or request content on GitHub.