Conversation
…etire PECOS's compile entry points
…rs, fail loud on unrecognised manglings, and validate compiler options at the boundary
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.
Phase 2 of moving HUGR handling to the Python boundary (the interpreter removal was #732/#733).
Why
PECOS carried its own copy of the HUGR-to-QIS compiler and used it at runtime through the
pecos-rslib-llvmwheel, plus three more Python compile entry points (one shelling out to an externalhugr-llvmbinary) and a broken keyword on the pipeline function. HUGR is upstream's format; the compiler should be upstream's too.What changes
pecos_rslib.hugr_lowering.compile_hugr_to_qis(hugr_bytes, *, platform="helios", opt_level=2, emit_debug=False), lowers with Selene'sselene_hugr_qis_compilerand then applies PECOS's helper-symbol pass to the LLVM IR text: the four PECOS runtime helpers that Guppy declares (pecos_qis_trace_metadata_hugr,pecos_qis_trace_metadata_qubit_hugr,pecos_qis_runtime_barrier_qubit_hugr,pecos_qis_runtime_barrier_qubits2_hugr) are renamed from their private__hugr__...forms at every use, duplicate declarations of the same LLVM type are merged, conflicting or wrong-ABI declarations and any definition of a helper fail loudly, strings and comments are left alone.pecos.compilation_pipeline.compile_hugr_to_qisre-exports it.pecos_rslibsim()) imports that module at runtime instead of the LLVM wheel. The bindings wheel declares the compiler under an optionalhugrextra;quantum-pecosdepends on it directly (selene-hugr-qis-compiler~=0.4.2).HugrLlvmCompiler, the privateGuppyFrontend/run_guppy_on_pecos/compile_guppy_to_qirfrontend (dead: used only by its own tests and one example, and already calling a nonexistent method),HugrTypeError(keyed on a message only the old compiler produced, nothing raised or caught it), and the fallback chain in_compilation.pecos.execute_llvmandpecos.engines.compile_hugr_to_qisdelegate to the boundary;get_compilation_backendsreports the Selene compiler.pecos-hugr-qisand the LLVM wheel's compile export stay for the Rust facade until the next phase; the parity test keeps comparing the two.Behaviour
Running a Guppy program is unchanged: the two compilers share tket-qsystem's lowering, and a d=3 surface-code program with trace metadata and barriers produces byte-identical hosted-operation traces through either (pinned by a new test that runs both on the QIS route and compares
capture_qis_operation_trace). Differences in the emitted text (target triple,EntryPointattribute,mallocnaming, expanded borrow checks) are inert. Invalid HUGR bytes now raise the compiler'sHugrReadErrorinstead of aRuntimeErrorfrom the Rust binding; a missing compiler package raisesImportErrornamingselene-hugr-qis-compiler.Verification
tests/guppy/test_helper_symbols.py(rename on the observed Selene form, merges, conflicts, wrong ABI,define, strings, comments, quoted identifiers, CRLF),tests/guppy/test_compilation_boundary.py,python/pecos-rslib/tests/test_hugr_lowering.py; the migrated lowering tests; fullguppy,pecos,qeclanes 5,197 passed; optional lane 23; Selene and SLR 461; bindings 2,300; doc tests 309;pre-commit,cargo fmt,cargo clippy -p pecos-rslib -D warningsclean. Independent adversarial review executed 25 hand-crafted IR cases against the pass and verified the DEM-path traces.Closes #407 for the runtime path.