Skip to content

Prevent code meant only for simulation from leaking into generated quantum programs and analysis - #3540

Open
Ian Davis (idavis) wants to merge 1 commit into
mainfrom
iadavis/fir-pass-sim-intrinsics
Open

Prevent code meant only for simulation from leaking into generated quantum programs and analysis#3540
Ian Davis (idavis) wants to merge 1 commit into
mainfrom
iadavis/fir-pass-sim-intrinsics

Conversation

@idavis

Copy link
Copy Markdown
Collaborator

Summary

This change prevents code meant only for simulation from leaking into generated quantum programs and FIR transform analysis.

What changed

  • Removed simulation-only implementations before code generation.
  • Treated diagnostic helpers such as DumpOperation and Fact as operations that produce no generated code.
  • Preserved measurements and other side effects in their arguments.
  • Added one shared list of operations that should not appear in generated output.
  • Added earlier, clearer errors for unsupported generic or callable parameters.
  • Updated compiler tests for restricted target profiles and cross-package code.

Why

Simulation helpers may contain fallback code that works in the simulator but cannot be emitted as part of a target program. Processing that code caused compiler failures or references to operations that did not exist at runtime.

The compiler now removes those fallback bodies at the correct boundary while leaving normal simulation behavior unchanged.


/// Intrinsic names that partial evaluation handles as code generation no-ops.
pub const CODEGEN_NOOP_INTRINSIC_NAMES: &[&str] = &[
"DumpRegister",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without really understanding what this list refers to, it surprises me that DumpRegister and DumpOperation would be present, but DumpMachine would be absent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants