Skip to content
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2037c83
Add quditgates.py and quditcircuit.py.
WeiguoMa Aug 28, 2025
3c062ab
add quditgates to __init__.py
WeiguoMa Aug 28, 2025
30c7025
Add functions from tc.Circuit
WeiguoMa Aug 29, 2025
da94086
Add tests for QuditCircuit
WeiguoMa Aug 29, 2025
6755d9f
Reported a potential bug.
WeiguoMa Aug 29, 2025
2b600b8
Add doc.
WeiguoMa Aug 29, 2025
4b96665
black
WeiguoMa Aug 29, 2025
dbbb685
Add QuditCircuit interface to __init__.py
WeiguoMa Aug 31, 2025
12f66c8
remove a useless pack
WeiguoMa Sep 1, 2025
4eb9dc2
remove useless pack.
WeiguoMa Sep 1, 2025
bde4f24
fixed a possible bug
WeiguoMa Sep 1, 2025
0212135
formatted codes.
WeiguoMa Sep 1, 2025
c910791
remove redundant code.
WeiguoMa Sep 1, 2025
255824a
add test_large_scale_sample
WeiguoMa Sep 2, 2025
edb97b1
Adjust the code framework
WeiguoMa Sep 3, 2025
b0b30d5
new docstring
WeiguoMa Sep 3, 2025
7585731
Add tests for quditgates
WeiguoMa Sep 3, 2025
0e6c053
formatted codes
WeiguoMa Sep 3, 2025
96a55b2
formatted codes
WeiguoMa Sep 3, 2025
9dbabaa
black
WeiguoMa Sep 3, 2025
35288d2
reform doc
WeiguoMa Sep 3, 2025
a3f2131
use np.eye
WeiguoMa Sep 3, 2025
5278f50
use np.diag
WeiguoMa Sep 3, 2025
62750f1
fixed an early notation
WeiguoMa Sep 3, 2025
3a265cc
use np.diag
WeiguoMa Sep 3, 2025
d88b9a9
remove useless line
WeiguoMa Sep 3, 2025
26dd999
change atol from 1e-4 to 1e-5
WeiguoMa Sep 3, 2025
60ce1e7
bug fixed
WeiguoMa Sep 3, 2025
8793b21
use highp
WeiguoMa Sep 3, 2025
2135ecf
remove `count_vector` from sample
WeiguoMa Sep 3, 2025
3e29f11
remove sympy
WeiguoMa Sep 3, 2025
8c86e1c
format codes according to pylint
WeiguoMa Sep 3, 2025
83378fb
change u8 __doc__
WeiguoMa Sep 3, 2025
d379cff
remove 'count_vector'
WeiguoMa Sep 3, 2025
995a3c8
remove y gate
WeiguoMa Sep 3, 2025
10cc46c
remove a y-related test info
WeiguoMa Sep 3, 2025
a64a3b9
remove y
WeiguoMa Sep 3, 2025
b6a8c10
rzz_gate from global to local (for consistence)
WeiguoMa Sep 4, 2025
92d98a3
np -> backend to ensure the auto-differential
WeiguoMa Sep 5, 2025
ee8b617
fixed rzz_gate
WeiguoMa Sep 5, 2025
9cceefa
fixed a docsing bug
WeiguoMa Sep 5, 2025
56902a5
Add expectation_before(), amplitude_before() functions
WeiguoMa Sep 5, 2025
d396ba2
add Gate
WeiguoMa Sep 5, 2025
8b224f0
Provide a corresponding uppercase entry for the doors.
WeiguoMa Sep 5, 2025
0944fb5
np -> backend, and this should solve auto-differential.
WeiguoMa Sep 5, 2025
3dd499b
Fixed a bug that could lead to backend pollution.
WeiguoMa Sep 5, 2025
5c3a082
add test_quditvqe.py for testing vqe, jit and vmap in QUDIT Interface.
WeiguoMa Sep 5, 2025
cdb1ee6
add tests for codecov test.
WeiguoMa Sep 5, 2025
90646ee
black .
WeiguoMa Sep 5, 2025
0e253e1
extend check_rotation()
WeiguoMa Sep 5, 2025
5a9a4ea
remove qudit gates lru_cache
WeiguoMa Sep 5, 2025
507c3ab
optimized codes
WeiguoMa Sep 5, 2025
ee11fd2
remove un-used import.
WeiguoMa Sep 5, 2025
9849ee0
fixed a bug of qudit swap
WeiguoMa Sep 5, 2025
a5246ae
add backend as para for tests/
WeiguoMa Sep 5, 2025
7a8759e
add ref to u8 gate and fixed logical bug of this
WeiguoMa Sep 5, 2025
80b04af
move jit, autograd, vmap tests to test_quditcircuit.py
WeiguoMa Sep 5, 2025
8ff6981
Add an example for qudit vqe.
WeiguoMa Sep 5, 2025
768b003
format
WeiguoMa Sep 5, 2025
68bb073
remove quditvqe test.
WeiguoMa Sep 6, 2025
8aa2695
change function name
WeiguoMa Sep 6, 2025
53669a2
add test for len(nodes) in amplitude_before_test
WeiguoMa Sep 6, 2025
52f9804
optimized examples/vqe_qudit_example.py according to comments.
WeiguoMa Sep 6, 2025
d4d3d8d
refresh the whole file, making no complicated conversion
WeiguoMa Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tensorcircuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
runtime_contractor,
) # prerun of set hooks
from . import gates
from . import quditgates
from . import basecircuit
from .gates import Gate
from .quditcircuit import QuditCircuit
from .circuit import Circuit, expectation
from .mpscircuit import MPSCircuit
from .densitymatrix import DMCircuit as DMCircuit_reference
Expand Down
24 changes: 4 additions & 20 deletions tensorcircuit/basecircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,28 +480,12 @@ def measure_jit(

def amplitude_before(self, l: Union[str, Tensor]) -> List[Gate]:
r"""
Returns the tensornetwor nodes for the amplitude of the circuit given a computational-basis label ``l``.
For a state simulator, it computes :math:`\langle l \vert \psi\rangle`;
for a density-matrix simulator, it computes :math:`\mathrm{Tr}(\rho \vert l\rangle\langle l\vert)`.
Returns the tensornetwor nodes for the amplitude of the circuit given the bitstring l.
For state simulator, it computes :math:`\langle l\vert \psi\rangle`,
for density matrix simulator, it computes :math:`Tr(\rho \vert l\rangle \langle 1\vert)`
Note how these two are different up to a square operation.

:Example:

>>> c = tc.Circuit(2)
>>> c.X(0)
>>> c.amplitude("10") # d=2, per-qubit digits
array(1.+0.j, dtype=complex64)
>>> c.CNOT(0, 1)
>>> c.amplitude("11")
array(1.+0.j, dtype=complex64)

For qudits (d>2, d<=36):
>>> c = tc.Circuit(3, dim=12)
>>> c.amplitude("0A2") # base-12 string, A stands for 10

:param l: Basis label.
- If a string: it must be a base-d string of length ``nqubits``, using 0–9A–Z (A=10,…,Z=35) when ``d<=36``.
- If a tensor/array/list: it should contain per-site integers in ``[0, d-1]`` with length ``nqubits``.
:param l: The bitstring of 0 and 1s.
:type l: Union[str, Tensor]
:return: The tensornetwork nodes for the amplitude of the circuit.
:rtype: List[Gate]
Expand Down
Loading