Add more documentation
This commit is contained in:
13
README.md
13
README.md
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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]
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user