uniqc.circuit_builder.originir_ext_spec module¶
OriginIR-ext language specification — the superset of official OriginIR.
OriginIR-ext extends the official OriginIR (accepted by OriginQ cloud) with:
Extended gates: ECR, ISWAP, XX, YY, ZZ, XY, PHASE2Q, UU15, RPhi, RPhi90, RPhi180 (all decomposable to official gates for cloud submission)
Extended features: DEF/ENDDEF blocks, QRAM (Quantum RAM) instructions, error channels for noise simulation
Symbolic parameters (local-only): a
PARAMheader declaration plus inline symbolic parameter references / expressions in gate angle slots — see the “Symbolic-parameter extension” note below.Extended syntax: inline
daggersuffix, inlinecontrolled_by(q[...])clause (as an alternative to DAGGER/CONTROL blocks)Classical / control-flow extension (local-simulation only — see
uniqc.simulator.OriginIR_ext_Simulator):a runtime classical-register (CREG) of single bits
c[0..n-1](declared byCREG n), written by measurement and classical instructions and read by conditions;MEASURE q[i], c[j]as a mid-circuit measurement writing CREG bitj(valid both mid-circuit and terminally);RESET q[i]mid-circuit qubit reset;classical bit instructions
AND/OR/XOR(op c[d], A, B) andMOV/NOT(op c[d], A), RISC three-operand / destination-first, whereA/Bare CREG bitsc[k]or0/1immediates;classical control flow
QIF <cond> ... [QELSE ...] ENDQIFandQWHILE <cond> ... ENDQWHILE, where<cond>is boolean logic over CREG bits usingnot/~,and/&,xor/^,or/|(lowercase keywords and symbols interchangeable) and parentheses.
These constructs are an OriginIR-ext-only feature and cannot be exported to OpenQASM or submitted to cloud backends.
Symbolic-parameter extension (local-only — mirrors the Python
Parameter/Parametersclasses):a
PARAMheader declaration, either scalar (PARAM theta) or array (PARAM alpha[4], expanding to the element symbolsalpha_0..alpha_3), placed after theQINIT/CREGheader;inline symbolic parameter references and arithmetic expressions in a gate’s angle slot, e.g.
RX q[0], (theta),RY q[1], (alpha[2])orRZ q[0], (2*theta + phi/3). Expressions are parsed/round-tripped via sympy and may not contain commas or parentheses (so no nested groups or function calls); split such angles into distinct named parameters instead.
A circuit carrying unbound
PARAMsymbols serializes to OriginIR-ext but must be bound to concrete values viauniqc.circuit_builder.Circuit.assign_parameters()before it can be simulated, exported to OpenQASM / official OriginIR, or submitted to cloud.
OriginIR-ext is the default local programming language in UnifiedQuantum.
When submitting to OriginQ cloud, circuits are automatically converted to
strict official OriginIR via uniqc.compile.decompose_for_originir().
See uniqc.circuit_builder.originir_spec for the official (downstream)
gate set, and uniqc.circuit_builder.originir_ext_spec (this module) for
the full superset.