feat(core): structured profile output with qubit lifetimes, injection impact, and enriched Monte Carlo fields#34
Merged
Conversation
Introduces the external API surface for profile output: ProfileOutput, OutputMeta, TimelineData, ErrorBudget, InjectionImpact, QubitLifetimes, RoutingModelInfo, and SimulationMode. Adds PartialEq to existing profile types for roundtrip test support. ProfileOutput separates the serialized JSON schema from internal ExecutionProfile, allowing the output format to evolve independently.
Adds compute_qubit_lifetimes to ProfileAnalyzer: single O(n) scan over GateScheduled/GateCompleted events to compute per-qubit first-to-last active cycle durations, with mean/max/p95 aggregation. Includes build_gate_qubit_map for OpId-to-qubit lookup from circuit IR. Covers unit and proptest invariants (mean <= max, p95 <= max, zero-qubit edge).
Replaces bare += with saturating_add for all event counters in StreamingAnalyzer (injection errors, fixups, buffer-full, decoder stalls). Shrinks fixup_starts SmallVec inline capacity from 8 to 2 (typical concurrent fixup count). Adds total_factory_productions counter and propagates it through EngineResult::Streaming.
…fields Adds critical_path_extension, total_factory_productions, and successful_injections to ReplicaSummary with corresponding Monte Carlo distributions. Replaces ReplicaSummary::new() with struct-literal syntax for compile-time field sync. Hardens SummaryAccumulator with saturating_add and fixup duration tracking. Adds five OutputMetric variants (StallFraction, CriticalPathExtension, BufferFullRate, InjectionErrorRate, SpaceTimeProduct) for sensitivity analysis. Exposes new fields in Python bindings.
Switches profile subcommand output from raw ExecutionProfile to the structured ProfileOutput envelope with metadata, timeline, error budget, qubit lifetimes, and injection impact sections. Updates integration tests to deserialize ProfileOutput.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
ProfileOutputserialization layer that wrapsExecutionProfileinto a structured JSON envelope, enrichesReplicaSummarywith fixup/factory/injection tracking, and introduces qubit lifetime analysis.Why
The raw
ExecutionProfileleaked internal structure into the CLI JSON output - consumers had no metadata (version, circuit name, hardware model, seed) and missing derived metrics (injection error rate, error budget, qubit lifetimes). Monte Carlo replicas lacked critical-path extension and factory production counts, making it impossible to analyze fixup overhead or injection success rates across runs. Sensitivity analysis had no metrics for stall fraction, buffer-full rate, or space-time product.How
ProfileOutputenvelope (profile.rs): new output types (OutputMeta,TimelineData,ErrorBudget,InjectionImpact,QubitLifetimes,RoutingModelInfo,SimulationMode) that restructureExecutionProfilefields into a stable external schema.ProfileOutput::from_profile()consumes the internal profile and produces the serialized form.analyzer.rs): single O(n) trace scan overGateScheduled/GateCompletedevents via a gate-to-qubit lookup map (build_gate_qubit_map). Computes per-qubit first-to-last active cycle, with mean/max/p95 aggregation. Usesselect_nth_unstablefor O(n) p95 without sorting.streaming.rs): replaces bare+=withsaturating_addon all event counters. Shrinksfixup_startsSmallVec from 8 to 2 inline (typical concurrent fixup count). Addstotal_factory_productionscounter propagated throughEngineResult.monte_carlo.rs): addscritical_path_extension,total_factory_productions,successful_injections. Replaces the positionalReplicaSummary::new()constructor with struct-literal syntax (compile-time field sync still enforced).SummaryAccumulatornow tracks fixup durations and factory production counts. Five newOutputMetricvariants for sensitivity analysis.ProfileOutputJSON instead of rawExecutionProfile. Python bindings expose the three newReplicaSummaryandMonteCarloResultfields.Testing
make cipasses locally (fmt + clippy + test + audit)Checklist
unwrap()/expect()in production code