Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Automatically add resource req for custom ops #389

Closed
wants to merge 1 commit into from

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Aug 9, 2023

Closes #388

This fix is blocked by extension inference.
The failing test in builder::circuit::test::with_nonlinear_and_outputs constructs this diagram:

image

Where MissingRsrc.MyOp now requires MissingRsrc. The output node has that extension in input_resources, but the rest of the operations in the region need to define it too. (And I think we'll require a lift node for qubit 1?)

@aborgna-q aborgna-q marked this pull request as draft August 9, 2023 16:14
@acl-cqc
Copy link
Contributor

acl-cqc commented Aug 22, 2023

Hmmm, see here:

https://github.com/CQCL-DEV/hugr/blob/377dc57ebe7a87b99c9b86ae2473da426d380f44/src/extension/op_def.rs#L227-L229

if we go with the approach in this comment, we'll have to update a lot of resources. Alternatively this might be a better place to compute the union.

@aborgna-q aborgna-q changed the title Automatically add resource req for custom ops fix: Automatically add resource req for custom ops Nov 7, 2023
@aborgna-q aborgna-q force-pushed the fix/customop-resource branch from 177cccd to 443ccf7 Compare November 9, 2023 11:07
@aborgna-q
Copy link
Collaborator Author

aborgna-q commented Nov 9, 2023

Updated to the latest HEAD.
This change still causes either a TgtExceedsSrcExtensions or a MismatchedConcreteWithLocations error in 24/154 tests.

@acl-cqc
Copy link
Contributor

acl-cqc commented Nov 10, 2023

Updated to the latest HEAD. This change still causes either a TgtExceedsSrcExtensions or a MismatchedConcreteWithLocations error in 24/154 tests.

Sounds like the same as changing

// TODO bring this assert back once resource inference is done?
// https://github.com/CQCL-DEV/hugr/issues/425
// assert!(res.contains(self.extension()));
to add the new element rather than assert - which I think is probably an easier place to do it (that catches all cases in one go).

But yeah, the bulk of the work here is figuring out why the tests are failing. In most cases it is probably that the tests need updating....

@acl-cqc
Copy link
Contributor

acl-cqc commented Jan 5, 2024

I think we can close this as #734 is an up-to-date version that includes all the necessary test fixes ?

@aborgna-q aborgna-q closed this Jan 5, 2024
@aborgna-q aborgna-q deleted the fix/customop-resource branch February 20, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom operations implicitly require their extension
2 participants