phir package#

Submodules#

phir.cli module#

PHIR validation driver.

phir.cli.main() None#

CLI Entrypoint.

phir.model module#

PHIR model lives here.

pydantic model phir.model.Barrier#

Bases: Meta

Barrier instruction.

Show JSON schema
{
   "title": "Barrier",
   "description": "Barrier instruction.",
   "type": "object",
   "properties": {
      "meta": {
         "const": "barrier",
         "title": "Meta",
         "type": "string"
      },
      "args": {
         "items": {
            "maxItems": 2,
            "minItems": 2,
            "prefixItems": [
               {
                  "type": "string"
               },
               {
                  "minimum": 0,
                  "type": "integer"
               }
            ],
            "type": "array"
         },
         "title": "Args",
         "type": "array"
      }
   },
   "additionalProperties": false,
   "required": [
      "meta",
      "args"
   ]
}

Config:
  • extra: str = forbid

Fields:
field args: list[Bit] [Required]#
field meta: Literal['barrier'] [Required]#
pydantic model phir.model.Block#

Bases: BaseModel, ABC

Base class for block type.

Show JSON schema
{
   "title": "Block",
   "description": "Base class for block type.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "block": {
         "title": "Block",
         "type": "string"
      }
   },
   "additionalProperties": false,
   "required": [
      "block"
   ]
}

Config:
  • extra: str = forbid

Fields:
field block: str [Required]#
field metadata: dict[str, Any] | None = None#
pydantic model phir.model.COp#

Bases: Op

Classical operation.

Show JSON schema
{
   "$defs": {
      "COp": {
         "additionalProperties": false,
         "description": "Classical operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "enum": [
                  "=",
                  "+",
                  "-",
                  "*",
                  "/",
                  "%",
                  "==",
                  "!=",
                  ">",
                  "<",
                  ">=",
                  "<=",
                  "&",
                  "|",
                  "^",
                  "~",
                  "<<",
                  ">>"
               ],
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "args"
         ],
         "title": "COp",
         "type": "object"
      }
   },
   "$ref": "#/$defs/COp"
}

Config:
  • extra: str = forbid

Fields:
field args: list[StrictInt | Sym | COp | Bit] [Required]#
field cop: Literal['=', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<=', '&', '|', '^', '~', '<<', '>>'] [Required]#
field returns: list[Sym | Bit] | None = None#
pydantic model phir.model.CVarDefine#

Bases: Data

Defining Classical Variables.

Show JSON schema
{
   "title": "CVarDefine",
   "description": "Defining Classical Variables.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "data": {
         "const": "cvar_define",
         "title": "Data",
         "type": "string"
      },
      "data_type": {
         "enum": [
            "i64",
            "i32",
            "u64",
            "u32"
         ],
         "title": "Data Type",
         "type": "string"
      },
      "variable": {
         "title": "Variable",
         "type": "string"
      },
      "size": {
         "anyOf": [
            {
               "exclusiveMinimum": 0,
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Size"
      }
   },
   "additionalProperties": false,
   "required": [
      "data",
      "data_type",
      "variable"
   ]
}

Config:
  • extra: str = forbid

Fields:
Validators:
field data: Literal['cvar_define'] [Required]#
Validated by:
field data_type: Literal['i64', 'i32', 'u64', 'u32'] [Required]#
Validated by:
field size: PositiveInt | None = None#
Constraints:
  • strict = True

Validated by:
field variable: Sym [Required]#
Validated by:
validator check_size  »  all fields#

Checks whether size fits the data_type.

pydantic model phir.model.Comment#

Bases: BaseModel

Optional comment.

Show JSON schema
{
   "title": "Comment",
   "description": "Optional comment.",
   "type": "object",
   "properties": {
      "//": {
         "minLength": 3,
         "title": "//",
         "type": "string"
      }
   },
   "additionalProperties": false,
   "required": [
      "//"
   ]
}

Config:
  • extra: str = forbid

Fields:
field c: str [Required] (alias '//')#
Constraints:
  • min_length = 3

pydantic model phir.model.Data#

Bases: BaseModel, ABC

Data Management Base Class.

Show JSON schema
{
   "title": "Data",
   "description": "Data Management Base Class.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field metadata: dict[str, Any] | None = None#
pydantic model phir.model.ExportVar#

Bases: Data

Exporting Classical Variables.

Show JSON schema
{
   "title": "ExportVar",
   "description": "Exporting Classical Variables.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "data": {
         "const": "cvar_export",
         "title": "Data",
         "type": "string"
      },
      "variables": {
         "items": {
            "type": "string"
         },
         "title": "Variables",
         "type": "array"
      },
      "to": {
         "anyOf": [
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "To"
      }
   },
   "additionalProperties": false,
   "required": [
      "data",
      "variables"
   ]
}

Config:
  • extra: str = forbid

Fields:
field data: Literal['cvar_export'] [Required]#
field to: list[Sym] | None = None#
field variables: list[Sym] [Required]#
pydantic model phir.model.FFCall#

Bases: Op

(Classical) Foreign Function Call.

Show JSON schema
{
   "title": "FFCall",
   "description": "(Classical) Foreign Function Call.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "cop": {
         "const": "ffcall",
         "title": "Cop",
         "type": "string"
      },
      "returns": {
         "anyOf": [
            {
               "items": {
                  "anyOf": [
                     {
                        "type": "string"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Returns"
      },
      "function": {
         "title": "Function",
         "type": "string"
      },
      "args": {
         "items": {
            "anyOf": [
               {
                  "type": "integer"
               },
               {
                  "type": "string"
               },
               {
                  "$ref": "#/$defs/COp"
               },
               {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               }
            ]
         },
         "title": "Args",
         "type": "array"
      }
   },
   "$defs": {
      "COp": {
         "additionalProperties": false,
         "description": "Classical operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "enum": [
                  "=",
                  "+",
                  "-",
                  "*",
                  "/",
                  "%",
                  "==",
                  "!=",
                  ">",
                  "<",
                  ">=",
                  "<=",
                  "&",
                  "|",
                  "^",
                  "~",
                  "<<",
                  ">>"
               ],
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "args"
         ],
         "title": "COp",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "cop",
      "function",
      "args"
   ]
}

Config:
  • extra: str = forbid

Fields:
field args: list[StrictInt | Sym | COp | Bit] [Required]#
field cop: Literal['ffcall'] [Required]#
field function: str [Required]#
field returns: list[Sym | Bit] | None = None#
pydantic model phir.model.IdleMOp#

Bases: MOp

Idle machine op.

Show JSON schema
{
   "title": "IdleMOp",
   "description": "Idle machine op.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "mop": {
         "const": "Idle",
         "title": "Mop",
         "type": "string"
      },
      "args": {
         "items": {
            "maxItems": 2,
            "minItems": 2,
            "prefixItems": [
               {
                  "type": "string"
               },
               {
                  "minimum": 0,
                  "type": "integer"
               }
            ],
            "type": "array"
         },
         "title": "Args",
         "type": "array"
      },
      "duration": {
         "maxItems": 2,
         "minItems": 2,
         "prefixItems": [
            {
               "type": "number"
            },
            {
               "enum": [
                  "s",
                  "ms",
                  "us",
                  "ns"
               ],
               "type": "string"
            }
         ],
         "title": "Duration",
         "type": "array"
      }
   },
   "additionalProperties": false,
   "required": [
      "mop",
      "args",
      "duration"
   ]
}

Config:
  • extra: str = forbid

Fields:
field args: list[Bit] [Required]#
field duration: Duration [Required]#
field mop: Literal['Idle'] [Required]#
pydantic model phir.model.IfBlock#

Bases: Block

If/else block.

Show JSON schema
{
   "$defs": {
      "Barrier": {
         "additionalProperties": false,
         "description": "Barrier instruction.",
         "properties": {
            "meta": {
               "const": "barrier",
               "title": "Meta",
               "type": "string"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "meta",
            "args"
         ],
         "title": "Barrier",
         "type": "object"
      },
      "COp": {
         "additionalProperties": false,
         "description": "Classical operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "enum": [
                  "=",
                  "+",
                  "-",
                  "*",
                  "/",
                  "%",
                  "==",
                  "!=",
                  ">",
                  "<",
                  ">=",
                  "<=",
                  "&",
                  "|",
                  "^",
                  "~",
                  "<<",
                  ">>"
               ],
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "args"
         ],
         "title": "COp",
         "type": "object"
      },
      "FFCall": {
         "additionalProperties": false,
         "description": "(Classical) Foreign Function Call.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "const": "ffcall",
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "function": {
               "title": "Function",
               "type": "string"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "function",
            "args"
         ],
         "title": "FFCall",
         "type": "object"
      },
      "IdleMOp": {
         "additionalProperties": false,
         "description": "Idle machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Idle",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            },
            "duration": {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "title": "Duration",
               "type": "array"
            }
         },
         "required": [
            "mop",
            "args",
            "duration"
         ],
         "title": "IdleMOp",
         "type": "object"
      },
      "IfBlock": {
         "additionalProperties": false,
         "description": "If/else block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "if",
               "title": "Block",
               "type": "string"
            },
            "condition": {
               "$ref": "#/$defs/COp"
            },
            "true_branch": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/FFCall"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     },
                     {
                        "$ref": "#/$defs/IdleMOp"
                     },
                     {
                        "$ref": "#/$defs/TransportMOp"
                     },
                     {
                        "$ref": "#/$defs/SkipMOp"
                     },
                     {
                        "$ref": "#/$defs/Barrier"
                     },
                     {
                        "$ref": "#/$defs/SeqBlock"
                     },
                     {
                        "$ref": "#/$defs/QParBlock"
                     },
                     {
                        "$ref": "#/$defs/IfBlock"
                     }
                  ]
               },
               "title": "True Branch",
               "type": "array"
            },
            "false_branch": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "$ref": "#/$defs/FFCall"
                           },
                           {
                              "$ref": "#/$defs/COp"
                           },
                           {
                              "$ref": "#/$defs/MeasOp"
                           },
                           {
                              "$ref": "#/$defs/SQOp"
                           },
                           {
                              "$ref": "#/$defs/TQOp"
                           },
                           {
                              "$ref": "#/$defs/IdleMOp"
                           },
                           {
                              "$ref": "#/$defs/TransportMOp"
                           },
                           {
                              "$ref": "#/$defs/SkipMOp"
                           },
                           {
                              "$ref": "#/$defs/Barrier"
                           },
                           {
                              "$ref": "#/$defs/SeqBlock"
                           },
                           {
                              "$ref": "#/$defs/QParBlock"
                           },
                           {
                              "$ref": "#/$defs/IfBlock"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "False Branch"
            }
         },
         "required": [
            "block",
            "condition",
            "true_branch"
         ],
         "title": "IfBlock",
         "type": "object"
      },
      "MeasOp": {
         "additionalProperties": false,
         "description": "Measurement operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "const": "Measure",
               "title": "Qop",
               "type": "string"
            },
            "returns": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Returns",
               "type": "array"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "returns",
            "args"
         ],
         "title": "MeasOp",
         "type": "object"
      },
      "QParBlock": {
         "additionalProperties": false,
         "description": "Parallel quantum operations block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "qparallel",
               "title": "Block",
               "type": "string"
            },
            "ops": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     }
                  ]
               },
               "title": "Ops",
               "type": "array"
            }
         },
         "required": [
            "block",
            "ops"
         ],
         "title": "QParBlock",
         "type": "object"
      },
      "SQOp": {
         "additionalProperties": false,
         "description": "Single-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "Init",
                  "I",
                  "X",
                  "Y",
                  "Z",
                  "RX",
                  "RY",
                  "RZ",
                  "R1XY",
                  "SX",
                  "SXdg",
                  "SY",
                  "SYdg",
                  "SZ",
                  "SZdg",
                  "H",
                  "F",
                  "Fdg",
                  "T",
                  "Tdg"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "SQOp",
         "type": "object"
      },
      "SeqBlock": {
         "additionalProperties": false,
         "description": "A generic sequence block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "sequence",
               "title": "Block",
               "type": "string"
            },
            "ops": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/FFCall"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     },
                     {
                        "$ref": "#/$defs/IdleMOp"
                     },
                     {
                        "$ref": "#/$defs/TransportMOp"
                     },
                     {
                        "$ref": "#/$defs/SkipMOp"
                     },
                     {
                        "$ref": "#/$defs/Barrier"
                     },
                     {
                        "$ref": "#/$defs/SeqBlock"
                     },
                     {
                        "$ref": "#/$defs/QParBlock"
                     },
                     {
                        "$ref": "#/$defs/IfBlock"
                     }
                  ]
               },
               "title": "Ops",
               "type": "array"
            }
         },
         "required": [
            "block",
            "ops"
         ],
         "title": "SeqBlock",
         "type": "object"
      },
      "SkipMOp": {
         "additionalProperties": false,
         "description": "Skip machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Skip",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "anyOf": [
                  {
                     "items": {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Args"
            },
            "duration": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "type": "number"
                        },
                        {
                           "enum": [
                              "s",
                              "ms",
                              "us",
                              "ns"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Duration"
            }
         },
         "required": [
            "mop"
         ],
         "title": "SkipMOp",
         "type": "object"
      },
      "TQOp": {
         "additionalProperties": false,
         "description": "Two-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "CX",
                  "CY",
                  "CZ",
                  "RXX",
                  "RYY",
                  "RZZ",
                  "R2XXYYZZ",
                  "SXX",
                  "SXXdg",
                  "SYY",
                  "SYYdg",
                  "SZZ",
                  "SZZdg",
                  "SWAP"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "TQOp",
         "type": "object"
      },
      "TransportMOp": {
         "additionalProperties": false,
         "description": "Transport machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Transport",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "anyOf": [
                  {
                     "items": {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Args"
            },
            "duration": {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "title": "Duration",
               "type": "array"
            }
         },
         "required": [
            "mop",
            "duration"
         ],
         "title": "TransportMOp",
         "type": "object"
      }
   },
   "$ref": "#/$defs/IfBlock"
}

Config:
  • extra: str = forbid

Fields:
field block: Literal['if'] [Required]#
field condition: COp [Required]#
field false_branch: list[OpType | BlockType] | None = None#
field true_branch: list[OpType | BlockType] [Required]#
pydantic model phir.model.MOp#

Bases: Op, ABC

Machine operation.

Show JSON schema
{
   "title": "MOp",
   "description": "Machine operation.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "mop": {
         "title": "Mop",
         "type": "string"
      },
      "args": {
         "anyOf": [
            {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Args"
      },
      "duration": {
         "anyOf": [
            {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Duration"
      }
   },
   "additionalProperties": false,
   "required": [
      "mop"
   ]
}

Config:
  • extra: str = forbid

Fields:
field args: list[Bit] | None = None#
field duration: Duration | None = None#
field mop: str [Required]#
pydantic model phir.model.MeasOp#

Bases: Op

Measurement operation.

Show JSON schema
{
   "title": "MeasOp",
   "description": "Measurement operation.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "qop": {
         "const": "Measure",
         "title": "Qop",
         "type": "string"
      },
      "returns": {
         "items": {
            "maxItems": 2,
            "minItems": 2,
            "prefixItems": [
               {
                  "type": "string"
               },
               {
                  "minimum": 0,
                  "type": "integer"
               }
            ],
            "type": "array"
         },
         "title": "Returns",
         "type": "array"
      },
      "args": {
         "items": {
            "maxItems": 2,
            "minItems": 2,
            "prefixItems": [
               {
                  "type": "string"
               },
               {
                  "minimum": 0,
                  "type": "integer"
               }
            ],
            "type": "array"
         },
         "title": "Args",
         "type": "array"
      }
   },
   "additionalProperties": false,
   "required": [
      "qop",
      "returns",
      "args"
   ]
}

Config:
  • extra: str = forbid

Fields:
Validators:
field args: list[Bit] [Required]#
Validated by:
field qop: Literal['Measure'] [Required]#
Validated by:
field returns: list[Bit] [Required]#
Validated by:
validator check_sizes  »  all fields#

Checks whether returns and args lengths match.

pydantic model phir.model.Meta#

Bases: BaseModel, ABC

Meta instructions base class.

Show JSON schema
{
   "title": "Meta",
   "description": "Meta instructions base class.",
   "type": "object",
   "properties": {
      "meta": {
         "title": "Meta",
         "type": "string"
      }
   },
   "additionalProperties": false,
   "required": [
      "meta"
   ]
}

Config:
  • extra: str = forbid

Fields:
field meta: str [Required]#
pydantic model phir.model.Op#

Bases: BaseModel, ABC

Operation Base Class.

Show JSON schema
{
   "title": "Op",
   "description": "Operation Base Class.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field metadata: dict[str, Any] | None = None#
pydantic model phir.model.PHIRModel#

Bases: BaseModel

PHIR model object.

Show JSON schema
{
   "title": "PHIRModel",
   "description": "PHIR model object.",
   "type": "object",
   "properties": {
      "format": {
         "default": "PHIR/JSON",
         "title": "Format",
         "type": "string"
      },
      "version": {
         "default": "0.1.0",
         "title": "Version",
         "type": "string"
      },
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "ops": {
         "items": {
            "anyOf": [
               {
                  "$ref": "#/$defs/CVarDefine"
               },
               {
                  "$ref": "#/$defs/QVarDefine"
               },
               {
                  "$ref": "#/$defs/ExportVar"
               },
               {
                  "$ref": "#/$defs/FFCall"
               },
               {
                  "$ref": "#/$defs/COp"
               },
               {
                  "$ref": "#/$defs/MeasOp"
               },
               {
                  "$ref": "#/$defs/SQOp"
               },
               {
                  "$ref": "#/$defs/TQOp"
               },
               {
                  "$ref": "#/$defs/IdleMOp"
               },
               {
                  "$ref": "#/$defs/TransportMOp"
               },
               {
                  "$ref": "#/$defs/SkipMOp"
               },
               {
                  "$ref": "#/$defs/Barrier"
               },
               {
                  "$ref": "#/$defs/SeqBlock"
               },
               {
                  "$ref": "#/$defs/QParBlock"
               },
               {
                  "$ref": "#/$defs/IfBlock"
               },
               {
                  "$ref": "#/$defs/Comment"
               }
            ]
         },
         "title": "Ops",
         "type": "array"
      }
   },
   "$defs": {
      "Barrier": {
         "additionalProperties": false,
         "description": "Barrier instruction.",
         "properties": {
            "meta": {
               "const": "barrier",
               "title": "Meta",
               "type": "string"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "meta",
            "args"
         ],
         "title": "Barrier",
         "type": "object"
      },
      "COp": {
         "additionalProperties": false,
         "description": "Classical operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "enum": [
                  "=",
                  "+",
                  "-",
                  "*",
                  "/",
                  "%",
                  "==",
                  "!=",
                  ">",
                  "<",
                  ">=",
                  "<=",
                  "&",
                  "|",
                  "^",
                  "~",
                  "<<",
                  ">>"
               ],
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "args"
         ],
         "title": "COp",
         "type": "object"
      },
      "CVarDefine": {
         "additionalProperties": false,
         "description": "Defining Classical Variables.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "data": {
               "const": "cvar_define",
               "title": "Data",
               "type": "string"
            },
            "data_type": {
               "enum": [
                  "i64",
                  "i32",
                  "u64",
                  "u32"
               ],
               "title": "Data Type",
               "type": "string"
            },
            "variable": {
               "title": "Variable",
               "type": "string"
            },
            "size": {
               "anyOf": [
                  {
                     "exclusiveMinimum": 0,
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Size"
            }
         },
         "required": [
            "data",
            "data_type",
            "variable"
         ],
         "title": "CVarDefine",
         "type": "object"
      },
      "Comment": {
         "additionalProperties": false,
         "description": "Optional comment.",
         "properties": {
            "//": {
               "minLength": 3,
               "title": "//",
               "type": "string"
            }
         },
         "required": [
            "//"
         ],
         "title": "Comment",
         "type": "object"
      },
      "ExportVar": {
         "additionalProperties": false,
         "description": "Exporting Classical Variables.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "data": {
               "const": "cvar_export",
               "title": "Data",
               "type": "string"
            },
            "variables": {
               "items": {
                  "type": "string"
               },
               "title": "Variables",
               "type": "array"
            },
            "to": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "To"
            }
         },
         "required": [
            "data",
            "variables"
         ],
         "title": "ExportVar",
         "type": "object"
      },
      "FFCall": {
         "additionalProperties": false,
         "description": "(Classical) Foreign Function Call.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "const": "ffcall",
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "function": {
               "title": "Function",
               "type": "string"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "function",
            "args"
         ],
         "title": "FFCall",
         "type": "object"
      },
      "IdleMOp": {
         "additionalProperties": false,
         "description": "Idle machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Idle",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            },
            "duration": {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "title": "Duration",
               "type": "array"
            }
         },
         "required": [
            "mop",
            "args",
            "duration"
         ],
         "title": "IdleMOp",
         "type": "object"
      },
      "IfBlock": {
         "additionalProperties": false,
         "description": "If/else block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "if",
               "title": "Block",
               "type": "string"
            },
            "condition": {
               "$ref": "#/$defs/COp"
            },
            "true_branch": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/FFCall"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     },
                     {
                        "$ref": "#/$defs/IdleMOp"
                     },
                     {
                        "$ref": "#/$defs/TransportMOp"
                     },
                     {
                        "$ref": "#/$defs/SkipMOp"
                     },
                     {
                        "$ref": "#/$defs/Barrier"
                     },
                     {
                        "$ref": "#/$defs/SeqBlock"
                     },
                     {
                        "$ref": "#/$defs/QParBlock"
                     },
                     {
                        "$ref": "#/$defs/IfBlock"
                     }
                  ]
               },
               "title": "True Branch",
               "type": "array"
            },
            "false_branch": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "$ref": "#/$defs/FFCall"
                           },
                           {
                              "$ref": "#/$defs/COp"
                           },
                           {
                              "$ref": "#/$defs/MeasOp"
                           },
                           {
                              "$ref": "#/$defs/SQOp"
                           },
                           {
                              "$ref": "#/$defs/TQOp"
                           },
                           {
                              "$ref": "#/$defs/IdleMOp"
                           },
                           {
                              "$ref": "#/$defs/TransportMOp"
                           },
                           {
                              "$ref": "#/$defs/SkipMOp"
                           },
                           {
                              "$ref": "#/$defs/Barrier"
                           },
                           {
                              "$ref": "#/$defs/SeqBlock"
                           },
                           {
                              "$ref": "#/$defs/QParBlock"
                           },
                           {
                              "$ref": "#/$defs/IfBlock"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "False Branch"
            }
         },
         "required": [
            "block",
            "condition",
            "true_branch"
         ],
         "title": "IfBlock",
         "type": "object"
      },
      "MeasOp": {
         "additionalProperties": false,
         "description": "Measurement operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "const": "Measure",
               "title": "Qop",
               "type": "string"
            },
            "returns": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Returns",
               "type": "array"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "returns",
            "args"
         ],
         "title": "MeasOp",
         "type": "object"
      },
      "QParBlock": {
         "additionalProperties": false,
         "description": "Parallel quantum operations block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "qparallel",
               "title": "Block",
               "type": "string"
            },
            "ops": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     }
                  ]
               },
               "title": "Ops",
               "type": "array"
            }
         },
         "required": [
            "block",
            "ops"
         ],
         "title": "QParBlock",
         "type": "object"
      },
      "QVarDefine": {
         "additionalProperties": false,
         "description": "Defining Quantum Variables.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "data": {
               "const": "qvar_define",
               "title": "Data",
               "type": "string"
            },
            "data_type": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "qubits",
               "title": "Data Type"
            },
            "variable": {
               "title": "Variable",
               "type": "string"
            },
            "size": {
               "exclusiveMinimum": 0,
               "title": "Size",
               "type": "integer"
            }
         },
         "required": [
            "data",
            "variable",
            "size"
         ],
         "title": "QVarDefine",
         "type": "object"
      },
      "SQOp": {
         "additionalProperties": false,
         "description": "Single-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "Init",
                  "I",
                  "X",
                  "Y",
                  "Z",
                  "RX",
                  "RY",
                  "RZ",
                  "R1XY",
                  "SX",
                  "SXdg",
                  "SY",
                  "SYdg",
                  "SZ",
                  "SZdg",
                  "H",
                  "F",
                  "Fdg",
                  "T",
                  "Tdg"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "SQOp",
         "type": "object"
      },
      "SeqBlock": {
         "additionalProperties": false,
         "description": "A generic sequence block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "sequence",
               "title": "Block",
               "type": "string"
            },
            "ops": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/FFCall"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     },
                     {
                        "$ref": "#/$defs/IdleMOp"
                     },
                     {
                        "$ref": "#/$defs/TransportMOp"
                     },
                     {
                        "$ref": "#/$defs/SkipMOp"
                     },
                     {
                        "$ref": "#/$defs/Barrier"
                     },
                     {
                        "$ref": "#/$defs/SeqBlock"
                     },
                     {
                        "$ref": "#/$defs/QParBlock"
                     },
                     {
                        "$ref": "#/$defs/IfBlock"
                     }
                  ]
               },
               "title": "Ops",
               "type": "array"
            }
         },
         "required": [
            "block",
            "ops"
         ],
         "title": "SeqBlock",
         "type": "object"
      },
      "SkipMOp": {
         "additionalProperties": false,
         "description": "Skip machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Skip",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "anyOf": [
                  {
                     "items": {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Args"
            },
            "duration": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "type": "number"
                        },
                        {
                           "enum": [
                              "s",
                              "ms",
                              "us",
                              "ns"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Duration"
            }
         },
         "required": [
            "mop"
         ],
         "title": "SkipMOp",
         "type": "object"
      },
      "TQOp": {
         "additionalProperties": false,
         "description": "Two-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "CX",
                  "CY",
                  "CZ",
                  "RXX",
                  "RYY",
                  "RZZ",
                  "R2XXYYZZ",
                  "SXX",
                  "SXXdg",
                  "SYY",
                  "SYYdg",
                  "SZZ",
                  "SZZdg",
                  "SWAP"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "TQOp",
         "type": "object"
      },
      "TransportMOp": {
         "additionalProperties": false,
         "description": "Transport machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Transport",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "anyOf": [
                  {
                     "items": {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Args"
            },
            "duration": {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "title": "Duration",
               "type": "array"
            }
         },
         "required": [
            "mop",
            "duration"
         ],
         "title": "TransportMOp",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "ops"
   ]
}

Config:
  • extra: str = forbid

Fields:
field format_: str = 'PHIR/JSON' (alias 'format')#
field metadata: dict[str, Any] | None = None#
field ops: list[Cmd] [Required]#
field version: str = '0.1.0'#
pydantic model phir.model.QParBlock#

Bases: Block

Parallel quantum operations block.

Show JSON schema
{
   "title": "QParBlock",
   "description": "Parallel quantum operations block.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "block": {
         "const": "qparallel",
         "title": "Block",
         "type": "string"
      },
      "ops": {
         "items": {
            "anyOf": [
               {
                  "$ref": "#/$defs/MeasOp"
               },
               {
                  "$ref": "#/$defs/SQOp"
               },
               {
                  "$ref": "#/$defs/TQOp"
               }
            ]
         },
         "title": "Ops",
         "type": "array"
      }
   },
   "$defs": {
      "MeasOp": {
         "additionalProperties": false,
         "description": "Measurement operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "const": "Measure",
               "title": "Qop",
               "type": "string"
            },
            "returns": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Returns",
               "type": "array"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "returns",
            "args"
         ],
         "title": "MeasOp",
         "type": "object"
      },
      "SQOp": {
         "additionalProperties": false,
         "description": "Single-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "Init",
                  "I",
                  "X",
                  "Y",
                  "Z",
                  "RX",
                  "RY",
                  "RZ",
                  "R1XY",
                  "SX",
                  "SXdg",
                  "SY",
                  "SYdg",
                  "SZ",
                  "SZdg",
                  "H",
                  "F",
                  "Fdg",
                  "T",
                  "Tdg"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "SQOp",
         "type": "object"
      },
      "TQOp": {
         "additionalProperties": false,
         "description": "Two-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "CX",
                  "CY",
                  "CZ",
                  "RXX",
                  "RYY",
                  "RZZ",
                  "R2XXYYZZ",
                  "SXX",
                  "SXXdg",
                  "SYY",
                  "SYYdg",
                  "SZZ",
                  "SZZdg",
                  "SWAP"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "TQOp",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "block",
      "ops"
   ]
}

Config:
  • extra: str = forbid

Fields:
field block: Literal['qparallel'] [Required]#
field ops: list[QOp] [Required]#
pydantic model phir.model.QVarDefine#

Bases: Data

Defining Quantum Variables.

Show JSON schema
{
   "title": "QVarDefine",
   "description": "Defining Quantum Variables.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "data": {
         "const": "qvar_define",
         "title": "Data",
         "type": "string"
      },
      "data_type": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": "qubits",
         "title": "Data Type"
      },
      "variable": {
         "title": "Variable",
         "type": "string"
      },
      "size": {
         "exclusiveMinimum": 0,
         "title": "Size",
         "type": "integer"
      }
   },
   "additionalProperties": false,
   "required": [
      "data",
      "variable",
      "size"
   ]
}

Config:
  • extra: str = forbid

Fields:
field data: Literal['qvar_define'] [Required]#
field data_type: str | None = 'qubits'#
field size: PositiveInt [Required]#
Constraints:
  • strict = True

  • gt = 0

field variable: Sym [Required]#
pydantic model phir.model.SQOp#

Bases: Op

Single-qubit Quantum operation.

Show JSON schema
{
   "title": "SQOp",
   "description": "Single-qubit Quantum operation.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "qop": {
         "enum": [
            "Init",
            "I",
            "X",
            "Y",
            "Z",
            "RX",
            "RY",
            "RZ",
            "R1XY",
            "SX",
            "SXdg",
            "SY",
            "SYdg",
            "SZ",
            "SZdg",
            "H",
            "F",
            "Fdg",
            "T",
            "Tdg"
         ],
         "title": "Qop",
         "type": "string"
      },
      "angles": {
         "anyOf": [
            {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "items": {
                        "type": "number"
                     },
                     "type": "array"
                  },
                  {
                     "enum": [
                        "rad",
                        "pi"
                     ],
                     "type": "string"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Angles"
      },
      "args": {
         "items": {
            "maxItems": 2,
            "minItems": 2,
            "prefixItems": [
               {
                  "type": "string"
               },
               {
                  "minimum": 0,
                  "type": "integer"
               }
            ],
            "type": "array"
         },
         "title": "Args",
         "type": "array"
      }
   },
   "additionalProperties": false,
   "required": [
      "qop",
      "args"
   ]
}

Config:
  • extra: str = forbid

Fields:
Validators:
field angles: tuple[list[StrictFloat], Literal['rad', 'pi']] | None = None#
Validated by:
field args: list[Bit] [Required]#
Validated by:
field qop: Literal['Init', 'I', 'X', 'Y', 'Z', 'RX', 'RY', 'RZ', 'R1XY', 'SX', 'SXdg', 'SY', 'SYdg', 'SZ', 'SZdg', 'H', 'F', 'Fdg', 'T', 'Tdg'] [Required]#
Validated by:
validator check_angles  »  all fields#

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

pydantic model phir.model.SeqBlock#

Bases: Block

A generic sequence block.

Show JSON schema
{
   "$defs": {
      "Barrier": {
         "additionalProperties": false,
         "description": "Barrier instruction.",
         "properties": {
            "meta": {
               "const": "barrier",
               "title": "Meta",
               "type": "string"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "meta",
            "args"
         ],
         "title": "Barrier",
         "type": "object"
      },
      "COp": {
         "additionalProperties": false,
         "description": "Classical operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "enum": [
                  "=",
                  "+",
                  "-",
                  "*",
                  "/",
                  "%",
                  "==",
                  "!=",
                  ">",
                  "<",
                  ">=",
                  "<=",
                  "&",
                  "|",
                  "^",
                  "~",
                  "<<",
                  ">>"
               ],
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "args"
         ],
         "title": "COp",
         "type": "object"
      },
      "FFCall": {
         "additionalProperties": false,
         "description": "(Classical) Foreign Function Call.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "cop": {
               "const": "ffcall",
               "title": "Cop",
               "type": "string"
            },
            "returns": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "type": "string"
                           },
                           {
                              "maxItems": 2,
                              "minItems": 2,
                              "prefixItems": [
                                 {
                                    "type": "string"
                                 },
                                 {
                                    "minimum": 0,
                                    "type": "integer"
                                 }
                              ],
                              "type": "array"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Returns"
            },
            "function": {
               "title": "Function",
               "type": "string"
            },
            "args": {
               "items": {
                  "anyOf": [
                     {
                        "type": "integer"
                     },
                     {
                        "type": "string"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ]
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "cop",
            "function",
            "args"
         ],
         "title": "FFCall",
         "type": "object"
      },
      "IdleMOp": {
         "additionalProperties": false,
         "description": "Idle machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Idle",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            },
            "duration": {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "title": "Duration",
               "type": "array"
            }
         },
         "required": [
            "mop",
            "args",
            "duration"
         ],
         "title": "IdleMOp",
         "type": "object"
      },
      "IfBlock": {
         "additionalProperties": false,
         "description": "If/else block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "if",
               "title": "Block",
               "type": "string"
            },
            "condition": {
               "$ref": "#/$defs/COp"
            },
            "true_branch": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/FFCall"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     },
                     {
                        "$ref": "#/$defs/IdleMOp"
                     },
                     {
                        "$ref": "#/$defs/TransportMOp"
                     },
                     {
                        "$ref": "#/$defs/SkipMOp"
                     },
                     {
                        "$ref": "#/$defs/Barrier"
                     },
                     {
                        "$ref": "#/$defs/SeqBlock"
                     },
                     {
                        "$ref": "#/$defs/QParBlock"
                     },
                     {
                        "$ref": "#/$defs/IfBlock"
                     }
                  ]
               },
               "title": "True Branch",
               "type": "array"
            },
            "false_branch": {
               "anyOf": [
                  {
                     "items": {
                        "anyOf": [
                           {
                              "$ref": "#/$defs/FFCall"
                           },
                           {
                              "$ref": "#/$defs/COp"
                           },
                           {
                              "$ref": "#/$defs/MeasOp"
                           },
                           {
                              "$ref": "#/$defs/SQOp"
                           },
                           {
                              "$ref": "#/$defs/TQOp"
                           },
                           {
                              "$ref": "#/$defs/IdleMOp"
                           },
                           {
                              "$ref": "#/$defs/TransportMOp"
                           },
                           {
                              "$ref": "#/$defs/SkipMOp"
                           },
                           {
                              "$ref": "#/$defs/Barrier"
                           },
                           {
                              "$ref": "#/$defs/SeqBlock"
                           },
                           {
                              "$ref": "#/$defs/QParBlock"
                           },
                           {
                              "$ref": "#/$defs/IfBlock"
                           }
                        ]
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "False Branch"
            }
         },
         "required": [
            "block",
            "condition",
            "true_branch"
         ],
         "title": "IfBlock",
         "type": "object"
      },
      "MeasOp": {
         "additionalProperties": false,
         "description": "Measurement operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "const": "Measure",
               "title": "Qop",
               "type": "string"
            },
            "returns": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Returns",
               "type": "array"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "returns",
            "args"
         ],
         "title": "MeasOp",
         "type": "object"
      },
      "QParBlock": {
         "additionalProperties": false,
         "description": "Parallel quantum operations block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "qparallel",
               "title": "Block",
               "type": "string"
            },
            "ops": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     }
                  ]
               },
               "title": "Ops",
               "type": "array"
            }
         },
         "required": [
            "block",
            "ops"
         ],
         "title": "QParBlock",
         "type": "object"
      },
      "SQOp": {
         "additionalProperties": false,
         "description": "Single-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "Init",
                  "I",
                  "X",
                  "Y",
                  "Z",
                  "RX",
                  "RY",
                  "RZ",
                  "R1XY",
                  "SX",
                  "SXdg",
                  "SY",
                  "SYdg",
                  "SZ",
                  "SZdg",
                  "H",
                  "F",
                  "Fdg",
                  "T",
                  "Tdg"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "SQOp",
         "type": "object"
      },
      "SeqBlock": {
         "additionalProperties": false,
         "description": "A generic sequence block.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "block": {
               "const": "sequence",
               "title": "Block",
               "type": "string"
            },
            "ops": {
               "items": {
                  "anyOf": [
                     {
                        "$ref": "#/$defs/FFCall"
                     },
                     {
                        "$ref": "#/$defs/COp"
                     },
                     {
                        "$ref": "#/$defs/MeasOp"
                     },
                     {
                        "$ref": "#/$defs/SQOp"
                     },
                     {
                        "$ref": "#/$defs/TQOp"
                     },
                     {
                        "$ref": "#/$defs/IdleMOp"
                     },
                     {
                        "$ref": "#/$defs/TransportMOp"
                     },
                     {
                        "$ref": "#/$defs/SkipMOp"
                     },
                     {
                        "$ref": "#/$defs/Barrier"
                     },
                     {
                        "$ref": "#/$defs/SeqBlock"
                     },
                     {
                        "$ref": "#/$defs/QParBlock"
                     },
                     {
                        "$ref": "#/$defs/IfBlock"
                     }
                  ]
               },
               "title": "Ops",
               "type": "array"
            }
         },
         "required": [
            "block",
            "ops"
         ],
         "title": "SeqBlock",
         "type": "object"
      },
      "SkipMOp": {
         "additionalProperties": false,
         "description": "Skip machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Skip",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "anyOf": [
                  {
                     "items": {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Args"
            },
            "duration": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "type": "number"
                        },
                        {
                           "enum": [
                              "s",
                              "ms",
                              "us",
                              "ns"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Duration"
            }
         },
         "required": [
            "mop"
         ],
         "title": "SkipMOp",
         "type": "object"
      },
      "TQOp": {
         "additionalProperties": false,
         "description": "Two-qubit Quantum operation.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "qop": {
               "enum": [
                  "CX",
                  "CY",
                  "CZ",
                  "RXX",
                  "RYY",
                  "RZZ",
                  "R2XXYYZZ",
                  "SXX",
                  "SXXdg",
                  "SYY",
                  "SYYdg",
                  "SZZ",
                  "SZZdg",
                  "SWAP"
               ],
               "title": "Qop",
               "type": "string"
            },
            "angles": {
               "anyOf": [
                  {
                     "maxItems": 2,
                     "minItems": 2,
                     "prefixItems": [
                        {
                           "items": {
                              "type": "number"
                           },
                           "type": "array"
                        },
                        {
                           "enum": [
                              "rad",
                              "pi"
                           ],
                           "type": "string"
                        }
                     ],
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Angles"
            },
            "args": {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     }
                  ],
                  "type": "array"
               },
               "title": "Args",
               "type": "array"
            }
         },
         "required": [
            "qop",
            "args"
         ],
         "title": "TQOp",
         "type": "object"
      },
      "TransportMOp": {
         "additionalProperties": false,
         "description": "Transport machine op.",
         "properties": {
            "metadata": {
               "anyOf": [
                  {
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Metadata"
            },
            "mop": {
               "const": "Transport",
               "title": "Mop",
               "type": "string"
            },
            "args": {
               "anyOf": [
                  {
                     "items": {
                        "maxItems": 2,
                        "minItems": 2,
                        "prefixItems": [
                           {
                              "type": "string"
                           },
                           {
                              "minimum": 0,
                              "type": "integer"
                           }
                        ],
                        "type": "array"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Args"
            },
            "duration": {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "title": "Duration",
               "type": "array"
            }
         },
         "required": [
            "mop",
            "duration"
         ],
         "title": "TransportMOp",
         "type": "object"
      }
   },
   "$ref": "#/$defs/SeqBlock"
}

Config:
  • extra: str = forbid

Fields:
field block: Literal['sequence'] [Required]#
field ops: list[OpType | BlockType] [Required]#
pydantic model phir.model.SkipMOp#

Bases: MOp

Skip machine op.

Show JSON schema
{
   "title": "SkipMOp",
   "description": "Skip machine op.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "mop": {
         "const": "Skip",
         "title": "Mop",
         "type": "string"
      },
      "args": {
         "anyOf": [
            {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Args"
      },
      "duration": {
         "anyOf": [
            {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "type": "number"
                  },
                  {
                     "enum": [
                        "s",
                        "ms",
                        "us",
                        "ns"
                     ],
                     "type": "string"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Duration"
      }
   },
   "additionalProperties": false,
   "required": [
      "mop"
   ]
}

Config:
  • extra: str = forbid

Fields:
field mop: Literal['Skip'] [Required]#
pydantic model phir.model.TQOp#

Bases: Op

Two-qubit Quantum operation.

Show JSON schema
{
   "title": "TQOp",
   "description": "Two-qubit Quantum operation.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "qop": {
         "enum": [
            "CX",
            "CY",
            "CZ",
            "RXX",
            "RYY",
            "RZZ",
            "R2XXYYZZ",
            "SXX",
            "SXXdg",
            "SYY",
            "SYYdg",
            "SZZ",
            "SZZdg",
            "SWAP"
         ],
         "title": "Qop",
         "type": "string"
      },
      "angles": {
         "anyOf": [
            {
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "items": {
                        "type": "number"
                     },
                     "type": "array"
                  },
                  {
                     "enum": [
                        "rad",
                        "pi"
                     ],
                     "type": "string"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Angles"
      },
      "args": {
         "items": {
            "maxItems": 2,
            "minItems": 2,
            "prefixItems": [
               {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               }
            ],
            "type": "array"
         },
         "title": "Args",
         "type": "array"
      }
   },
   "additionalProperties": false,
   "required": [
      "qop",
      "args"
   ]
}

Config:
  • extra: str = forbid

Fields:
Validators:
field angles: tuple[list[StrictFloat], Literal['rad', 'pi']] | None = None#
Validated by:
field args: list[tuple[Bit, Bit]] [Required]#
Validated by:
field qop: Literal['CX', 'CY', 'CZ', 'RXX', 'RYY', 'RZZ', 'R2XXYYZZ', 'SXX', 'SXXdg', 'SYY', 'SYYdg', 'SZZ', 'SZZdg', 'SWAP'] [Required]#
Validated by:
validator check_angles  »  all fields#

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

pydantic model phir.model.TransportMOp#

Bases: MOp

Transport machine op.

Show JSON schema
{
   "title": "TransportMOp",
   "description": "Transport machine op.",
   "type": "object",
   "properties": {
      "metadata": {
         "anyOf": [
            {
               "type": "object"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Metadata"
      },
      "mop": {
         "const": "Transport",
         "title": "Mop",
         "type": "string"
      },
      "args": {
         "anyOf": [
            {
               "items": {
                  "maxItems": 2,
                  "minItems": 2,
                  "prefixItems": [
                     {
                        "type": "string"
                     },
                     {
                        "minimum": 0,
                        "type": "integer"
                     }
                  ],
                  "type": "array"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Args"
      },
      "duration": {
         "maxItems": 2,
         "minItems": 2,
         "prefixItems": [
            {
               "type": "number"
            },
            {
               "enum": [
                  "s",
                  "ms",
                  "us",
                  "ns"
               ],
               "type": "string"
            }
         ],
         "title": "Duration",
         "type": "array"
      }
   },
   "additionalProperties": false,
   "required": [
      "mop",
      "duration"
   ]
}

Config:
  • extra: str = forbid

Fields:
field duration: Duration [Required]#
field mop: Literal['Transport'] [Required]#

Module contents#

Init file for phir.