Skip to content

[unitaryHACK] (#2) Qsharp support#17

Merged
pedrorrivero merged 20 commits intopedrorrivero:devfrom
Avhijit-Nair:dev
May 30, 2021
Merged

[unitaryHACK] (#2) Qsharp support#17
pedrorrivero merged 20 commits intopedrorrivero:devfrom
Avhijit-Nair:dev

Conversation

@Avhijit-Nair
Copy link
Copy Markdown
Contributor

These are changes I implemented for Qsharp platform. Please check it and then I'll make the commits to master.

@Avhijit-Nair Avhijit-Nair changed the title [unitaryHack] (#2) Qsharp support [unitaryHACK] (#2) Qsharp support May 28, 2021
Copy link
Copy Markdown
Owner

@pedrorrivero pedrorrivero left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Avhijit-codeboy! These are some general comments that need to be addressed before merging.

Comment thread qrand/platforms/qsharp/backend.py Outdated
Comment thread qrand/platforms/qsharp/backend.py Outdated
Comment thread qrand/platforms/qsharp/backend.py Outdated
Comment thread qrand/platforms/qsharp/circuit.py Outdated
Comment thread qrand/platforms/qsharp/circuit.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment on lines +115 to +119
return compile(
qsharp_code.format(
num_qubits=self.circuit.num_qubits, gates=self.circuit.gates
)
)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I thought qsharp's compile method return Union[QSharpCallable, List[QSharpCallable]]. That does not match the return type of this function. How so?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The qsharp code defined as a Python string in the function has only one operation, operation Program():String[], which compiles and returns only one callable, Program() and hence the return type is just QSharpCallable.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes, in this case all you are getting back is one QSharpCallable, but still the complete signature of the function is not that. Since you are not converting types (i.e. checking if you receive a list and "converting" it to a single callable) mypy should be sending some error: isn't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mypy didn't show any error, that's why I was able to commit in the first place.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I am wondering how is that the case though, any explanation?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@Avhijit-codeboy sent me the source code for compile through discord: https://github.com/microsoft/iqsharp/blob/main/src/Python/qsharp-core/qsharp/__init__.py

Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/circuit.py
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/backend.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Copy link
Copy Markdown

@crazy4pi314 crazy4pi314 left a comment

Choose a reason for hiding this comment

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

Some minor things, excited to try out!

@property
def max_measurements(self) -> int:
raise NotImplementedError(self.ERROR_MSG)
return 1048576
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Was this from a particular partner backend?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, but it confirms to Qiskit's simulator.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is roughly the maximum that qiskit allows (2^19 < 2^13*75 < 2^20). It was added for consistency and more as a default value. I will need to think about how to refactor, but I will take care of it myself. Any further thoughts @crazy4pi314?

Comment thread qrand/platforms/qsharp/backend.py Outdated
Comment thread qrand/platforms/qsharp/circuit.py
Comment thread qrand/platforms/qsharp/circuit.py Outdated
Comment thread qrand/platforms/qsharp/circuit.py
Comment thread qrand/platforms/qsharp/job.py
Comment thread qrand/platforms/qsharp/job.py
Comment thread qrand/platforms/qsharp/job.py
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/backend.py
Comment thread qrand/platforms/qsharp/circuit.py
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/job.py Outdated
Comment thread qrand/platforms/qsharp/platform.py
@pedrorrivero pedrorrivero merged commit 3867dc5 into pedrorrivero:dev May 30, 2021
@pedrorrivero
Copy link
Copy Markdown
Owner

Alright @Avhijit-codeboy great work! I will take it from here 😉

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.

3 participants