Skip to content

Commit

Permalink
Add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankya2 committed Feb 1, 2024
1 parent 460f5e7 commit 6f4ffa7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ Qibotn is the tensor-network translation module for Qibo to support large-scale

To get started, `python setup.py install` to install the tools and dependencies.

# Computation Supported

- Tensornet (TN)
- TN contraction to dense vector
- TN contraction to dense vector with Message Passing Interface (MPI)
- TN contraction to dense vector with NCCL
- TN contraction to expectation of given Pauli string
- TN contraction to expectation of given Pauli string with Message Passing Interface (MPI)
- TN contraction to expectation of given Pauli string with NCCL

- Matrix Product State (MPS)
- MPS contraction to dense vector

# Sample Codes
## Single Node
The code below shows an example of how to activate the Cuquantum TensorNetwork backend of Qibo.
Expand Down
18 changes: 10 additions & 8 deletions src/qibotn/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def expectation_pauli_tn(qibo_circ, datatype, pauli_string):
myconvertor = QiboCircuitToEinsum(qibo_circ, dtype=datatype)
return contract(
*myconvertor.expectation_operands(
PauliStringGen(qibo_circ.nqubits, pauli_string)
pauli_string_gen(qibo_circ.nqubits, pauli_string)
)
)

Expand Down Expand Up @@ -234,7 +234,7 @@ def expectation_pauli_tn_nccl(qibo_circ, datatype, pauli_string, n_samples=8):
# mem_avail = cp.cuda.Device().mem_info[0]
# print("Mem avail: aft convetor",mem_avail, "rank =",rank)
operands = myconvertor.expectation_operands(
PauliStringGen(qibo_circ.nqubits, pauli_string)
pauli_string_gen(qibo_circ.nqubits, pauli_string)
)

# mem_avail = cp.cuda.Device().mem_info[0]
Expand Down Expand Up @@ -315,7 +315,7 @@ def expectation_pauli_tn_MPI(qibo_circ, datatype, pauli_string, n_samples=8):
# mem_avail = cp.cuda.Device().mem_info[0]
# print("Mem avail: aft convetor",mem_avail, "rank =",rank)
operands = myconvertor.expectation_operands(
PauliStringGen(qibo_circ.nqubits, pauli_string)
pauli_string_gen(qibo_circ.nqubits, pauli_string)
)
# mem_avail = cp.cuda.Device().mem_info[0]
# print("Mem avail: aft operand interleave",mem_avail, "rank =",rank)
Expand Down Expand Up @@ -376,6 +376,8 @@ def expectation_pauli_tn_MPI(qibo_circ, datatype, pauli_string, n_samples=8):


def dense_vector_mps(qibo_circ, gate_algo, datatype):
"""Convert qibo circuit to matrix product state (MPS) format and perform contraction to dense vector.
"""
myconvertor = QiboCircuitToMPS(qibo_circ, gate_algo, dtype=datatype)
mps_helper = MPSContractionHelper(myconvertor.num_qubits)

Expand All @@ -384,17 +386,17 @@ def dense_vector_mps(qibo_circ, gate_algo, datatype):
)


def PauliStringGen(nqubits, pauli_string):
def pauli_string_gen(nqubits, pauli_string_pattern):
""" Used internally to generate the string based on given pattern and number of qubit.
Example: pattern: "XZ", number of qubit: 7, output = XZXZXZX
"""
if nqubits <= 0:
return "Invalid input. N should be a positive integer."

characters = pauli_string
# characters = "XXXZ"

result = ""

for i in range(nqubits):
char_to_add = characters[i % len(characters)]
char_to_add = pauli_string_pattern[i % len(pauli_string_pattern)]
result += char_to_add
print("pauli string", result)
return result

0 comments on commit 6f4ffa7

Please sign in to comment.