phir package#
Submodules#
phir.cli module#
PHIR validation driver.
- phir.cli.main() None#
CLI Entrypoint.
phir.model module#
PHIR model lives here.
- class phir.model.Barrier(*, meta: Literal['barrier'], args: list[Bit])#
Bases:
MetaBarrier instruction.
- args: list[Bit]#
- meta: Literal['barrier']#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class phir.model.Block(*, metadata: dict[str, Any] | None = None, block: str)#
Bases:
BaseModel,ABCBase class for block type.
- block: str#
- metadata: dict[str, Any] | None#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class phir.model.COp(*, metadata: dict[str, Any] | None = None, cop: Literal['=', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<=', '&', '|', '^', '~', '<<', '>>'], returns: list[str | Bit] | None = None, args: list[Annotated[int, Strict(strict=True)] | str | COp | Bit])#
Bases:
OpClassical operation.
- cop: Literal['=', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<=', '&', '|', '^', '~', '<<', '>>']#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- returns: list[Sym | Bit] | None#
- class phir.model.CVarDefine(*, metadata: dict[str, Any] | None = None, data: Literal['cvar_define'], data_type: Literal['i64', 'i32', 'u64', 'u32'], variable: str, size: Annotated[Annotated[int, Gt(gt=0)] | None, Strict(strict=True)] = None)#
Bases:
DataDefining Classical Variables.
- check_size() CVarDefine#
Checks whether size fits the data_type.
- data: Literal['cvar_define']#
- data_type: Literal['i64', 'i32', 'u64', 'u32']#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- size: PositiveInt | None#
- variable: Sym#
- class phir.model.Comment(*, c: Annotated[str, MinLen(min_length=3)])#
Bases:
BaseModelOptional comment.
- c: str#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class phir.model.Data(*, metadata: dict[str, Any] | None = None)#
Bases:
BaseModel,ABCData Management Base Class.
- metadata: dict[str, Any] | None#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class phir.model.ExportVar(*, metadata: dict[str, Any] | None = None, data: Literal['cvar_export'], variables: list[str], to: list[str] | None = None)#
Bases:
DataExporting Classical Variables.
- data: Literal['cvar_export']#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- to: list[Sym] | None#
- variables: list[Sym]#
- class phir.model.FFCall(*, metadata: dict[str, Any] | None = None, cop: Literal['ffcall'], returns: list[str | Bit] | None = None, function: str, args: list[Annotated[int, Strict(strict=True)] | str | COp | Bit])#
Bases:
Op(Classical) Foreign Function Call.
- cop: Literal['ffcall']#
- function: str#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- returns: list[Sym | Bit] | None#
- class phir.model.IdleMOp(*, metadata: dict[str, Any] | None = None, mop: Literal['Idle'], args: list[Bit], duration: Duration)#
Bases:
MOpIdle machine op.
- args: list[Bit]#
- duration: Duration#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- mop: Literal['Idle']#
- class phir.model.IfBlock(*, metadata: dict[str, Any] | None = None, block: str)#
Bases:
BlockIf/else block.
- block: Literal['if']#
- false_branch: list[OpType | BlockType] | None#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- true_branch: list[OpType | BlockType]#
- class phir.model.MOp(*, metadata: dict[str, Any] | None = None, mop: str, args: list[Bit] | None = None, duration: Duration | None = None)#
Bases:
Op,ABCMachine operation.
- args: list[Bit] | None#
- duration: Duration | None#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- mop: str#
- class phir.model.MeasOp(*, metadata: dict[str, Any] | None = None, qop: Literal['Measure'], returns: list[Bit], args: list[Bit])#
Bases:
OpMeasurement operation.
- args: list[Bit]#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- qop: Literal['Measure']#
- returns: list[Bit]#
- class phir.model.Meta(*, meta: str)#
Bases:
BaseModel,ABCMeta instructions base class.
- meta: str#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class phir.model.Op(*, metadata: dict[str, Any] | None = None)#
Bases:
BaseModel,ABCOperation Base Class.
- metadata: dict[str, Any] | None#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class phir.model.PHIRModel(*, format: str = 'PHIR/JSON', version: str = '0.1.0', metadata: dict[str, Any] | None = None, ops: list[CVarDefine | QVarDefine | ExportVar | FFCall | COp | MeasOp | SQOp | TQOp | IdleMOp | TransportMOp | SkipMOp | Barrier | SeqBlock | QParBlock | IfBlock | Comment])#
Bases:
BaseModelPHIR model object.
- format_: str#
- metadata: dict[str, Any] | None#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ops: list[Cmd]#
- version: str#
- class phir.model.QParBlock(*, metadata: dict[str, Any] | None = None, block: Literal['qparallel'], ops: list[MeasOp | SQOp | TQOp])#
Bases:
BlockParallel quantum operations block.
- block: Literal['qparallel']#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ops: list[QOp]#
- class phir.model.QVarDefine(*, metadata: dict[str, Any] | None = None, data: Literal['qvar_define'], data_type: str | None = 'qubits', variable: str, size: Annotated[int, Strict(strict=True), Gt(gt=0)])#
Bases:
DataDefining Quantum Variables.
- data: Literal['qvar_define']#
- data_type: str | None#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- size: PositiveInt#
- variable: Sym#
- class phir.model.SQOp(*, metadata: dict[str, Any] | None = None, qop: Literal['Init', 'I', 'X', 'Y', 'Z', 'RX', 'RY', 'RZ', 'R1XY', 'SX', 'SXdg', 'SY', 'SYdg', 'SZ', 'SZdg', 'H', 'F', 'Fdg', 'T', 'Tdg'], angles: tuple[list[Annotated[float, Strict(strict=True)]], Literal['rad', 'pi']] | None = None, args: list[Bit])#
Bases:
OpSingle-qubit Quantum operation.
- angles: tuple[list[StrictFloat], Literal['rad', 'pi']] | None#
- args: list[Bit]#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- qop: Literal['Init', 'I', 'X', 'Y', 'Z', 'RX', 'RY', 'RZ', 'R1XY', 'SX', 'SXdg', 'SY', 'SYdg', 'SZ', 'SZdg', 'H', 'F', 'Fdg', 'T', 'Tdg']#
- class phir.model.SeqBlock(*, metadata: dict[str, Any] | None = None, block: Literal['sequence'], ops: list[FFCall | COp | MeasOp | SQOp | TQOp | IdleMOp | TransportMOp | SkipMOp | Barrier | SeqBlock | QParBlock | IfBlock])#
Bases:
BlockA generic sequence block.
- block: Literal['sequence']#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ops: list[OpType | BlockType]#
- class phir.model.SkipMOp(*, metadata: dict[str, Any] | None = None, mop: Literal['Skip'], args: list[Bit] | None = None, duration: Duration | None = None)#
Bases:
MOpSkip machine op.
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- mop: Literal['Skip']#
- class phir.model.TQOp(*, metadata: dict[str, Any] | None = None, qop: Literal['CX', 'CY', 'CZ', 'RXX', 'RYY', 'RZZ', 'R2XXYYZZ', 'SXX', 'SXXdg', 'SYY', 'SYYdg', 'SZZ', 'SZZdg', 'SWAP'], angles: tuple[list[Annotated[float, Strict(strict=True)]], Literal['rad', 'pi']] | None = None, args: list[tuple[Bit, Bit]])#
Bases:
OpTwo-qubit Quantum operation.
- angles: tuple[list[StrictFloat], Literal['rad', 'pi']] | None#
- args: list[tuple[Bit, Bit]]#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- qop: Literal['CX', 'CY', 'CZ', 'RXX', 'RYY', 'RZZ', 'R2XXYYZZ', 'SXX', 'SXXdg', 'SYY', 'SYYdg', 'SZZ', 'SZZdg', 'SWAP']#
- class phir.model.TransportMOp(*, metadata: dict[str, Any] | None = None, mop: Literal['Transport'], args: list[Bit] | None = None, duration: Duration)#
Bases:
MOpTransport machine op.
- duration: Duration#
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- mop: Literal['Transport']#
Module contents#
Init file for phir.