Overview¶
Parsing, compiling, and printing QVR source, with the public entry
points: load and loads compile source to a Program, parse
produces the AST that Compiler lowers and module_to_source prints,
and the QIEC lowering checks a module against the kernel. The package
re-exports the public names of its modules; the AST node classes live
in quivers.dsl.ast_nodes.
dsl
¶
quivers DSL: parse .qvr files into trainable PyTorch models.
The DSL provides a declarative syntax for specifying V-enriched
categorical morphism networks that compile to quivers.Program
instances (nn.Module subclasses). Parsing is delegated to panproto
via the qvr tree-sitter grammar; the AST is a tree of
quivers.dsl.ast_nodes didactic Models.
Morphism roles need not be declared: a morphism drawn with sample
compiles as latent, one drawn with observe as observed, and any
other morphism as a kernel. An explicit [role=...] option always
wins over inference.
Quick start
::
from quivers.dsl import load, loads
program = loads('''
object Resp : FinSet 8
morphism bias : Resp -> Real 1 ~ Normal(0.0, 5.0)
program m : Resp -> Resp
sample b <- bias
observe y : Resp <- Normal(b, 1.0)
return y
export m
''')
program = load("model.qvr")
optimizer = torch.optim.Adam(program.parameters())
DISTRIBUTION_FAMILIES
module-attribute
¶
DISTRIBUTION_FAMILIES: frozenset[str] = frozenset((*_FAMILY_PARAMETERS, *FAMILY_ALIASES))
Every distribution-family name accepted in QVR source.
Highlighters consume this set so their surface vocabulary follows the same schemas used by validation and lowering.
FAMILY_ALIASES
module-attribute
¶
Surface family names that resolve to another family's registry record.
A key is a name a source may write; its value is the family whose specification builds the distribution.
QVR_DEDUCTION_PROTOCOL
module-attribute
¶
QVR_DEDUCTION_PROTOCOL: Protocol = panproto.define_protocol({'name': 'qvr_deduction', 'schema_theory': 'ThBratSchema', 'instance_theory': 'ThBratInstance', 'edge_rules': _DEDUCTION_EDGE_RULES, 'obj_kinds': _DEDUCTION_OBJECT_KINDS, 'constraint_sorts': _DEDUCTION_CONSTRAINT_SORTS})
Panproto protocol for a weighted deductive system.
Vertex kinds:
* deduction_system: the top-level declaration.
* deduction_atom: an atom of the item algebra.
* deduction_rule: a named sequent-style inference rule.
* deduction_premise: one premise pattern of a rule.
* deduction_conclusion: a rule's conclusion pattern.
Edges:
* decl: system :math:\to rule.
* atom: system :math:\to atom.
* premise: rule :math:\to premise.
* conclusion: rule :math:\to conclusion.
Constraint sorts carry the system's semiring, start, depth, and
each pattern's textual form. Schema morphisms over this protocol
correspond to specializations of deduction systems
(e.g., :math:\mathsf{CCG} \subset \mathsf{Lambek} \subset \mathsf{MultimodalLambek}).
QVR_PROGRAM_PROTOCOL
module-attribute
¶
QVR_PROGRAM_PROTOCOL: Protocol = panproto.define_protocol({'name': 'qvr_program', 'schema_theory': 'ThBratSchema', 'instance_theory': 'ThBratInstance', 'edge_rules': _EDGE_RULES, 'obj_kinds': _OBJECT_KINDS, 'constraint_sorts': _CONSTRAINT_SORTS})
Panproto protocol for a compiled QVR program.
extract_program_schema writes schemas in this protocol. The vertex
kinds, edge rules, and constraint sorts are the ones the module
docstring lists.
QIEC_STATEMENT_TYPES
module-attribute
¶
QIEC_STATEMENT_TYPES = (surface.QiecIndexDecl, surface.QiecFamilyDecl, surface.QiecEffectDecl, surface.QiecEffectInstanceDecl, surface.QiecHandlerDecl, surface.QiecComputationDecl)
The declaration classes that make up the QIEC surface of a module.
qiec_projection keeps these statements and non_qiec_projection
drops them, so the tuple fixes where the two routes divide a module.
QVR_SOURCE_VERSION
module-attribute
¶
The source protocol a QvrQiecLowerer route accepts.
lower_qvr_to_qiec checks its source_version argument against this
identifier, which names the QVR surface the elaboration reads.
Module
didactic-model
¶
Module(*, statements: tuple[Statement, ...] = field(default_factory=tuple))
Bases: Model
A complete .qvr program (sequence of statements).
Compiler
¶
Compiler(module: Module, *, module_name: str | None = None, file_path: str = '<source>', lower_qiec: bool = True)
Bases: _DeclarationsMixin, _ProgramsMixin, _StructuralMixin, _DeductionsMixin, _ResolutionMixin, _ExpressionsMixin
Compile a quivers DSL AST into a Program.
The compiler maintains three environments:
- objects: name -> SetObject (discrete finite sets)
- spaces: name -> ContinuousSpace
- morphisms: name -> Morphism or ContinuousMorphism (any morphism-like)
It processes statements in order and compiles the output expression into a Program wrapping the morphism DAG.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed AST.
TYPE:
|
lower_qiec
|
Whether to lower the checked QIEC projection. Tooling sets this to
TYPE:
|
Source code in src/quivers/dsl/compiler/core.py
losses
property
¶
Declared loss heads (loss NAME : ... [on=...]).
Keyed by entry name; values are the registered :class:LossEntry
records. Empty when no loss decl appears in the module.
bundles
property
¶
Declared bundle aliases (bundle NAME = R1 | R2 | ...).
contractions
property
¶
Declared tensor-network contractions
(contraction NAME : ... [wiring=...]).
transformations
property
¶
User-declared transformation constructors / singletons.
qiec_module
property
¶
qiec_module: QiecModule | None
The checked QIEC module, or None when the source has no QIEC surface.
| RETURNS | DESCRIPTION |
|---|---|
QiecModule | None
|
The module, lowered on first access. |
| RAISES | DESCRIPTION |
|---|---|
QiecDiagnosticError
|
If the source's QIEC surface fails to lower, other than by a program gap, which the module records instead. |
entry_points
¶
entry_points() -> tuple[EntryPoint, ...]
The executable entry points of the checked module.
| RETURNS | DESCRIPTION |
|---|---|
tuple[EntryPoint, ...]
|
Every |
Source code in src/quivers/dsl/compiler/core.py
entry
¶
entry(name: str) -> EntryPoint
One entry point of the checked module, by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The entry's source name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EntryPoint
|
The entry. |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
With code |
Source code in src/quivers/dsl/compiler/core.py
compile
¶
compile() -> Program
Compile the module into a trainable Program.
| RETURNS | DESCRIPTION |
|---|---|
Program
|
The compiled nn.Module wrapping the morphism DAG. |
| RAISES | DESCRIPTION |
|---|---|
CompileError
|
On semantic errors (undefined names, type mismatches, etc.). |
Source code in src/quivers/dsl/compiler/core.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
compile_env
¶
Compile all statements and return the full environment.
Useful for inspection without requiring an output declaration.
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Combined environment of every declared atom: the active algebra, objects, spaces, morphisms, rules, programs (parametric templates), deductions, signatures, encoders, decoders, losses, bundles, contractions, transformations. |
Source code in src/quivers/dsl/compiler/core.py
CompileError
¶
Bases: Exception
Raised when the compiler encounters a semantic error.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
Error description.
TYPE:
|
line
|
Source line number (0 if unknown).
TYPE:
|
col
|
Source column number (0 if unknown).
TYPE:
|
Source code in src/quivers/dsl/compiler/_prelude.py
Violation
didactic-model
¶
Bases: Model
One constraint-solver finding.
Every finding check_constraints reports is an error. Compiler
diagnostics that should surface in qvr check output without
failing the compile set severity to "warning".
| PARAMETER | DESCRIPTION |
|---|---|
code
|
The stable diagnostic code.
TYPE:
|
message
|
What is wrong.
TYPE:
|
line
|
The one-based source line.
TYPE:
|
col
|
The source column.
TYPE:
|
severity
|
TYPE:
|
EmitError
¶
Bases: Exception
Raised when an AST value has no valid .qvr surface form.
ParseError
¶
Bases: Exception
Raised when .qvr source fails to parse or wrap into AST nodes.
parse and parse_file raise it with a message that starts with
the file path and locates the first syntax error.
QvrLexer
¶
Bases: Lexer
Pygments lexer for .qvr (quivers DSL) files.
The lexer is a thin walker over the in-tree tree-sitter parse; the grammar is the single source of truth. There is no regex approximation: when the shared library can't be loaded, the lexer raises a typed exception so the failure is visible at the rendering site rather than silently emitting a degraded highlight.
get_tokens_unprocessed
¶
Yield (index, token_type, text) tuples for text.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
tuple[int, _TokenType, str]
|
The character offset, Pygments token type, and text of each leaf of the parse and of the whitespace between leaves. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the in-tree tree-sitter parser library cannot be loaded. |
Source code in src/quivers/dsl/pygments_lexer.py
QiecDiagnosticError
¶
QiecDiagnosticError(message: str, *, code: str, file: str, line: int = 0, column: int = 0, program: str | None = None)
Bases: ValueError
A source-located, stable-code diagnostic from QIEC elaboration.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What was rejected.
TYPE:
|
code
|
The stable diagnostic code.
TYPE:
|
file
|
The file the source was read from.
TYPE:
|
line
|
The one-based line, or zero when unknown.
TYPE:
|
column
|
The zero-based column.
TYPE:
|
program
|
The program whose elaboration raised the diagnostic, when it was
raised inside a program body;
TYPE:
|
Source code in src/quivers/dsl/qiec_diagnostics.py
CheckedQvrQiec
dataclass
¶
CheckedQvrQiec(module: QiecModule)
The checked result passed between Didactic's ordered stages.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The kernel module the stages produced.
TYPE:
|
QvrQiecLowerer
¶
Quivers-owned implementation of Didactic's extension-lowering protocol.
check
¶
check(source: QvrQiecSource) -> CheckedQvrQiec
Elaborate a source module and recheck the result.
The recheck is deliberate rather than redundant: it rebuilds a registry from the lowered module alone, so a bug in elaboration surfaces here instead of reaching a backend.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The QIEC projection, its module name, and its file path.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedQvrQiec
|
The checked module. |
| RAISES | DESCRIPTION |
|---|---|
QiecDiagnosticError
|
If elaboration rejects the source, carrying a stable code and a source position. |
KernelError
|
If the lowered module fails its independent recheck. |
Source code in src/quivers/dsl/qiec_lowering.py
lower
¶
lower(checked: CheckedQvrQiec) -> QiecModule
Return the checked module.
Checking and lowering are one step here, because the elaborator produces the kernel module directly, so this unwraps rather than transforms.
| PARAMETER | DESCRIPTION |
|---|---|
checked
|
The result of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecModule
|
The lowered module. |
Source code in src/quivers/dsl/qiec_lowering.py
validate
¶
validate(target: QiecModule) -> None
Recheck a module and confirm it survives serialization.
| PARAMETER | DESCRIPTION |
|---|---|
target
|
The module to validate.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
KernelError
|
If the module fails its recheck, or if a dump and load round trip does not return an equal module. The second is checked because identities downstream are content addressed: a module that changed under serialization would hash differently on the other side of the boundary. |
Source code in src/quivers/dsl/qiec_lowering.py
QvrQiecSource
dataclass
¶
QvrQiecSource(syntax: Module, module_name: str, file_path: str = '<source>', elaborate_programs: bool = True)
A parsed QVR projection plus the identity absent from the AST root.
| PARAMETER | DESCRIPTION |
|---|---|
syntax
|
The projected module.
TYPE:
|
module_name
|
The name every stable identity derives from.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
elaborate_programs
|
Whether
TYPE:
|
check_constraints
¶
Return every well-formedness violation in module.
Walks the statements in source order, building up the symbol tables (residuated universes, enum sets, free monoids, declared rule / schema / bundle names) incrementally so that out-of-order references are flagged.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Violation]
|
The findings in source order, empty for a well-formed module. |
Source code in src/quivers/dsl/constraints.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
module_to_source
¶
module_to_source(module: Module) -> str
Serialize a Module AST to canonical .qvr source.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The module to print.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The canonical source, ending in a single newline. |
| RAISES | DESCRIPTION |
|---|---|
EmitError
|
If a node in |
Source code in src/quivers/dsl/emit.py
static_argument_to_source
¶
static_argument_to_source(argument: QiecStaticArgument) -> str
Emit one static argument of an effect or type application.
| PARAMETER | DESCRIPTION |
|---|---|
argument
|
A type, an effect written as type syntax, or an index literal.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The argument's source form, as the module emitter writes it. |
Source code in src/quivers/dsl/emit.py
family_parameter_names
¶
Return the canonical QVR keyword order for family.
| PARAMETER | DESCRIPTION |
|---|---|
family
|
The family name as written in source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...] | None
|
The keyword names in canonical order, or None when no keyword
schema is declared for |
Source code in src/quivers/dsl/family_schemas.py
family_parameterizations
¶
Return every complete keyword schema accepted by family.
| PARAMETER | DESCRIPTION |
|---|---|
family
|
The family name as written in source.
TYPE:
|
canonical
|
The parameter names the family's registry record declares,
used when no schema for
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[tuple[str, ...], ...]
|
One tuple of keyword names per accepted parameterization, empty when the family takes no parameters. |
Source code in src/quivers/dsl/family_schemas.py
free_let_names
¶
free_let_names(expr: LetExprNode, *, bound: frozenset[str] = frozenset(), include_callees: bool = False) -> tuple[str, ...]
Return free value names in first-use order.
Lambda parameters and factor indices bind in their bodies. Call names are declarations by default; callers that model a callee as a host value can include them explicitly.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to scan.
TYPE:
|
bound
|
Names already bound around
TYPE:
|
include_callees
|
Whether the function name of a call counts as a free name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
Each free name once, in the order of its first occurrence. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the scan reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
let_expr_children
¶
let_expr_children(expr: LetExprNode) -> tuple[LetExprNode, ...]
Return the immediate expression children of expr in source order.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to take apart.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[LetExprNode, ...]
|
The direct subexpressions, empty for a leaf. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
Source code in src/quivers/dsl/let_expr_traversal.py
substitute_let_expr
¶
substitute_let_expr(expr: LetExprNode, substitution: Mapping[str, LetExprNode]) -> LetExprNode
Substitute expressions for free variables in expr without capture.
A lambda parameter or factor binder that would capture a free name of a replacement is renamed to a fresh name first.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to rewrite.
TYPE:
|
substitution
|
The replacement for each free variable name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LetExprNode
|
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the rewrite reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
walk_let_expr
¶
walk_let_expr(expr: LetExprNode) -> Iterator[LetExprNode]
Yield expr and all descendants in preorder.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The root of the walk.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
LetExprNode
|
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the walk reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
parse
¶
parse(source: str | bytes, file_path: str = '<source>') -> Module
Parse .qvr source into a Module.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The source text, or its UTF-8 bytes.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module's statements in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the source has a syntax error or a node the AST cannot represent. |
Source code in src/quivers/dsl/parser/core.py
parse_file
¶
parse_file(path: str | Path) -> Module
Parse a .qvr file at path.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The file to read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The file's statements in source order. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file cannot be read. |
ParseError
|
If the file does not parse. |
Source code in src/quivers/dsl/parser/core.py
extract_deduction_schema
¶
extract_deduction_schema(compiler: Compiler) -> Schema
Produce a panproto.Schema for the compiler's
deduction-system environment.
Walks the compiler's _deductions registry and emits one
panproto vertex per deduction system, one per rule, one per
atom, and per-premise / per-conclusion pattern vertices. The
returned schema validates against
QVR_DEDUCTION_PROTOCOL and is suitable for
panproto.diff_schemas and
panproto.auto_generate_lens operations over deduction
systems.
| PARAMETER | DESCRIPTION |
|---|---|
compiler
|
A compiler whose
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Schema
|
A schema in the |
Source code in src/quivers/dsl/program_theory.py
extract_program_schema
¶
extract_program_schema(compiler: Compiler) -> Schema
Produce a panproto.Schema for a compiled program.
Walks the compiler's resolved environment (objects, spaces, morphisms)
and its checked kernel module (effects, instances, handlers,
computations, and program entry points) and emits a graph of
vertices and edges in the QVR_PROGRAM_PROTOCOL protocol. The
returned schema validates against that protocol and is suitable for
panproto.diff_schemas, panproto.auto_generate_lens, and the rest
of panproto's schema-level operations.
| PARAMETER | DESCRIPTION |
|---|---|
compiler
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Schema
|
A program-level Schema in the |
Source code in src/quivers/dsl/program_theory.py
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 | |
has_qiec_surface
¶
has_qiec_surface(module: Module) -> bool
Return whether a parsed module has anything to elaborate through QIEC.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to inspect.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when at least one statement belongs to the QIEC surface or is a program or deduction the elaboration turns into computations. Callers use this to decide whether the QIEC route runs at all, so a module of other declarations pays nothing for it. |
Source code in src/quivers/dsl/qiec_lowering.py
lower_qvr_to_qiec
¶
lower_qvr_to_qiec(module: Module, *, module_name: str | None = None, file_path: str = '<source>', source_version: str = QVR_SOURCE_VERSION, target_version: str = QIEC_ABI, elaborate_programs: bool = True) -> QiecModule
Check and lower the QIEC projection of one parsed QVR module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module, which may mix QIEC and ordinary declarations.
TYPE:
|
module_name
|
Name the stable identities derive from. None takes it from
TYPE:
|
file_path
|
Path recorded on diagnostics.
TYPE:
|
source_version
|
The source protocol the module is written against.
TYPE:
|
target_version
|
The kernel ABI to lower to.
TYPE:
|
elaborate_programs
|
Whether
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecModule
|
The checked, lowered module. |
| RAISES | DESCRIPTION |
|---|---|
QiecDiagnosticError
|
If the source is rejected, with a stable code and a position. The
code |
KernelError
|
If the lowered module fails its independent recheck. |
Source code in src/quivers/dsl/qiec_lowering.py
non_qiec_projection
¶
Project declarations consumed by the categorical/probabilistic compiler.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to project.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
A module of everything outside the QIEC surface, in source order. |
Source code in src/quivers/dsl/qiec_lowering.py
qiec_projection
¶
Project QIEC declarations from a module with multiple neighborhoods.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to project.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
A module of the QIEC statements alone, in source order. The
complement is |
Source code in src/quivers/dsl/qiec_lowering.py
loads
¶
loads(source: str, *, data: dict | None = None) -> Program
Compile .qvr source text into a trainable Program.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The
TYPE:
|
data
|
Maps string keys to tensors (or tensor-like objects) for
any
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Program
|
The compiled program. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If |
CompileError
|
If the parsed module does not compile. |
Source code in src/quivers/dsl/__init__.py
load
¶
load(path: str | Path, *, data: dict | None = None) -> Program
Load and compile a .qvr file into a trainable Program.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The
TYPE:
|
data
|
Maps string keys to tensors for any
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Program
|
The compiled program. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file cannot be read. |
ParseError
|
If the file does not parse. |
CompileError
|
If the parsed module does not compile. |