You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Native PHIR-JSON engine ignores cvar_export and returns every register #1323
The native PHIR-JSON engine ignores cvar_export, so sim(PhirJson(...)) returns every classical register instead of only the exported ones.
Cause (from source on the #1314 branch; same on dev)
The PHIR v0.1 spec (crates/pecos-phir-json/specification/v0.1/spec.md) defines {"cop": "cvar_export", "args": [...], "to": [...]} as selecting which classical variables are returned, optionally renaming them with to. In PECOS:
the native engine's DataExport handling skips it (crates/pecos-phir-json/src/v0_1/engine.rs, DataExport arm, and the block executor), and get_results returns all classical registers when no Result mapping exists;
the AST does not keep the to field.
A regression added in the #1314 work shows it: with registers m and scratch, X then Measure into m, and cvar_export ["m"], the native engine returns both m and scratch.
This also blocks the PHIR JSON -> pecos-phir module path: lowering cvar_export to the module's Result instructions would follow the spec (return only m) and disagree with the native engine, so after #1314 the converter rejects cvar_export with a named error. QASM -> PHIR and QuantumCircuit.to_phir_json() both emit cvar_export, so most real programs cannot use the module path until this is fixed.
Direction
Make the native engine honour cvar_export per the spec: return only exported variables, renamed by to when given (keep the AST field). Programs without any cvar_export keep returning all registers.
Lower cvar_export to module Result instructions in phir_json_to_module, and test that QASM-with-creg and qc2phir programs give identical results through the native engine and JSON -> module -> PhirEngine.
This changes what sim(PhirJson(...)) returns for programs with exports (unexported registers disappear): list it as a breaking change, and check PECOS's own producers and tests that rely on unexported registers.
Activity