Skip to content
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

[open-systems] Phased classical simulation #1590

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a9d5d7f
notey
mpharrigan Mar 5, 2025
62e9fee
ctrl
mpharrigan Mar 5, 2025
ac2db81
qdtype
mpharrigan Mar 5, 2025
fbca42b
ctrl spec
mpharrigan Mar 5, 2025
4dfe53a
controlled
mpharrigan Mar 5, 2025
0f3b5a1
controlled
mpharrigan Mar 5, 2025
d8bbe49
data types
mpharrigan Mar 5, 2025
a747b51
on classical vals
mpharrigan Mar 5, 2025
497d7ee
dtypes
mpharrigan Mar 5, 2025
9bba4e4
registers
mpharrigan Mar 5, 2025
efe6f0f
registers
mpharrigan Mar 5, 2025
e145433
bloq ctrl spec
mpharrigan Mar 5, 2025
dedc304
cast
mpharrigan Mar 5, 2025
9fc5300
bloq dtypes
mpharrigan Mar 5, 2025
e0f2b41
controlled
mpharrigan Mar 5, 2025
c58116c
bloq dtypes
mpharrigan Mar 5, 2025
535c8ef
ctrl
mpharrigan Mar 5, 2025
9e97cc9
bloq dtypes
mpharrigan Mar 5, 2025
f283249
bloq dtypes
mpharrigan Mar 5, 2025
a26cdab
bloq dtypes
mpharrigan Mar 5, 2025
f9bd77d
bloq dtypes
mpharrigan Mar 5, 2025
a10a331
bloq dtypes
mpharrigan Mar 5, 2025
1c758d4
bloq dtypes
mpharrigan Mar 5, 2025
f57cdcc
drawing
mpharrigan Mar 5, 2025
d0773f1
drawing
mpharrigan Mar 5, 2025
ba39913
annotations
mpharrigan Mar 5, 2025
300b8ba
bits
mpharrigan Mar 5, 2025
bad1f36
bits
mpharrigan Mar 5, 2025
d668e62
init
mpharrigan Mar 5, 2025
e699973
init
mpharrigan Mar 5, 2025
85907da
controlled docs
mpharrigan Mar 5, 2025
96f2cbb
lint
mpharrigan Mar 5, 2025
919bdd9
fixes
mpharrigan Mar 5, 2025
b05d94d
Merge remote-tracking branch 'origin/main' into 2025-03/classical-1
mpharrigan Mar 5, 2025
40ef237
format
mpharrigan Mar 5, 2025
22e3184
autogenerate notebooks
mpharrigan Mar 5, 2025
aabe689
Merge remote-tracking branch 'origin/main' into 2025-03/classical-1
mpharrigan Mar 5, 2025
70bac9a
add notebook to toc
mpharrigan Mar 5, 2025
6e93114
fix musical score serialization
mpharrigan Mar 5, 2025
8951104
phased classical sim
mpharrigan Mar 5, 2025
9e1bb8c
docstring
mpharrigan Mar 5, 2025
7492027
Merge remote-tracking branch 'origin/main' into 2025-03/classical-1
mpharrigan Mar 10, 2025
8fb94c6
Merge branch '2025-03/classical-1' into 2025-03/classical-sim-1
mpharrigan Mar 10, 2025
3a395f7
stuff
mpharrigan Mar 10, 2025
fa68016
Merge remote-tracking branch 'origin/main' into 2025-03/classical-1
mpharrigan Mar 13, 2025
63ed9b4
Merge branch '2025-03/classical-1' into 2025-03/classical-sim-1
mpharrigan Mar 13, 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
Prev Previous commit
Next Next commit
bits
mpharrigan committed Mar 5, 2025
commit 300b8baf22064b2ce54061b805dd444872ea2344
17 changes: 10 additions & 7 deletions qualtran/simulation/tensor/_dense.py
Original file line number Diff line number Diff line change
@@ -13,11 +13,11 @@
# limitations under the License.

import logging
from typing import Dict, List, Tuple, TYPE_CHECKING
from typing import Any, Dict, List, Tuple, TYPE_CHECKING

from numpy.typing import NDArray

from qualtran import Bloq, Connection, ConnectionT, LeftDangle, RightDangle, Signature, Soquet
from qualtran import Bloq, Connection, ConnectionT, LeftDangle, RightDangle, Signature

from ._flattening import flatten_for_tensor_contraction
from ._quimb import cbloq_to_quimb
@@ -48,14 +48,14 @@ def _order_incoming_outgoing_indices(
# j: each qubit (sub-)index for a given data type
for reg in signature.rights():
for idx in reg.all_idxs():
for j in range(reg.dtype.num_qubits):
for j in range(reg.dtype.num_bits):
if idx:
inds.append((outgoing[reg.name][idx], j)) # type: ignore[index]
else:
inds.append((outgoing[reg.name], j)) # type: ignore[arg-type]
for reg in signature.lefts():
for idx in reg.all_idxs():
for j in range(reg.dtype.num_qubits):
for j in range(reg.dtype.num_bits):
if idx:
inds.append((incoming[reg.name][idx], j)) # type: ignore[index]
else:
@@ -64,7 +64,7 @@ def _order_incoming_outgoing_indices(
return inds


def get_right_and_left_inds(tn: 'qtn.TensorNetwork', signature: Signature) -> List[List[Soquet]]:
def get_right_and_left_inds(tn: 'qtn.TensorNetwork', signature: Signature) -> List[List[Any]]:
"""Return right and left tensor indices.

In general, this will be returned as a list of length-2 corresponding
@@ -80,8 +80,11 @@ def get_right_and_left_inds(tn: 'qtn.TensorNetwork', signature: Signature) -> Li
"""
left_inds = {}
right_inds = {}

# Each index is a (cxn: Connection, j: int) tuple.
cxn: Connection
j: int

for ind in tn.outer_inds():
cxn, j = ind
if cxn.left.binst is LeftDangle:
@@ -99,13 +102,13 @@ def get_right_and_left_inds(tn: 'qtn.TensorNetwork', signature: Signature) -> Li
left_ordered_inds = []
for reg in signature.lefts():
for idx in reg.all_idxs():
for j in range(reg.dtype.num_qubits):
for j in range(reg.dtype.num_bits):
left_ordered_inds.append(left_inds[reg, idx, j])

right_ordered_inds = []
for reg in signature.rights():
for idx in reg.all_idxs():
for j in range(reg.dtype.num_qubits):
for j in range(reg.dtype.num_bits):
right_ordered_inds.append(right_inds[reg, idx, j])

inds = []