Skip to content

PR Draft for Qudit inferface #31

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WeiguoMa
Copy link

No description provided.

@WeiguoMa WeiguoMa marked this pull request as ready for review August 14, 2025 09:24
@WeiguoMa WeiguoMa marked this pull request as draft August 14, 2025 09:26
@@ -13,7 +13,8 @@

Copy link
Member

Choose a reason for hiding this comment

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

this file is very old and deprecated, so no need to take care of the module

@@ -217,15 +217,15 @@ def train_qml_vag(
c.exp( # type: ignore
i,
(i + 1) % 10,
unitary=array_to_tensor(G._swap_matrix),
Copy link
Member

Choose a reason for hiding this comment

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

the same to this file, no need to care about files in applications

self, nqubits: int, inputs: Tensor = None, tableau_inputs: Tensor = None
self,
nqubits: int,
dim: Optional[int] = None,
Copy link
Member

Choose a reason for hiding this comment

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

it doesn;t support qudit anyway,no need to add

@@ -79,6 +51,31 @@ class AbstractCircuit:
mpogates = mpogates
gate_aliases = gate_aliases

def _validate_dim(self, dim: Optional[int]) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

this is set dim instead of validate dim?

from . import gates

gmod = gates.get_gate_module(int(getattr(self, "_d", 2)))
self._gmod = gmod
Copy link
Member

Choose a reason for hiding this comment

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

the circuit class should be tested with python multiprocessing, to see whether there is subtle issues

for g in sgates:
setattr(
cls, g, cls.apply_general_gate_delayed(gatef=getattr(gates, g), name=g)
cls, g, cls.apply_general_gate_delayed(gatef=cls._named_stub(g), name=g)
Copy link
Member

Choose a reason for hiding this comment

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

what is this for, _named_stub always raise error?

# --- Default behavior: Register and export qubit gates when importing tensorcircuit.gates ---
try:
_DEFAULT_GATE_MODULE: types.ModuleType = set_gates_for(2, export=True)
except Exception:
Copy link
Member

Choose a reason for hiding this comment

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

catch what exception here?

return mod


def set_gates_for(dim: Optional[int] = None, export: bool = True) -> types.ModuleType:
Copy link
Member

Choose a reason for hiding this comment

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

dont allow export for clarity? the qudit gates can only be accessed from a predefined variable assigned by set_gates_for instead of global export, so that we can avoid global namesapce rewriting

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.

2 participants