Propagate every run-time failure in pecos-neo as an error instead of printing or panicking - #712
Draft
ciaranra wants to merge 2 commits into
Draft
Propagate every run-time failure in pecos-neo as an error instead of printing or panicking#712ciaranra wants to merge 2 commits into
ciaranra wants to merge 2 commits into
Conversation
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.
Summary
Makes every run-time failure inside a pecos-neo simulation surface as
Err(PecosError)fromsim_neo(),SimNeoBuilder::run(),Simulation::run()and thepecos::sim()facade's neo route. Before this change a failing classical engine was printed to stderr and reported as a completed shot, a simulator that could not execute a gate panicked, and the tool scheduler had no way to carry an error at all.Stacked on #711 (base branch
neo-delete-engines-module); retarget todevonce that merges.What changed
CommandSource::{next_commands, reset, shot_results},ProgramRunner::run_shotandDynProgramRunner::run_shotreturnResult.ClassicalEngineAdapterreturns the wrapped engine's error instead of printing it;QuantumEngineProgramRunnerno longer panics on reset, processing or outcome decoding. A continuation requested without the previous batch's outcomes is now an error rather than a silent completion.ExecutionErrorconverts intoPecosError::Processing(message preserved) and gains aQubitArityvariant for injected gates whose target count does not match their arity.ExecutionErrorthroughapply_noise_responseandCircuitRunner::apply_noiseinstead of asserting. Event handlers are user closures with no build-time validation, so this was a reachable run-time panic.System::run,Schedule::{run_stage, run_shots},Tool::{run, run_shots, run_shots_on}andSimulation::runare fallible; the schedule stops at the first error. Startup-stage engine and backend construction failures propagate the same way, and startup no longer consumes the program source before its fallible build, so aSimulationre-run after a failed start returns the error again instead of panicking.build()beside the existing configuration validators (same loud pattern, pinned withshould_panictests).subset_simulation(0)is rejected there too instead of underflowing. Each sampler's gate-support predicate lives in its own module and is pinned by an exhaustive agreement test that runs the real executor for everyGateTypevariant;GateType::ALLis enforced complete at compile time.pecos::sim()facade propagates with?; thepecos-rslib-expbindings map the error toPyRuntimeError. Doc examples that discarded the result now use?orexpect.Build-time configuration validation that panics inside
SimNeoBuilder::build()is unchanged and out of scope.run_parallel_importanceuses the separate importance runner, which has no fallible operation on that path.Tests
exp/pecos-neo/tests/error_propagation_test.rs(nine tests). Each was run against the pre-change tree first and observed to fail for the stated reason:Okwith a printed error, nowErrcarrying the engine's messagesparse_stab(): previously a panic inProgramRunner::run_shot, nowErrOk, nowErrrun(), nowErrtwiceexecute_noise_gate, nowErrsubset_simulation(0): previously panics inside the executors, now rejected atbuild()Plus three agreement tests (
supports_agrees_with_executor_for_every_gate_type) in the sampler modules, each shown to fail when one arm is removed from its predicate.Verification
All green on a cold build (changed crates cleaned first). The Python wheel cannot be rebuilt in the development environment;
cargo clippy -p pecos-rslib-expis the compile gate for the bindings and the behaviour is exercised by CI.