Skip to content

Conversation

@WeiguoMa
Copy link
Contributor

This PR contains extensive preliminary work for quditcircuit, including:
1. Removing and improving a large amount of hard-coded logic based on qubit systems with dimension 2, replacing it with a general dimension d;
2. Preserving the efficient sampling method for d = 2, while providing an if branch for cases where d != 2;
3. Updating the state labeling scheme from standard binary to a base-d representation using 0–9A–Z;
4. Adjusting the hard-coded parts in MPSCircuit and densitycircuit to ensure their functionality as qudit backends in the future, while currently forbidding the direct creation of qudits with d != 2 from mpscircuit and densitycircuit.

WeiguoMa and others added 18 commits August 27, 2025 14:04
… While a qudit in |10> state, it will be shown as `A` from _ALPHBET.
…l the functions are now avaliable for any d-dimensional systems. Add _infer_num_sites() for inferring the site number in d-dimensional system.
…qudit gates. And optimized some code writing.
…rcuit is now suitable to do general calculation for d-dimensional systems.
…as matrix(), get_quoperator() method), add a _qudit attribute to abstractcircuit.py, defaulting to False.
@refraction-ray
Copy link
Member

please add some tests for these changed functions with d>2, some may require d>10, also be consistent with the variable name: d or dim

Copy link
Member

@refraction-ray refraction-ray left a comment

Choose a reason for hiding this comment

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

In general looks nice, the pr can be merged after fixing the following minor points

ind = backend.probability_sample(
shots=1,
p=backend.cast(pu, rdtypestr),
status=one_r - st,
Copy link
Member

Choose a reason for hiding this comment

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

why one_r-st instead of st?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because probability_sample internally uses 1 - status when mapping uniform random numbers to the CDF, passing one_r - st ensures the sampling behavior stays consistent with the original implicit_randc/CDF logic.

@refraction-ray
Copy link
Member

LGTM now, will merge if there is no CI error

@WeiguoMa
Copy link
Contributor Author

WeiguoMa commented Sep 3, 2025

Great, it seems that the program has passed the CI.

@refraction-ray refraction-ray merged commit f82b382 into tensorcircuit:master Sep 3, 2025
1 check passed
@WeiguoMa WeiguoMa deleted the qudit_infras branch September 3, 2025 04:14
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