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

[Refactor] Batch dimension as first dimension in tensors #11

Open
Brogis1 opened this issue Nov 29, 2022 · 4 comments
Open

[Refactor] Batch dimension as first dimension in tensors #11

Brogis1 opened this issue Nov 29, 2022 · 4 comments
Labels

Comments

@Brogis1
Copy link

Brogis1 commented Nov 29, 2022

Problem

Right now we have the batch dimension at the back of tensors in PyQ. However, in PyTorch it is in front.

Consequence

This entails reshaping tensors back and forth to make them compatible with PyTorch/PyQ convention. Hence, there are unnecessary code lines just for that.

Suggested Solution

We can make it possible to have both conventions (with a keyword argument) or just one (for instance, the batch dimension is the first and not last in PyQ tensors).

@madagra madagra changed the title PyQ batch dimension: Better to have it in front as in standard pytorch. Batch dimension as first dimension in tensors Nov 29, 2022
@madagra madagra added the feature New feature or request label Nov 29, 2022
@madagra
Copy link
Collaborator

madagra commented Nov 29, 2022

@Brogis1 Could you please add a small code snippets to the description above?

@Slimane33
Copy link
Collaborator

Right now the PyQ convention is made to align with the qubit index (qubit indices between 0, ... n-1 coincide with the dimensions 0, ... n-1 of the tensor).

I think however that changing it would not be too much problematic for the usage. It seems that there is no critical reason for the batch to be last dimension, so I would be in favor to change it as you suggest.

Implementing both conventions seems hard because we would make all functions like _apply_gate being also dependent of theat keyword. This ay slow down perfomances.

@dominikandreasseitz dominikandreasseitz added Refactor and removed feature New feature or request labels Oct 17, 2023
@RolandMacDoland RolandMacDoland changed the title Batch dimension as first dimension in tensors [Refactor] Batch dimension as first dimension in tensors Apr 26, 2024
@RolandMacDoland
Copy link
Collaborator

@dominikandreasseitz Is this still relevant ? I have the feeling it is closeable.

@dominikandreasseitz
Copy link
Collaborator

I think long-term it would make sense to make the switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants