"color_488_d3", and that slug is
how a code is referred to when compiling circuits to it with
qec_compile and when running circuits with
qec_run.
The library can be browsed from the SDK in two ways:
haiqu.list_qec_codeslists the codes page by page, optionally filtered by family, code type, completeness tier, number of physical qubits and code distance. Itsqargument searches the codes by the beginning of their name or slug.haiqu.get_qec_codefetches a single code by its slug.
.qecx file and are shown in the code library on the
Haiqu dashboard.
Completeness tiers
Every code belongs to one of three completeness tiers, given by itscompleteness field. The
tier says how much of the code is available in the library:
To list only the codes that can be compiled to, pass
completeness=["full"] to
haiqu.list_qec_codes.
Current limitations
- Downloading
.qecxfiles withhaiqu.download_qec_codeis not available yet: the call raisesrequests.HTTPErrorfor every code that has a file.
Haiqu.list_qec_codes(family=None, code_type=None, completeness=None, n=None, d=None, q=None, page=1, page_size=20)
List the codes of the Haiqu QEC code library, optionally filtered. The results come in pages. Each filter keeps the codes that match any of its values, and the filters given together keep only the codes that match all of them. The values offamily, code_type and completeness are matched exactly, including case, so an
unknown value matches no codes rather than raising an error.
- Parameters:
- family (list *[*str ] | None) — Keep the codes of these code families, given by their slugs
(the
familyfield of a code), e.g.["color"]. Defaults toNone, no family filter. - code_type (list *[*str ] | None) — Keep the codes of these code types:
"css","stabilizer","subsystem_css","subsystem_stabilizer". Defaults toNone, no code type filter. - completeness (list *[*str ] | None) — Keep the codes in these completeness tiers:
"full","partial","metadata_only", as explained in Completeness tiers. Defaults toNone, no completeness filter. - n (list *[*int ] | None) — Keep the codes with one of these numbers of physical qubits.
Defaults to
None, no filter on the number of physical qubits. - d (list *[*int ] | None) — Keep the codes with one of these code distances. A code whose X
and Z distances differ matches no value. Defaults to
None, no distance filter. - q (str | None) — Keep the codes whose name or slug starts with this text, ignoring
case. Defaults to
None, no search. - page (int) — Number of the page to return, starting at 1. A page past the last one has no items. Defaults to 1.
- page_size (int) — Maximum number of codes per page. Defaults to 20.
- family (list *[*str ] | None) — Keep the codes of these code families, given by their slugs
(the
- Returns: The requested page of matching codes, with the total number of matching codes.
- Return type: QECCodeListResponseModel
- Raises:
requests.HTTPError — If the request fails, for example because a value of
nordis not an integer. In a notebook, an error message is shown andNoneis returned instead.
Examples
Haiqu.get_qec_code(slug)
Get a code of the Haiqu QEC code library by its slug.- Parameters:
slug (str) — Slug of the code, as listed by
haiqu.list_qec_codes, e.g."color_488_d3". - Returns: The code.
- Return type: QECCodeModel
- Raises:
- ValueError — If the library has no code with this slug.
- requests.HTTPError — If the request fails for another reason. In a notebook, an error
message is shown and
Noneis returned instead.
Examples
Haiqu.download_qec_code(slug)
Download the.qecx file of a code of the Haiqu QEC code library.
A .qecx file holds the definition of a code together with the circuits that implement
its operations, as far as these are available. Codes in the "metadata_only" tier have
no file (see Completeness tiers).
- Parameters:
slug (str) — Slug of the code, as listed by
haiqu.list_qec_codes, e.g."color_488_d3". - Returns:
The content of the code’s
.qecxfile. Currently, downloading is not available, and the call raisesrequests.HTTPErrorfor every code that has a file (see Current limitations). - Return type: bytes
- Raises:
- ValueError — If the library has no code with this slug, or the code is in the
"metadata_only"tier and so has no file. - requests.HTTPError — If the request fails for another reason.
- ValueError — If the library has no code with this slug, or the code is in the
class haiqu.sdk.schemas.QECCodeModel
A code of the Haiqu QEC code library, as returned byhaiqu.get_qec_code and haiqu.list_qec_codes.
A code in the "full" tier can be passed to haiqu.qec_compile and haiqu.qec_run
either by its slug or as this model. Which logical operations a code supports and how they are
implemented is defined by the code’s .qecx file and shown in the code library on the
Haiqu dashboard.
slug
Unique identifier of the code, used to refer to it inhaiqu.get_qec_code,
haiqu.qec_compile and haiqu.qec_run.
- Type: str
name
Display name of the code.- Type: str
family
Slug of the code family, as used by thefamily filter of
haiqu.list_qec_codes.
- Type: str
sub_family
Slug of the sub-family within the code family,"" when the code has
none.
- Type: str
code_type
Type of the code:"css", "stabilizer", "subsystem_css" or
"subsystem_stabilizer".
- Type: str
n
Number of physical qubits,None when not available.
- Type: int | None
k
Number of logical qubits,None when not available.
- Type: int | None
d
Code distance. For a code whose X and Z distances differ, a dict with the keys"X" and "Z". None when not available.
- Type: int | dict | None
completeness
Completeness tier of the code:"full", "partial" or
"metadata_only", as explained in
Completeness tiers.
- Type: str
description
Short description of the code,None when not available.
- Type: str | None
stabilizers
Stabilizer generators of the code,None when not available.
- Type: dict | None
logical_operators
Logical operators of the code,None when not available.
- Type: dict | None
references
Literature references for the code,None when not available.
Each reference has the optional fields key, title, authors, year,
doi, arxiv, url and note.
- Type: list | None
class haiqu.sdk.schemas.QECCodeListResponseModel
One page of codes of the Haiqu QEC code library, as returned byhaiqu.list_qec_codes.
items
The codes on this page, seeQECCodeModel.
- Type: list[QECCodeModel]
total
Total number of codes matching the filters, across all pages.- Type: int
page
Number of this page, as requested.- Type: int
page_size
Maximum number of codes per page, as requested.- Type: int