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: Meta

Barrier 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, ABC

Base 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: Op

Classical operation.

args: list[StrictInt | Sym | COp | Bit]#
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: Data

Defining 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: BaseModel

Optional 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, ABC

Data 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: Data

Exporting 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.

args: list[StrictInt | Sym | COp | Bit]#
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: MOp

Idle 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: Block

If/else block.

block: Literal['if']#
condition: COp#
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, ABC

Machine 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: Op

Measurement operation.

args: list[Bit]#
check_sizes() → MeasOp#

Checks whether returns and args lengths match.

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, ABC

Meta 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, ABC

Operation 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: BaseModel

PHIR 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: Block

Parallel 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: Data

Defining 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: Op

Single-qubit Quantum operation.

angles: tuple[list[StrictFloat], Literal['rad', 'pi']] | None#
args: list[Bit]#
check_angles() → SQOp#

Checks whether correct number of angles are provided for a given gate.

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: Block

A 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: MOp

Skip 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: Op

Two-qubit Quantum operation.

angles: tuple[list[StrictFloat], Literal['rad', 'pi']] | None#
args: list[tuple[Bit, Bit]]#
check_angles() → TQOp#

Checks whether correct number of angles are provided for a given gate.

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: MOp

Transport 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.