scalerqec.Stratified package¶
Submodules¶
scalerqec.Stratified.Scaler module¶
scalerqec.Stratified.ScurveModel module¶
- scalerqec.Stratified.ScurveModel.bias_estimator(N, M)[source]¶
Bias = E[y(w)] - y(w) Estimated by: (1/2) * f’’(P_w) * Var(P_w) where f(x) = ln(1/(2x) - 1)
- scalerqec.Stratified.ScurveModel.linear_function(x, a, b)[source]¶
Linear function for curve fitting.
- scalerqec.Stratified.ScurveModel.modified_sigmoid_function(x, a, b, c, d)[source]¶
Modified sigmoid function for curve fitting. This function is used to fit the S-curve.
- scalerqec.Stratified.ScurveModel.poly_function(x, a, b, c, d)[source]¶
Linear function for curve fitting.
- scalerqec.Stratified.ScurveModel.quadratic_function(x, a, b, c)[source]¶
Linear function for curve fitting.
- scalerqec.Stratified.ScurveModel.scurve_function_with_distance(x, cd, mu, sigma)[source]¶
- Piece-wise S-curve:
0 for x < cd 0.5 * Φ((x - μ) / σ) for x ≥ cd
where Φ is the standard normal CDF.
scalerqec.Stratified.fitting module¶
- scalerqec.Stratified.fitting.r_squared(y_true, y_pred, clip=False)[source]¶
Compute the coefficient of determination (R²).
- Parameters:
y_true (array-like) – Observed data.
y_pred (array-like) – Model-predicted data (same length as y_true).
clip (bool, default False) – If True, negative R² values are clipped to 0 so the score lies strictly in the interval [0, 1].
- Returns:
The R² statistic.
- Return type:
float
scalerqec.Stratified.StratifiedLERcalc module¶
- scalerqec.Stratified.StratifiedLERcalc.SAMPLE_GAP = 100¶
Use strafified sampling algorithm to calculate the logical error rate
- class scalerqec.Stratified.StratifiedLERcalc.StratifiedLERcalc(error_rate=0, sampleBudget=10000, num_subspace=30)[source]¶
Bases:
object- calculate_LER_from_StabCode(qeccirc: StabCode, noise_model: NoiseModel, repeat=1)[source]¶
- determine_range_to_sample(epsilon=0.01)[source]¶
We need to be exact about the range of w we want to sample. We don’t want to sample too many subspaces, especially those subspaces with tiny binomial weights. This should comes from the analysis of the weight of each subspace.
We use the standard deviation to approimxate the range
scalerqec.Stratified.stratifiedScurveLER module¶
- class scalerqec.Stratified.stratifiedScurveLER.StratifiedScurveLERcalc(error_rate=0, sampleBudget=10000, k_range=3, num_subspace=5, beta=4)[source]¶
Bases:
object- calculate_LER_from_StabCode(qeccirc: StabCode, noise_model: NoiseModel, figname, titlename, repeat=1)[source]¶
- calc_logical_error_rate_with_fixed_w(shots, w)[source]¶
Calculate the logical error rate with fixed w
- determine_range_to_sample()[source]¶
We need to be exact about the range of w we want to sample. We don’t want to sample too many subspaces, especially those subspaces with tiny binomial weights. This should comes from the analysis of the weight of each subspace.
We use the standard deviation to approimxate the range
- ground_truth_subspace_sampling()[source]¶
Sample around the subspaces. This is the ground truth value to test the accuracy of the curve fitting.
- sample_all_subspaces(Nclip, Budget, save_path=None)[source]¶
Sample all subspaces from minw to maxw return the result of these samples as two dictionary
- set_sample_bound(MIN_NUM_LE_EVENT, SAMPLE_GAP, MAX_SAMPLE_GAP, MAX_SUBSPACE_SAMPLE)[source]¶
Set the sample bound for the subspace sampling
- set_t(t)[source]¶
Set the t value for the S-curve fitting. This is used to determine the range of subspace we need to sample.
Module contents¶
- class scalerqec.Stratified.Scaler(error_rate=0, time_budget=7200)[source]¶
Bases:
objectUse stratified sampling to estimate the logical error rate of a quantum error correction code. The only hyper parameters are physical error rate and time budget (in seconds).
- class scalerqec.Stratified.StratifiedLERcalc(error_rate=0, sampleBudget=10000, num_subspace=30)[source]¶
Bases:
object- calculate_LER_from_StabCode(qeccirc: StabCode, noise_model: NoiseModel, repeat=1)[source]¶
- determine_range_to_sample(epsilon=0.01)[source]¶
We need to be exact about the range of w we want to sample. We don’t want to sample too many subspaces, especially those subspaces with tiny binomial weights. This should comes from the analysis of the weight of each subspace.
We use the standard deviation to approimxate the range
- class scalerqec.Stratified.StratifiedScurveLERcalc(error_rate=0, sampleBudget=10000, k_range=3, num_subspace=5, beta=4)[source]¶
Bases:
object- calculate_LER_from_StabCode(qeccirc: StabCode, noise_model: NoiseModel, figname, titlename, repeat=1)[source]¶
- calc_logical_error_rate_with_fixed_w(shots, w)[source]¶
Calculate the logical error rate with fixed w
- determine_range_to_sample()[source]¶
We need to be exact about the range of w we want to sample. We don’t want to sample too many subspaces, especially those subspaces with tiny binomial weights. This should comes from the analysis of the weight of each subspace.
We use the standard deviation to approimxate the range
- ground_truth_subspace_sampling()[source]¶
Sample around the subspaces. This is the ground truth value to test the accuracy of the curve fitting.
- sample_all_subspaces(Nclip, Budget, save_path=None)[source]¶
Sample all subspaces from minw to maxw return the result of these samples as two dictionary
- set_sample_bound(MIN_NUM_LE_EVENT, SAMPLE_GAP, MAX_SAMPLE_GAP, MAX_SUBSPACE_SAMPLE)[source]¶
Set the sample bound for the subspace sampling
- set_t(t)[source]¶
Set the t value for the S-curve fitting. This is used to determine the range of subspace we need to sample.