-
Notifications
You must be signed in to change notification settings - Fork 12
Qudit infras #42
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
Qudit infras #42
Conversation
… 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.
|
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 |
# Conflicts: # tensorcircuit/basecircuit.py # tensorcircuit/quantum.py
refraction-ray
left a comment
There was a problem hiding this 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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
LGTM now, will merge if there is no CI error |
|
Great, it seems that the program has passed the CI. |
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.