Skip to content

Tenpy&Quimb&Tensornetwork Transform #25

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

Closed
wants to merge 2 commits into from

Conversation

Charlespkuer
Copy link

This work focuses on developing a comprehensive interoperability framework for quantum computing libraries within the TensorCircuit-NG ecosystem. The primary contribution involves implementing bidirectional conversion functions that enable seamless integration between TensorCircuit's QuOperator format and major tensor network libraries including TeNPy, Quimb, and TensorNetwork.

contraction_nodes + [left_node, right_node],
output_edge_order=output_edges + input_edges,
)
mat_from_tenpy = tc.backend.reshape(
Copy link
Member

Choose a reason for hiding this comment

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

the logic for this check is complicated, just check that each local tensor are the same in the two format is okay, no need to do the contraction is the impl is so complicated

mpo_original = MPO(sites, Ws, IdL=0, IdR=chi_mpo - 1)

qop_mpo = tc.quantum.tenpy2qop(mpo_original)
mpo_roundtrip = tc.quantum.qop2tenpy(qop_mpo)
Copy link
Member

Choose a reason for hiding this comment

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

just check the local tensor are the same after roundtrip is sufficient? no need complicated contraction below.

Copy link
Member

@refraction-ray refraction-ray Aug 5, 2025

Choose a reason for hiding this comment

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

but sometimes, check the final contracted tensor indeed important as this confirms the connection beside the nodes themselves, so carefully design the tests and keep the necessary parts. There should be direct way and functions to contract the whole MPO or MPS on quimb, tensornetwork and tenpy, aren't they?

quimb_tensors = []
node_map = {node: i for i, node in enumerate(sorted_nodes)}
for i, node in enumerate(sorted_nodes):
tensor_data = np.asarray(node.tensor)
Copy link
Member

Choose a reason for hiding this comment

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

why change tensor to numpy format? quimb should also accept jax or tf tensor directly?

contraction_nodes + [left_node, right_node],
output_edge_order=output_edges + input_edges,
)
mat_from_tenpy = np.reshape(
Copy link
Member

Choose a reason for hiding this comment

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

are there any method in tenpy directly contracting the MPO? the current check further goes back to tn to build the tensor and contract which seems verbose

if not endpoint_nodes:
endpoint_nodes = {edge.node1 for edge in qop.ignore_edges if edge.node1}

if not endpoint_nodes and len(nodes_for_sorting) > 1:
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 the case here, the min bond should be counted as sum of the bond dimension instead of sum of 1?

Copy link

codecov bot commented Aug 9, 2025

Codecov Report

❌ Patch coverage is 89.67136% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
tensorcircuit/quantum.py 89.67% 22 Missing ⚠️
Files with missing lines Coverage Δ
tensorcircuit/quantum.py 88.56% <89.67%> (+3.28%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…puting libraries within the TensorCircuit-NG ecosystem. The primary contribution involves implementing bidirectional conversion functions that enable seamless integration between TensorCircuit's QuOperator format and major tensor network libraries including TeNPy, Quimb, and TensorNetwork.
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