Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

test: Add integration tests lowering guppy programs #35

Merged
merged 5 commits into from
Jun 20, 2024

Conversation

doug-q
Copy link
Collaborator

@doug-q doug-q commented Jun 19, 2024

No description provided.

@doug-q
Copy link
Collaborator Author

doug-q commented Jun 19, 2024

Note that this PR includes #31 and #33, let's wait for those before we merge this.

@doug-q doug-q requested a review from mark-koch June 19, 2024 07:29
@doug-q doug-q force-pushed the doug/init-guppy-tests branch from 528ef43 to c98c979 Compare June 19, 2024 07:30
@doug-q
Copy link
Collaborator Author

doug-q commented Jun 19, 2024

Ahh, I need to fix CI to have python with guppylang in path for the tests.
EDIT: done

Copy link
Contributor

@mark-koch mark-koch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

The only thing I'm not sure about is if we should actually store the lowered Guppy examples as golden values. This only works if the node order outputted by Guppy is deterministic. AFAIK this is currently the case, but not sure if we want to guarantee that?

let ty: FloatType<'c> = context
.llvm_type(&k.get_type())?
.try_into()
.map_err(|_| anyhow!("Failed to get type of ConstF64 as FloatType"))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this error actually happen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how, you prefer unwrap?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 👍

@doug-q
Copy link
Collaborator Author

doug-q commented Jun 20, 2024

The only thing I'm not sure about is if we should actually store the lowered Guppy examples as golden values. This only works if the node order outputted by Guppy is deterministic. AFAIK this is currently the case, but not sure if we want to guarantee that?

I think guppy node order should be deterministic, but it should also be unspecified. I.e. compiling the same program twice is guaranteed to give the same result, but it may change arbitrarily between guppy versions. I think it is worth some effort to ensure guppy is deterministic. There is certainly a lot of literature on the benefits of deterministic compilation and reproducible builds, and I would assume that the same arguments would apply to guppy.

I agree that these golden tests are fragile and that when they break it will not be guppy's fault. On the other hand, for now they are convenient, allow by-hand inspection of codegen in github, and I can't think of a better way to test that compiling guppy works. Are you ok with leaving them in for now, and replacing them when they become too annoying, or when we come up with a better solution? Maybe execution tests.

@mark-koch
Copy link
Contributor

There is certainly a lot of literature on the benefits of deterministic compilation and reproducible builds, and I would assume that the same arguments would apply to guppy.

Fair enough. If we make that a Guppy requirement, we should probably verify it for all Guppy integration tests?

Are you ok with leaving them in for now, and replacing them when they become too annoying, or when we come up with a better solution? Maybe execution tests.

Yes, happy to merge the PR as is 👍

@doug-q doug-q force-pushed the doug/init-guppy-tests branch from c8fc106 to dc87ebd Compare June 20, 2024 11:20
@doug-q doug-q added this pull request to the merge queue Jun 20, 2024
Merged via the queue into main with commit b63ba63 Jun 20, 2024
10 checks passed
@doug-q doug-q deleted the doug/init-guppy-tests branch June 20, 2024 11:26
@hugrbot hugrbot mentioned this pull request Jun 26, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jul 10, 2024
## 🤖 New release
* `hugr-llvm`: 0.1.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.1.0](https://github.com/CQCL/hugr-llvm/releases/tag/v0.1.0) -
2024-07-10

### Bug Fixes
- Syntax error
- sum type tag elision logic reversed
- [**breaking**] Allow Const and FuncDecl as children of Modules,
Dataflow Parents, and CFG nodes
([#46](#46))

### Documentation
- fix bad grammar ([#34](#34))

### New Features
- Emission for Call nodes
- Support  values
- add `get_extern_func`
([#28](#28))
- lower CFGs ([#26](#26))
- Add initial codegen extension for `prelude`
([#29](#29))
- [**breaking**] `Namer` optionally appends node index to mangled names.
([#32](#32))
- Implement lowerings for ieq,ilt_s,sub in int codegen extension
([#33](#33))
- Add initial `float` extension
([#31](#31))
- Emit more int comparison operators
([#47](#47))

### Refactor
- clean up fat.rs ([#38](#38))

### Testing
- add a test for sum type tags
- Add integration tests lowering guppy programs
([#35](#35))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

---------

Co-authored-by: Douglas Wilson <douglas.wilson@quantinuum.com>
@hugrbot hugrbot mentioned this pull request Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants