Skip to main content

faultscope_core/
lib.rs

1//! Rust core types for FaultScope.
2//!
3//! This crate is the Python-independent home for FaultScope's circuit, detector
4//! error model, and hotspot data model.  The PyO3 crate is responsible for
5//! adapting these types to Python and for the remaining Python callback
6//! integration while the algorithms are migrated here.
7
8mod compile;
9mod decoder;
10mod dem;
11mod dem_canonical;
12mod dem_problem;
13mod dem_sampling;
14mod expr;
15mod hotspot;
16mod labels;
17mod mask;
18mod model;
19mod packed;
20mod pauli;
21mod program;
22mod rng;
23mod sampling;
24mod stabilizer;
25
26pub use compile::compile_sampler_program_ref;
27#[cfg(feature = "decoder-fusion-blossom")]
28pub use decoder::NativeFusionBlossomDecoder;
29pub use decoder::{
30    convert_detector_batch, logical_residual_loss_mask_native, mask_corrections_to_packed,
31    packed_corrections_to_masks, packed_residual_failure_count, select_detector_batch_format,
32    validate_decoder_batch_formats, validate_decoder_detector_ids, validate_decoder_observable_ids,
33    CorrectionMaskBatch, DecoderCorrectionBatch, DetectorBatch, DetectorBatchFormat,
34    DetectorBatchView, DetectorEventShotBatchView, DetectorMaskBatchView,
35    FaultScopeNativeCorrectionBatchMutViewV4, FaultScopeNativeCorrectionBatchPayloadV4,
36    FaultScopeNativeCorrectionMaskBatchMutViewV1, FaultScopeNativeDecoderFactoryV4,
37    FaultScopeNativeDecoderI64SliceV1, FaultScopeNativeDecoderMaskMutViewV1,
38    FaultScopeNativeDecoderMaskViewV1, FaultScopeNativeDecoderStatusV1,
39    FaultScopeNativeDecoderStringViewV1, FaultScopeNativeDecoderU32SliceV1,
40    FaultScopeNativeDecoderWorkerV4, FaultScopeNativeDetectorBatchPayloadV4,
41    FaultScopeNativeDetectorBatchViewV4, FaultScopeNativeDetectorEventShotBatchViewV1,
42    FaultScopeNativeDetectorMaskBatchViewV1, FaultScopeNativePackedDetectorShotBatchViewV1,
43    FaultScopeNativePackedObservableShotBatchMutViewV1, NativeCompositeDecoder,
44    NativeDecoderFactory, NativeDecoderWorker, NativeGraphlikeDetectorCopyDecoder,
45    NativeNoCorrectionDecoder, PackedDetectorShotBatchView, PackedObservableShotBatch,
46    NATIVE_DECODER_BATCH_FORMAT_EVENTS, NATIVE_DECODER_BATCH_FORMAT_MASKS,
47    NATIVE_DECODER_BATCH_FORMAT_PACKED, NATIVE_DECODER_FACTORY_FLAG_THREAD_SAFE,
48    NATIVE_DECODER_PLUGIN_ABI_NAME, NATIVE_DECODER_PLUGIN_ABI_VERSION,
49    NATIVE_DECODER_PLUGIN_CAPSULE_METHOD, NATIVE_DECODER_PLUGIN_CAPSULE_NAME,
50    NATIVE_DECODER_PLUGIN_ENTRY_POINT_GROUP, NATIVE_DECODER_PLUGIN_STATUS_ERROR,
51    NATIVE_DECODER_PLUGIN_STATUS_OK,
52};
53pub use dem::{
54    collect_dem_event_plan, collect_dem_event_plan_with_options, detectors_from_circuit,
55    generate_dem_edges, generate_dem_edges_from_event_plan, generate_dem_edges_with_options,
56    observables_from_circuit, DemEventPlan, DemGenerationOptions, DetectorErrorModelGenerator,
57    LazyDetectorErrorModel, ValidatedDemCircuit,
58};
59pub use dem_problem::{
60    log_likelihood_ratio, BinaryLinearDecodingProblem, FaultScopeNativeGraphlikeEdgeV1,
61    FaultScopeNativeGraphlikeProblemV1, GraphlikeDecodingProblem, GraphlikeDecompositionComponent,
62    GraphlikeEdge, GraphlikeEdgeRef, IndexedDem, IndexedDemEdge, SparseBinaryMatrix,
63    NATIVE_GRAPHLIKE_PROBLEM_ABI_NAME, NATIVE_GRAPHLIKE_PROBLEM_ABI_VERSION,
64    NATIVE_GRAPHLIKE_PROBLEM_CAPSULE_METHOD, NATIVE_GRAPHLIKE_PROBLEM_CAPSULE_NAME,
65};
66pub use dem_sampling::{
67    CompiledDemLogicalCountPlan, CompiledDemSamplingPlan, DemAttributionTrace, DemHotspotEstimator,
68    DemObservableBatch, DemSamplingResult, DetectorEventDemShotBatch, PackedDemShotBatch,
69};
70pub use expr::Expr;
71pub use hotspot::compute_packed_estimate;
72pub use labels::{IndexedNoiseLocation, LocationCatalog, LocationId};
73pub use mask::{word_count, Mask};
74pub use model::{
75    Circuit, DemBatch, DemEvent, DemHotspotEstimate, DemLocationGroup, Detector, DetectorErrorEdge,
76    DetectorErrorModel, DetectorGraphEstimate, DetectorGraphKey, HotspotEstimate,
77    LogicalObservable, NoiseLocation, NoiseModel, NpError, NpResult, Operation, TagValue,
78};
79pub use packed::{
80    run_sampler_program, FaultScopeSimulator, PauliBasis, RuntimeCapacities, RuntimeState,
81    SamplerObservable, SamplerOperation, SamplerProgram,
82};
83pub use program::expand_circuit_operations;
84pub use rng::SmallRng;
85pub use sampling::{
86    bernoulli_mask, choose_weighted_event, compile_pauli_channel_events, for_each_bernoulli_event,
87    positive_unit_f64, random_bit_mask, set_shot_bit, CompiledPauliEvent,
88    TWO_QUBIT_DEPOLARIZING_EVENTS,
89};
90pub use stabilizer::{ConcreteStabilizer, PauliFrame};