-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Added static attribute num_params
to all standard gates
#6883
Conversation
Not at all sure it's the cause of the test failure, but you've got |
Yep thanks I'm aware, they're mostly placeholders for now :) |
why
I'm not familiar with qasm at all so not sure what the best approach is in this case, maybe rename the property in Any advice would be greatly appreciated 😊 |
I think this runs a little deeper than just QASM, that's just where the problem became visible. I think we decided that If the model moves to more of a QASM-3-like one, with significant classical control flow, this won't be a problem any more, because we'd be swapping to the |
Ok that makes sense, except
Any other suggestions welcome 😄 |
Any instance of That said, I still think it's worthwhile doing this kind of thing where we can, even if it doesn't entirely work out for |
I agree with Jake's last comment, this would maybe fix the issue that large circuits consume a large amount of memory. I think the So to me Abby's option 3 together with Jake's comment make sense: keep Is the name getter of the controlled gates the only thing keeping us from making the # in Instruction
name = "ch" # static attribut
# in circuit's qasm() method
name = instruction.name
if isinstance(instruction, ControlledGate) and instruction._open_ctrl:
name += # open control suffix like _o2 This assumes that the name with the open control suffix, like |
Ok I've reverted the TwoLocal changes (moved them into another PR #7100) so this one can just focus on adding the static attributes to the standard gates. Are there any other static attributes we think it would be useful to have other than |
|
Maybe we can reduce this PR to the number of qubits/clbits and the number of parameters. In |
Looking back on this PR (it's been quite a while now) - adding a static For the future: with enhanced classical processing, and with the intent of reducing memory usage, I've proposed in Qiskit/RFCs#26 a move towards encoding a "type signature" on gates and circuits, which would also cover all the things suggested here, I think (except |
Maybe we can revive this for the 0.24 release 🙂
|
Pull Request Test Coverage Report for Build 4445539346
💛 - Coveralls |
So we came across an issue with both |
name
and num_params
to all standard gatesnum_params
to all standard gates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've lost the original reason for this change now on this PR, sorry.
What's the intended use-case for this static num_params
field? It's not a field on Instruction
or Gate
, so in general, if we've got an Instruction
we can't know if it's got this field or not, so it's not really safe to try and use it.
(fwiw: I checked the files and agree that all the num_params
fields are correct)
@jakelishman the original purpose for adding the |
Looking back to that underlying I'm not sure that adding a static |
Oh I wasn't aware that mapping exists now, that would solve the use case here. So after a long back and forth it seems we found a good solution for the original use case 😬 |
It didn't at the time you opened the issue, or even when Abby opened this PR - it's relatively recent (maybe Terra 0.22, I think?). |
Yeah, git blame says it's from 6 months ago and this PR is from 2021 😅 |
Given the above comments, the difficulties we had with all the edge cases involved, and that the underlying use-case for this got solved another way, I'll close this PR as staled now. Thanks for the work, and feel free to re-open if there's more to discuss. |
Summary
name
lower case string name of the gatenum_params
number of angle params the class requiresDetails and comments
This PR originally was created for #6185 but due to the complexity of the solution it has now been split into 2x PRs. This one covers the creation of the static attributes, and the
twolocal
changes have been moved to #7100