qcs_sdk.qpu.experimental.random
An [ExternedCall] that may be used to select one or more random
sub-regions from a source array of real values to a destination array.
A valid seed value that may be used to initialize the PRNG. Such
values are in the range [1, MAX_SEQUENCER_VALUE] and are losslessly
convertible to f64.
Errors that may occur using the randomization primitives defined in this module.
Given a seed, start index, series length, and sub-region count, this function will generate and return the sequence of pseudo-randomly chosen indices on the Rigetti control systems.
For instance, if the following Quil program is run for 100 shots:
# presumed sub-region size is 3.
DECLARE destination REAL[6] # prng invocations per shot = (6 / sub_region_size) = 2
DECLARE source REAL[12] # implicit sub-region count = (12 / sub_region_size) = 4
DECLARE seed INTEGER[1]
DECLARE ro BIT[1]
DELAY 0 1e-6
PRAGMA EXTERN choose_random_real_sub_regions "(destination : mut REAL[], source : REAL[], sub_region_size : INTEGER, seed : mut INTEGER)"
CALL choose_random_real_sub_regions destination source 3 seed
with a seed of 639,523, the following will provide the random sequence of sub-region indices:
use qcs::qpu::experimental::random::{choose_random_real_sub_region_indices, PrngSeedValue};
let seed = PrngSeedValue::try_new(639_523).unwrap();
let start_index = 0;
let prng_invocations_per_shot = 2;
let shot_count = 100;
let series_length = prng_invocations_per_shot * shot_count;
let sub_region_count = 4;
let _random_indices = choose_random_real_sub_region_indices(seed, start_index, series_length, sub_region_count);
This represents the linear feedback shift register currently implemented on Rigetti control systems. Specifically, it implements a 48-bit LFSR with taps at 0-based indices 47, 46, 20, and 19. The taps have been shown to produce maximal sequence lengths for 48-bit strings.