feat: improve the configure_tn_simulation function so that we don't need to use external objects

This commit is contained in:
MatteoRobbiati
2025-02-10 16:45:26 +01:00
parent 5b63877876
commit 292d3573a6
2 changed files with 202 additions and 143 deletions

View File

@@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 2,
"id": "6722d94e-e311-48f9-b6df-c6d829bf67fb",
"metadata": {},
"outputs": [],
@@ -23,9 +23,7 @@
"\n",
"import qibo\n",
"from qibo import Circuit, gates, hamiltonians\n",
"from qibo.backends import construct_backend\n",
"\n",
"from qmatchatea import QCConvergenceParameters"
"from qibo.backends import construct_backend"
]
},
{
@@ -38,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 3,
"id": "64162116-1555-4a68-811c-01593739d622",
"metadata": {},
"outputs": [],
@@ -63,7 +61,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 4,
"id": "4a22a172-f50d-411d-afa3-fa61937c7b3a",
"metadata": {},
"outputs": [],
@@ -82,7 +80,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 5,
"id": "76f23c57-6d08-496b-9a27-52fb63bbfcb1",
"metadata": {},
"outputs": [
@@ -104,7 +102,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 6,
"id": "07b2c097-cea2-42ec-8f1d-b4bbb5b71d98",
"metadata": {},
"outputs": [],
@@ -127,18 +125,75 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 10,
"id": "34452bfd-2287-4b38-8099-e072239eab74",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mSignature:\u001b[0m\n",
"\u001b[0mqmatcha_backend\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconfigure_tn_simulation\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mansatz\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'MPS'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mmax_bond_dimension\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mint\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mcut_ratio\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mfloat\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1e-09\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mtrunc_tracking_mode\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'C'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0msvd_control\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mstr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'A'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mini_bond_dimension\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mint\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m\n",
"Configure TN simulation given Quantum Matcha Tea interface.\n",
"\n",
"Args:\n",
" ansatz (str): tensor network ansatz. It can be tree tensor network \"TTN\"\n",
" or Matrix Product States \"MPS\" (default).\n",
" max_bond_dimension : int, optional Maximum bond dimension of the problem. Default to 10.\n",
" cut_ratio : float, optional\n",
" Cut ratio for singular values. If :math:`\\lambda_n/\\lambda_1 <` cut_ratio then\n",
" :math:`\\lambda_n` is neglected. Default to 1e-9.\n",
" trunc_tracking_mode : str, optional\n",
" Modus for storing truncation, 'M' for maximum, 'C' for\n",
" cumulated (default).\n",
" svd_ctrl : character, optional\n",
" Control for the SVD algorithm. Available:\n",
" - \"A\" : automatic. Some heuristic is run to choose the best mode for the algorithm.\n",
" - \"V\" : gesvd. Safe but slow method.\n",
" - \"D\" : gesdd. Fast iterative method. It might fail. Resort to gesvd if it fails\n",
" - \"E\" : eigenvalue decomposition method. Faster on GPU. Available only when\n",
" contracting the singular value to left or right\n",
" - \"X\" : sparse eigenvalue decomposition method. Used when you reach the maximum\n",
" bond dimension.\n",
" - \"R\" : random svd method. Used when you reach the maximum bond dimension.\n",
" Default to 'A'.\n",
" ini_bond_dimension: int, optional\n",
" Initial bond dimension of the simulation. It is used if the initial state is random.\n",
" Default to 1.\n",
"\u001b[0;31mFile:\u001b[0m ~/Documents/PhD/qibotn/src/qibotn/backends/qmatchatea.py\n",
"\u001b[0;31mType:\u001b[0m method\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# And then call the dedicate configuration function\n",
"# which is especially written to match the QuantumMatchaTea requirements\n",
"qmatcha_backend.configure_tn_simulation?"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "2ee03e94-d794-4a51-9e76-01e8d8a259ba",
"metadata": {},
"outputs": [],
"source": [
"# We first define the useful objects \n",
"convergence_parameters = QCConvergenceParameters(cut_ratio=1e-6, max_bond_dimension=50)\n",
"\n",
"# And then call the dedicate configuration function\n",
"# Let's set a simple customization\n",
"qmatcha_backend.configure_tn_simulation(\n",
" convergence_params=convergence_parameters,\n",
" ansatz=\"MPS\",\n",
" max_bond_dimension=10,\n",
" cut_ratio=1e-6,\n",
")"
]
},
@@ -157,7 +212,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 14,
"id": "221ef886-5578-4200-a019-dcafa51aada3",
"metadata": {},
"outputs": [
@@ -220,31 +275,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"id": "f271d3f3-c7f2-49b3-94e2-d6e843a169d0",
"metadata": {},
"outputs": [],
"source": [
"circuit = build_circuit(nqubits=4, nlayers=2)\n",
"\n",
"# Setting random parameters\n",
"circuit.set_parameters(\n",
" parameters=np.random.uniform(-np.pi, np.pi, len(circuit.get_parameters())),\n",
")\n",
"\n",
"# We first define the useful objects \n",
"convergence_parameters = QCConvergenceParameters(cut_ratio=1e-12, max_bond_dimension=1100)\n",
"\n",
"# And then call the dedicate configuration function\n",
"qmatcha_backend.configure_tn_simulation(\n",
" convergence_params=convergence_parameters,\n",
" ansatz=\"MPS\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 17,
"id": "35a244c3-adba-4b8b-b28c-0ab592b0f7cf",
"metadata": {},
"outputs": [
@@ -254,36 +285,36 @@
"{'nqubits': 4,\n",
" 'backend': QMatchaTeaBackend(),\n",
" 'measures': None,\n",
" 'measured_probabilities': {'U': {'0000': (0.0, 0.06042361322153613),\n",
" '0001': (0.06042361322153613, 0.16103484648184754),\n",
" '0010': (0.1610348464818476, 0.3885436985884956),\n",
" '0011': (0.3885436985884956, 0.4596882048691001),\n",
" '0100': (0.4596882048691, 0.46449216980829905),\n",
" '0101': (0.46449216980829905, 0.47672801247815266),\n",
" '0110': (0.47672801247815266, 0.5016979158974251),\n",
" '0111': (0.5016979158974251, 0.5398303779135739),\n",
" '1000': (0.539830377913574, 0.6539396910265846),\n",
" '1001': (0.6539396910265846, 0.7584098289087688),\n",
" '1010': (0.7584098289087688, 0.7781986778747929),\n",
" '1011': (0.7781986778747929, 0.8661307878495997),\n",
" '1100': (0.8661307878495996, 0.8908084103632258),\n",
" '1101': (0.8908084103632258, 0.9107085647613623),\n",
" '1110': (0.9107085647613623, 0.9481703292728131),\n",
" '1111': (0.9481703292728131, 0.9999999999999999)},\n",
" 'measured_probabilities': {'U': {'0000': (0.0, 0.009075021799813076),\n",
" '0001': (0.009075021799813076, 0.013505513590974613),\n",
" '0010': (0.01350551359097461, 0.03969337383808732),\n",
" '0011': (0.03969337383808732, 0.3501239760030636),\n",
" '0100': (0.3501239760030635, 0.3525850615313512),\n",
" '0101': (0.3525850615313512, 0.37831917247243874),\n",
" '0110': (0.37831917247243874, 0.5888353440545037),\n",
" '0111': (0.5888353440545037, 0.5934703289984129),\n",
" '1000': (0.5934703289984128, 0.6896713158046865),\n",
" '1001': (0.6896713158046865, 0.7110042815132214),\n",
" '1010': (0.7110042815132213, 0.7242989335460854),\n",
" '1011': (0.7242989335460854, 0.7640693817193864),\n",
" '1100': (0.7640693817193864, 0.7641799598480784),\n",
" '1101': (0.7641799598480784, 0.9530705920006985),\n",
" '1110': (0.9530705920006985, 0.989871146703016),\n",
" '1111': (0.989871146703016, 1.0000000000000002)},\n",
" 'E': [None],\n",
" 'G': [None]},\n",
" 'prob_type': 'U',\n",
" 'statevector': array([-0.13931487-0.20252155j, -0.21974897+0.25655351j,\n",
" 0.02884164-0.06302479j, -0.15237615+0.03819857j,\n",
" -0.3172761 -0.35615268j, -0.10121749+0.09769272j,\n",
" 0.14826026-0.0546699j , -0.1814861 -0.06726486j,\n",
" -0.10907416+0.29784906j, 0.30276076+0.11316387j,\n",
" 0.07771728+0.07871383j, -0.12379363+0.0676409j ,\n",
" -0.21860099+0.15283362j, 0.06862868+0.28848261j,\n",
" -0.04640848-0.18968056j, -0.22262942-0.04760056j])}"
" 'statevector': array([-0.0381929 -0.08727155j, -0.25811667+0.17197899j,\n",
" -0.04960402-0.00072563j, 0.00323629-0.01000523j,\n",
" 0.0625107 +0.14926578j, -0.11530027-0.00070762j,\n",
" -0.35885958-0.28589503j, -0.08233943+0.17326504j,\n",
" 0.06345512-0.02009824j, 0.03609859+0.14152688j,\n",
" -0.11045046+0.11633919j, -0.27587224+0.33583499j,\n",
" 0.46347251+0.30923103j, 0.02322259-0.19806857j,\n",
" -0.00893755+0.06749152j, -0.07071717-0.0716096j ])}"
]
},
"execution_count": 23,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -298,7 +329,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 19,
"id": "60501c3d-2a44-421f-b434-4a508714b132",
"metadata": {},
"outputs": [
@@ -310,24 +341,24 @@
" 'measures': None,\n",
" 'measured_probabilities': {'U': [None],\n",
" 'E': [None],\n",
" 'G': {'0010': 0.227508852106648,\n",
" '0011': 0.07114450628060452,\n",
" '1000': 0.227508852106648,\n",
" '1001': 0.07114450628060452,\n",
" '0000': 0.06042361322153613,\n",
" '0001': 0.1006112332603114}},\n",
" 'G': {'0010': 0.02618786024711271,\n",
" '0011': 0.3104306021649763,\n",
" '1100': 0.00011057812869196484,\n",
" '1101': 0.18889063215262014,\n",
" '0110': 0.21051617158206493,\n",
" '0111': 0.0046349849439092155}},\n",
" 'prob_type': 'G',\n",
" 'statevector': array([-0.13931487-0.20252155j, -0.21974897+0.25655351j,\n",
" 0.02884164-0.06302479j, -0.15237615+0.03819857j,\n",
" -0.3172761 -0.35615268j, -0.10121749+0.09769272j,\n",
" 0.14826026-0.0546699j , -0.1814861 -0.06726486j,\n",
" -0.10907416+0.29784906j, 0.30276076+0.11316387j,\n",
" 0.07771728+0.07871383j, -0.12379363+0.0676409j ,\n",
" -0.21860099+0.15283362j, 0.06862868+0.28848261j,\n",
" -0.04640848-0.18968056j, -0.22262942-0.04760056j])}"
" 'statevector': array([-0.0381929 -0.08727155j, -0.25811667+0.17197899j,\n",
" -0.04960402-0.00072563j, 0.00323629-0.01000523j,\n",
" 0.0625107 +0.14926578j, -0.11530027-0.00070762j,\n",
" -0.35885958-0.28589503j, -0.08233943+0.17326504j,\n",
" 0.06345512-0.02009824j, 0.03609859+0.14152688j,\n",
" -0.11045046+0.11633919j, -0.27587224+0.33583499j,\n",
" 0.46347251+0.30923103j, 0.02322259-0.19806857j,\n",
" -0.00893755+0.06749152j, -0.07071717-0.0716096j ])}"
]
},
"execution_count": 26,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -338,7 +369,7 @@
"outcome = qmatcha_backend.execute_circuit(\n",
" circuit=circuit,\n",
" prob_type=\"G\",\n",
" prob_threshold=0.9,\n",
" prob_threshold=0.7,\n",
" return_array=True,\n",
")\n",
"\n",
@@ -358,7 +389,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 20,
"id": "c0443efc-21ef-4ed5-9cf4-785d204a1881",
"metadata": {},
"outputs": [
@@ -367,15 +398,16 @@
"output_type": "stream",
"text": [
"Probabilities:\n",
" [0.22750885 0.07114451 0.22750885 0.07114451 0.06042361 0.10061123]\n",
" [2.61878602e-02 3.10430602e-01 1.10578129e-04 1.88890632e-01\n",
" 2.10516172e-01 4.63498494e-03]\n",
"\n",
"State:\n",
" [-0.13931487-0.20252155j -0.21974897+0.25655351j 0.02884164-0.06302479j\n",
" -0.15237615+0.03819857j -0.3172761 -0.35615268j -0.10121749+0.09769272j\n",
" 0.14826026-0.0546699j -0.1814861 -0.06726486j -0.10907416+0.29784906j\n",
" 0.30276076+0.11316387j 0.07771728+0.07871383j -0.12379363+0.0676409j\n",
" -0.21860099+0.15283362j 0.06862868+0.28848261j -0.04640848-0.18968056j\n",
" -0.22262942-0.04760056j]\n",
" [-0.0381929 -0.08727155j -0.25811667+0.17197899j -0.04960402-0.00072563j\n",
" 0.00323629-0.01000523j 0.0625107 +0.14926578j -0.11530027-0.00070762j\n",
" -0.35885958-0.28589503j -0.08233943+0.17326504j 0.06345512-0.02009824j\n",
" 0.03609859+0.14152688j -0.11045046+0.11633919j -0.27587224+0.33583499j\n",
" 0.46347251+0.30923103j 0.02322259-0.19806857j -0.00893755+0.06749152j\n",
" -0.07071717-0.0716096j ]\n",
"\n"
]
}
@@ -397,7 +429,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 21,
"id": "8a868f3e-8383-47ee-a93a-27c5f85e48c5",
"metadata": {},
"outputs": [],
@@ -417,7 +449,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 22,
"id": "68122cd3-662f-4fd1-bb9c-d33b6f5448dd",
"metadata": {},
"outputs": [
@@ -426,37 +458,33 @@
"text/plain": [
"{'nqubits': 4,\n",
" 'backend': QMatchaTeaBackend(),\n",
" 'measures': {'0000': 75,\n",
" '0001': 113,\n",
" '0010': 202,\n",
" '0011': 59,\n",
" '0100': 9,\n",
" '0101': 14,\n",
" '0110': 30,\n",
" '0111': 37,\n",
" '1000': 130,\n",
" '1001': 113,\n",
" '1010': 19,\n",
" '1011': 95,\n",
" '1100': 19,\n",
" '1101': 26,\n",
" '1110': 39,\n",
" '1111': 44},\n",
" 'measures': {'0000': 12,\n",
" '0001': 5,\n",
" '0010': 20,\n",
" '0011': 307,\n",
" '0100': 5,\n",
" '0101': 35,\n",
" '0110': 207,\n",
" '0111': 4,\n",
" '1000': 107,\n",
" '1001': 19,\n",
" '1010': 11,\n",
" '1011': 41,\n",
" '1100': 1,\n",
" '1101': 199,\n",
" '1110': 37,\n",
" '1111': 14},\n",
" 'measured_probabilities': {'U': [None],\n",
" 'E': {'0000': 0.06042361322153613,\n",
" '0001': 0.1006112332603114,\n",
" '0010': 0.227508852106648,\n",
" '0011': 0.07114450628060452,\n",
" '1000': 0.11410931311301056,\n",
" '1001': 0.10447013788218423,\n",
" '1011': 0.08793210997480687,\n",
" '1111': 0.05182967072718676},\n",
" 'E': {'0011': 0.3104306021649763,\n",
" '0110': 0.21051617158206493,\n",
" '1000': 0.09620098680627374,\n",
" '1101': 0.18889063215262014},\n",
" 'G': [None]},\n",
" 'prob_type': 'E',\n",
" 'statevector': None}"
]
},
"execution_count": 29,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -477,7 +505,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 23,
"id": "ef0e9591-ccca-4cdd-a81b-2bfb3caaf3d0",
"metadata": {},
"outputs": [
@@ -486,7 +514,7 @@
"output_type": "stream",
"text": [
"Frequencies:\n",
" {'0000': 75, '0001': 113, '0010': 202, '0011': 59, '0100': 9, '0101': 14, '0110': 30, '0111': 37, '1000': 130, '1001': 113, '1010': 19, '1011': 95, '1100': 19, '1101': 26, '1110': 39, '1111': 44}\n",
" {'0000': 12, '0001': 5, '0010': 20, '0011': 307, '0100': 5, '0101': 35, '0110': 207, '0111': 4, '1000': 107, '1001': 19, '1010': 11, '1011': 41, '1100': 1, '1101': 199, '1110': 37, '1111': 14}\n",
"\n"
]
}
@@ -506,7 +534,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 24,
"id": "9e9632d5-28dd-4846-8457-c579d0cb9453",
"metadata": {},
"outputs": [],
@@ -574,7 +602,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 25,
"id": "5620f476-1bc7-4cf8-9868-b127c715b6ec",
"metadata": {},
"outputs": [],
@@ -593,7 +621,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 26,
"id": "32d605e9-672a-40b6-8a1a-eb17bbc3c45e",
"metadata": {},
"outputs": [
@@ -632,7 +660,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 27,
"id": "0b46e315-7786-4247-bd2a-83ea1c5842eb",
"metadata": {},
"outputs": [],
@@ -642,7 +670,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 28,
"id": "37385485-e8a3-4ab0-ad44-bcc4e9da24ca",
"metadata": {},
"outputs": [
@@ -669,10 +697,18 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 29,
"id": "ddecc910-7804-4199-8577-a7db38a16db8",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[Qibo 0.2.15|INFO|2025-02-10 16:44:30]: Using qibojit (numba) backend on /CPU:0\n"
]
}
],
"source": [
"# We can create an Hamiltonian form\n",
"form = 0.5 * Z(0) * Z(1) +- 1.5 * X(0) * Z(2) + Z(3)\n",
@@ -681,7 +717,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 30,
"id": "a6599df3-989e-4131-8664-3451d0cc4372",
"metadata": {},
"outputs": [
@@ -724,17 +760,17 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 31,
"id": "163b70a3-814a-4a62-a98a-2ffca933a544",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-0.27540575238693377"
"-0.21133814688683614"
]
},
"execution_count": 38,
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
@@ -748,17 +784,17 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 32,
"id": "2d8c4a9c-eca3-49d0-bdbf-ab054172c4e5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-0.275405752386936"
"-0.2113381468868367"
]
},
"execution_count": 39,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}

View File

@@ -30,23 +30,46 @@ class QMatchaTeaBackend(QibotnBackend, NumpyBackend):
def configure_tn_simulation(
self,
ansatz: str = "MPS",
convergence_params=None,
max_bond_dimension: int = 10,
cut_ratio: float = 1e-9,
trunc_tracking_mode: str = "C",
svd_control: str = "A",
ini_bond_dimension: int = 1,
):
"""Configure TN simulation given Quantum Matcha Tea interface.
Args:
ansatz (str): tensor network ansatz. It can be tree tensor network "TTN"
or Matrix Product States "MPS" (default).
convergence_params (qmatchatea.utils.QCConvergenceParameters):
convergence parameters class adapted to the quantum computing
execution. See https://baltig.infn.it/quantum_matcha_tea/py_api_quantum_matcha_tea/-/blob/master/qmatchatea/utils/utils.py?ref_type=heads#L540
for more instructions. If not passed, the default values proposed
by Quantum Matcha Tea's authors are set.
max_bond_dimension : int, optional Maximum bond dimension of the problem. Default to 10.
cut_ratio : float, optional
Cut ratio for singular values. If :math:`\\lambda_n/\\lambda_1 <` cut_ratio then
:math:`\\lambda_n` is neglected. Default to 1e-9.
trunc_tracking_mode : str, optional
Modus for storing truncation, 'M' for maximum, 'C' for
cumulated (default).
svd_ctrl : character, optional
Control for the SVD algorithm. Available:
- "A" : automatic. Some heuristic is run to choose the best mode for the algorithm.
- "V" : gesvd. Safe but slow method.
- "D" : gesdd. Fast iterative method. It might fail. Resort to gesvd if it fails
- "E" : eigenvalue decomposition method. Faster on GPU. Available only when
contracting the singular value to left or right
- "X" : sparse eigenvalue decomposition method. Used when you reach the maximum
bond dimension.
- "R" : random svd method. Used when you reach the maximum bond dimension.
Default to 'A'.
ini_bond_dimension: int, optional
Initial bond dimension of the simulation. It is used if the initial state is random.
Default to 1.
"""
# Set configurations or defaults
self.convergence_params = (
convergence_params or qmatchatea.QCConvergenceParameters()
self.convergence_params = qmatchatea.QCConvergenceParameters(
max_bond_dimension=max_bond_dimension,
cut_ratio=cut_ratio,
trunc_tracking_mode=trunc_tracking_mode,
svd_ctrl=svd_control,
ini_bond_dimension=ini_bond_dimension,
)
self.ansatz = ansatz