quri_parts.qulacs.simulator module¶
- evaluate_state_to_vector(state, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Apply
state’s circuit to its initial vector and return the resulting state vector.- Parameters:
state (qulacs.types.QulacsStateT) – A quri-parts state whose circuit will be applied to its initial vector.
backend (QulacsBackend) – Backend used to construct the qulacs state and read its state vector.
- Returns:
A
QuantumStateVectorholding the resulting amplitudes.- Return type:
- run_circuit(circuit, init_state, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Apply
circuittoinit_stateand return the resulting state vector.- Parameters:
circuit (ImmutableQuantumCircuit) – Circuit to apply.
init_state (ndarray[Any, dtype[complex128]]) – Initial state vector.
backend (QulacsBackend) – Backend used to construct the qulacs state and read its state vector.
- Returns:
The state vector after applying
circuittoinit_state.- Return type:
ndarray[Any, dtype[complex128]]
- get_marginal_probability(state_vector, measured_values, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Compute the marginal probability of a partial measurement outcome.
- Parameters:
state_vector (ndarray[Any, dtype[complex128]]) – A 1-dimensional array representing the state vector.
measured_values (dict[int, int]) – Desired measurement outcomes keyed by qubit index. For example,
{0: 1, 2: 0}requests the probability of obtaining 1 on qubit 0 and 0 on qubit 2.backend (QulacsBackend) – Backend used to compute the marginal probability.
- Returns:
The marginal probability of the requested outcome.
- Return type:
float
- create_qulacs_vector_state_sampler(random_seed=None, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Create a state sampler based on Qulacs vector simulation.
- Parameters:
random_seed (Optional[int]) – Optional random seed for sampling.
backend (QulacsBackend) – Backend used for simulation (state construction and sampling strategy).
- Returns:
A
StateSamplerthat samples measurement outcomes.- Return type:
StateSampler[QulacsStateT]
- create_concurrent_vector_state_sampler(executor=None, concurrency=1, random_seed=None, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Create a concurrent state sampler based on Qulacs vector simulation.
- Parameters:
executor (Optional['Executor']) – Executor used to run samplers concurrently.
concurrency (int) – Maximum number of concurrent sampler invocations.
random_seed (Optional[int]) – Optional random seed for sampling.
backend (QulacsBackend) – Backend used for simulation (state construction and sampling strategy).
- Returns:
A
ConcurrentStateSamplerthat samples concurrently.- Return type:
ConcurrentStateSampler[QulacsStateT]
- create_qulacs_ideal_vector_state_sampler(backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Create an ideal state sampler returning shot counts proportional to exact probabilities.
- Parameters:
backend (QulacsBackend) – Backend used to construct the qulacs state and read its state vector.
- Returns:
A
StateSamplerreturning ideal (probability-weighted) counts.- Return type:
StateSampler[QulacsStateT]
- create_qulacs_density_matrix_state_sampler(model, random_seed=None, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Create a noisy state sampler using a density matrix.
- Parameters:
model (NoiseModel) – Noise model to apply.
random_seed (Optional[int]) – Optional random seed for sampling.
backend (QulacsBackend) – Backend used to construct the qulacs density matrix.
- Returns:
A
StateSamplersampling from the noisy density matrix.- Return type:
StateSampler[QulacsStateT]
- create_qulacs_ideal_density_matrix_state_sampler(model, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Create an ideal noisy state sampler using a density matrix.
- Parameters:
model (NoiseModel) – Noise model to apply.
backend (QulacsBackend) – Backend used to construct the qulacs density matrix.
- Returns:
A
StateSamplerreturning ideal (probability-weighted) counts from the noisy density matrix.- Return type:
StateSampler[QulacsStateT]
- create_qulacs_noisesimulator_state_sampler(model, random_seed=None, backend=<quri_parts.qulacs._backend.DefaultQulacsBackend object>)¶
Create a state sampler that uses Qulacs
NoiseSimulator.- Parameters:
model (NoiseModel) – Noise model to apply.
random_seed (Optional[int]) – Has no effect (
NoiseSimulatordoes not support seeding); a RuntimeWarning is emitted if notNone.backend (QulacsBackend) – Backend used to construct the qulacs state and the
NoiseSimulatorinstance.
- Returns:
A
StateSamplersampling via QulacsNoiseSimulator.- Return type:
StateSampler[QulacsStateT]