✨ Add qtensor dialect to MLIR#1542
✨ Add qtensor dialect to MLIR#1542li-mingbao wants to merge 21 commits intomunich-quantum-toolkit:mainfrom
qtensor dialect to MLIR#1542Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
@denialhaag @burgholzer Currently the new operations are implemented on top of the other operations and do not replace the Let me know if this is ok or if the qubits should be deallocated separately with the tensor at the end. |
Thanks a lot for getting this started! 🙂
Is there an argument against defining a
That sounds fine to me! If a qubit is extracted and modified, it should probably be inserted again before the tensor is deallocated, though. 🤔 |
Also from my side: thanks! this is great to see 🙌🏼
I think I would also prefer that. This matches more closely with the notion of how registers are allocated and feels quite natural to me.
To guarantee proper linear types any qubit and any register value needs to be used exactly once, i.e., every value needs to have a sink. |
Description
This PR adds the
qtensordialect to the environment.The
qtensordialect is an adjusted version of the standardtensordialect that supports linear typing for tensors with qubit types.At the moment the following operations are supported:
extract,extract_slice,from_elements,insert,insert_slice.extractoperations are modified so that they also return the input tensor as result.insertand thefrom_elementsoperations are just wrapper operations that are canonicalized to a standardtensoroperation.insert_sliceis identical to the standard operation but the canonicalizations are slightly adjusted to fit the new extract operation.In addition, a
qtensor.deallocoperation is added that deallocates a tensor and serves as a sink operation.Example:
Checklist: