Skip to content

Commit

Permalink
chore!: Update hugr to 0.8.0 (#454)
Browse files Browse the repository at this point in the history
Updates guppy to use extension operation definitions instead of opaque
ops defined on the fly.

Some relevant changes included:

* Defined a new `guppylang` extension with two ops: `partial` and
`unsupported`
* Most list and array operations currently emit `unsupported`, as they
require custom hugr building code (the core ops in `std.collections`
don't match the python operations 1 to 1, it'll need some custom
compilation code).
* Changed `module.compile` to produce a `Package` containing the hugr
along with the required extensions to interpret it. (Currently
hardcoded, we should infer which extensions are needed at some point).
* We hardcode the tket2 extension jsons. The plan is for `tket2` to
publish a new library exporting those, but for now we need the jsons for
validation.
* Use the prelude operations exported by hugr for most
int/float/logic/conversion builtin definitions.

The `tket2` dependency is currently pinned to a commit hash, I'll update
it once `0.3.0` is released.

- Closes #442
- Closes #411
- Closes #412
- Closes #410 

BREAKING CHANGE: Bumped the `hugr` dependency to `0.8.0`

---------

Co-authored-by: Agustin Borgna <[email protected]>
  • Loading branch information
aborgna-q and Agustin Borgna authored Sep 6, 2024
1 parent 1d0667b commit b02e0d0
Show file tree
Hide file tree
Showing 55 changed files with 3,317 additions and 1,019 deletions.
22 changes: 20 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,26 @@ repos:
- id: check-vcs-permalinks
- id: check-yaml
- id: detect-private-key
# - id: end-of-file-fixer
# - id: trailing-whitespace
- id: end-of-file-fixer
exclude: |
(?x)^(
.*\.json|
.*\.err|
tests/.*|
.*CHANGELOG.md|
\.github/.*|
.release-please-manifest.json
)$
- id: trailing-whitespace
exclude: |
(?x)^(
.*\.json|
.*\.err|
tests/.*|
.*CHANGELOG.md|
\.github/.*|
.release-please-manifest.json
)$
- id: fix-byte-order-marker
- id: mixed-line-ending
# Python-specific
Expand Down
76 changes: 43 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ debug_assert_with_mut_call = "warn"

[workspace.dependencies]
pyo3 = "0.19.0"
hugr = "0.11.0"
hugr-cli = "0.4.0"
hugr-llvm = "0.3.0"
hugr = "0.12.1"
hugr-cli = "0.6.0"
hugr-llvm = "0.4.0"
serde_json = "1.0.111"
inkwell = "0.4.0"
cargo_toml = "0.20.4"
Expand Down
4 changes: 1 addition & 3 deletions execute_llvm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "execute-llvm"
requires-python = ">=3.10,<3.13"
classifiers = [
"Private :: Do Not Upload",
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
Expand All @@ -14,6 +15,3 @@ build-backend = "maturin"

[tool.maturin]
features = ["pyo3/extension-module"]

[tool.uv]
no-build = true
2 changes: 1 addition & 1 deletion guppylang/checker/linearity_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def visit_PlaceNode(self, node: PlaceNode, /, is_inout_arg: bool = False) -> Non
# Visiting the `__getitem__(place.parent, place.item)` call ensures that we
# linearity-check the parent and element.
self.visit(subscript.getitem_call)
# For all other places, we record uses of all leafs
# For all other places, we record uses of all leaves
else:
for place in leaf_places(node.place):
x = place.id
Expand Down
8 changes: 4 additions & 4 deletions guppylang/compiler/cfg_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from collections.abc import Sequence

from hugr import Wire, ops
from hugr import cfg as hc
from hugr import tys as ht
from hugr.dfg import DP, _DfBase
from hugr.node_port import ToNode
from hugr.build import cfg as hc
from hugr.build.dfg import DP, DfBase
from hugr.hugr.node_port import ToNode

from guppylang.checker.cfg_checker import CheckedBB, CheckedCFG, Row, Signature
from guppylang.checker.core import Place, Variable
Expand All @@ -22,7 +22,7 @@

def compile_cfg(
cfg: CheckedCFG[Place],
container: _DfBase[DP],
container: DfBase[DP],
inputs: Sequence[Wire],
globals: CompiledGlobals,
) -> hc.Cfg:
Expand Down
8 changes: 4 additions & 4 deletions guppylang/compiler/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import cast

from hugr import Wire, ops
from hugr.dfg import DP, _DfBase
from hugr.build.dfg import DP, DfBase

from guppylang.checker.core import FieldAccess, Place, PlaceId, Variable
from guppylang.definition.common import CompiledDef, DefId
Expand All @@ -24,13 +24,13 @@ class DFContainer:
current compilation state.
"""

builder: _DfBase[ops.DfParentOp]
builder: DfBase[ops.DfParentOp]
locals: CompiledLocals = field(default_factory=dict)

def __init__(
self, builder: _DfBase[DP], locals: CompiledLocals | None = None
self, builder: DfBase[DP], locals: CompiledLocals | None = None
) -> None:
generic_builder = cast(_DfBase[ops.DfParentOp], builder)
generic_builder = cast(DfBase[ops.DfParentOp], builder)
if locals is None:
locals = {}
self.builder = generic_builder
Expand Down
Loading

0 comments on commit b02e0d0

Please sign in to comment.