Approximate/compressed contraction

In this example we use cotengra to find a ‘compressed’ contraction tree (as detailed in 2206.07044) for a \(10\times10\times10\) tensor network representation of the partition function of the 3D classical ising model. We then use quimb to actually perform the compressed contraction.

%config InlineBackend.figure_formats = ['svg']
import cotengra as ctg
import quimb.tensor as qtn

First we get the tensor network from quimb, though note we could also specify it as usual via inputs, output and size_dict.

tn = qtn.TN3D_classical_ising_partition_function(
    10, 10, 10, beta=0.3
)

Then we set-up our compressed contraction tree finder:

chi = 16
copt = ctg.ReusableHyperCompressedOptimizer(
    chi,
    max_repeats=256,
    minimize='combo-compressed', 
    progbar=True,
    # # save paths to disk:
    # directory=True  
)

quimb knows about cotengra and will directly return the ContractionTreeCompressed generated during the search:

tree = tn.contraction_tree(copt)
log2[SIZE]: 21.00 log10[FLOPs]: 10.89: 100%|████████████████████████| 256/256 [00:15<00:00, 16.02it/s]

We can perform various bits of introspection on both the compressed contraction tree and optimizer now before we actually perform the contraction.

copt.last_opt.plot_trials()
../_images/ae3563da3e7100c0d9554f1682505a4d2511878af8e1cf92a3eb02fad15284a7.svg
(<Figure size 800x300 with 1 Axes>, <Axes: xlabel='TRIAL', ylabel='SCORE'>)

We can see that the best tree was generated with the Span algorithm, so we can visualize the actual spanning tree like so:

tree.plot_span(
    node_max_size=1, 
    edge_max_width=1, 
    edge_color='order', 
    node_color='order',
    edge_colormap='Spectral_r',
    node_colormap='Spectral_r',
    colorbars=False,
)
../_images/2f6c8fde7b82a1994bae2f283063c13d14f45dd8cf683bfd71ae1fd6c675ee4d.svg
(<Figure size 500x500 with 1 Axes>, <Axes: >)

Here we optionally convert to GPU arrays to make the contraction (much) quicker:

def to_backend(x):
    import torch

    return torch.tensor(x, dtype=torch.float32, device='cuda')

tn.apply_to_arrays(to_backend)

Now we actually perform the contraction, this requires a lot of machinery that only quimb can provide currently, so we just need to supply either the raw path or optimizer to the following method:

tn.contract_compressed_(
    optimize=tree.get_path(),  # or optimize=copt
    max_bond=chi,
    equalize_norms=1.0,
    progbar=True,
)
log2[SIZE]: 0.00/21.00: 100%|███████████████████████████████████████| 999/999 [00:11<00:00, 90.42it/s]
TensorNetwork3D(tensors=1, indices=0, Lx=10, Ly=10, Lz=10, max_bond=1)
Tensor(shape=(), inds=[], tags={I9,0,9, X9, Y0, Z9, I9,1,9, Y1, I9,2,9, Y2, I9,3,9, Y3, I9,4,9, Y4, I9,5,9, Y5, I9,6,9, Y6, I9,7,9, Y7, I9,8,9, Y8, I9,9,9, Y9, I9,0,8, Z8, I9,1,8, I9,2,8, I9,3,8, I9,4,8, I9,5,8, I9,6,8, I9,7,8, I9,8,8, I9,9,8, I9,0,7, Z7, I9,1,7, I9,2,7, I9,3,7, I9,4,7, I9,5,7, I9,6,7, I9,7,7, I9,8,7, I9,9,7, I9,0,6, Z6, I9,1,6, I9,2,6, I9,3,6, I9,4,6, I9,5,6, I9,6,6, I9,7,6, I9,8,6, I9,9,6, I9,0,5, Z5, I9,1,5, I9,2,5, I9,3,5, I9,4,5, I9,5,5, I9,6,5, I9,7,5, I9,8,5, I9,9,5, I9,0,4, Z4, I9,1,4, I9,2,4, I9,3,4, I9,4,4, I9,5,4, I9,6,4, I9,7,4, I9,8,4, I9,9,4, I9,0,3, Z3, I9,1,3, I9,2,3, I9,3,3, I9,4,3, I9,5,3, I9,6,3, I9,7,3, I9,8,3, I9,9,3, I9,0,2, Z2, I9,1,2, I9,2,2, I9,3,2, I9,4,2, I9,5,2, I9,6,2, I9,7,2, I9,8,2, I9,9,2, I9,0,1, Z1, I9,1,1, I9,2,1, I9,3,1, I9,4,1, I9,5,1, I9,6,1, I9,7,1, I9,8,1, I9,9,1, I9,0,0, Z0, I9,1,0, I9,2,0, I9,3,0, I9,4,0, I9,5,0, I9,6,0, I9,7,0, I9,8,0, I9,9,0, I8,0,9, X8, I8,1,9, I8,2,9, I8,3,9, I8,4,9, I8,5,9, I8,6,9, I8,7,9, I8,8,9, I8,9,9, I8,0,8, I8,1,8, I8,2,8, I8,3,8, I8,4,8, I8,5,8, I8,6,8, I8,7,8, I8,8,8, I8,9,8, I8,0,7, I8,1,7, I8,2,7, I8,3,7, I8,4,7, I8,5,7, I8,6,7, I8,7,7, I8,8,7, I8,9,7, I8,0,6, I8,1,6, I8,2,6, I8,3,6, I8,4,6, I8,5,6, I8,6,6, I8,7,6, I8,8,6, I8,9,6, I8,0,5, I8,1,5, I8,2,5, I8,3,5, I8,4,5, I8,5,5, I8,6,5, I8,7,5, I8,8,5, I8,9,5, I8,0,4, I8,1,4, I8,2,4, I8,3,4, I8,4,4, I8,5,4, I8,6,4, I8,7,4, I8,8,4, I8,9,4, I8,0,3, I8,1,3, I8,2,3, I8,3,3, I8,4,3, I8,5,3, I8,6,3, I8,7,3, I8,8,3, I8,9,3, I8,0,2, I8,1,2, I8,2,2, I8,3,2, I8,4,2, I8,5,2, I8,6,2, I8,7,2, I8,8,2, I8,9,2, I8,0,1, I8,1,1, I8,2,1, I8,3,1, I8,4,1, I8,5,1, I8,6,1, I8,7,1, I8,8,1, I8,9,1, I8,0,0, I8,1,0, I8,2,0, I8,3,0, I8,4,0, I8,5,0, I8,6,0, I8,7,0, I8,8,0, I8,9,0, I7,0,9, X7, I7,1,9, I7,2,9, I7,3,9, I7,4,9, I7,5,9, I7,6,9, I7,7,9, I7,8,9, I7,9,9, I7,0,8, I7,1,8, I7,2,8, I7,3,8, I7,4,8, I7,5,8, I7,6,8, I7,7,8, I7,8,8, I7,9,8, I7,0,7, I7,1,7, I7,2,7, I7,3,7, I7,4,7, I7,5,7, I7,6,7, I7,7,7, I7,8,7, I7,9,7, I7,0,6, I7,1,6, I7,2,6, I7,3,6, I7,4,6, I7,5,6, I7,6,6, I7,7,6, I7,8,6, I7,9,6, I7,0,5, I7,1,5, I7,2,5, I7,3,5, I7,4,5, I7,5,5, I7,6,5, I7,7,5, I7,8,5, I7,9,5, I7,0,4, I7,1,4, I7,2,4, I7,3,4, I7,4,4, I7,5,4, I7,6,4, I7,7,4, I7,8,4, I7,9,4, I7,0,3, I7,1,3, I7,2,3, I7,3,3, I7,4,3, I7,5,3, I7,6,3, I7,7,3, I7,8,3, I7,9,3, I7,0,2, I7,1,2, I7,2,2, I7,3,2, I7,4,2, I7,5,2, I7,6,2, I7,7,2, I7,8,2, I7,9,2, I7,0,1, I7,1,1, I7,2,1, I7,3,1, I7,4,1, I7,5,1, I7,6,1, I7,7,1, I7,8,1, I7,9,1, I7,0,0, I7,1,0, I7,2,0, I7,3,0, I7,4,0, I7,5,0, I7,6,0, I7,7,0, I7,8,0, I7,9,0, I6,0,9, X6, I6,1,9, I6,2,9, I6,3,9, I6,4,9, I6,5,9, I6,6,9, I6,7,9, I6,8,9, I6,9,9, I6,0,8, I6,1,8, I6,2,8, I6,3,8, I6,4,8, I6,5,8, I6,6,8, I6,7,8, I6,8,8, I6,9,8, I6,0,7, I6,1,7, I6,2,7, I6,3,7, I6,4,7, I6,5,7, I6,6,7, I6,7,7, I6,8,7, I6,9,7, I6,0,6, I6,1,6, I6,2,6, I6,3,6, I6,4,6, I6,5,6, I6,6,6, I6,7,6, I6,8,6, I6,9,6, I6,0,5, I6,1,5, I6,2,5, I6,3,5, I6,4,5, I6,5,5, I6,6,5, I6,7,5, I6,8,5, I6,9,5, I6,0,4, I6,1,4, I6,2,4, I6,3,4, I6,4,4, I6,5,4, I6,6,4, I6,7,4, I6,8,4, I6,9,4, I6,0,3, I6,1,3, I6,2,3, I6,3,3, I6,4,3, I6,5,3, I6,6,3, I6,7,3, I6,8,3, I6,9,3, I6,0,2, I6,1,2, I6,2,2, I6,3,2, I6,4,2, I6,5,2, I6,6,2, I6,7,2, I6,8,2, I6,9,2, I6,0,1, I6,1,1, I6,2,1, I6,3,1, I6,4,1, I6,5,1, I6,6,1, I6,7,1, I6,8,1, I6,9,1, I6,0,0, I6,1,0, I6,2,0, I6,3,0, I6,4,0, I6,5,0, I6,6,0, I6,7,0, I6,8,0, I6,9,0, I5,0,9, X5, I5,1,9, I5,2,9, I5,3,9, I5,4,9, I5,5,9, I5,6,9, I5,7,9, I5,8,9, I5,9,9, I5,0,8, I5,1,8, I5,2,8, I5,3,8, I5,4,8, I5,5,8, I5,6,8, I5,7,8, I5,8,8, I5,9,8, I5,0,7, I5,1,7, I5,2,7, I5,3,7, I5,4,7, I5,5,7, I5,6,7, I5,7,7, I5,8,7, I5,9,7, I5,0,6, I5,1,6, I5,2,6, I5,3,6, I5,4,6, I5,5,6, I5,6,6, I5,7,6, I5,8,6, I5,9,6, I5,0,5, I5,1,5, I5,2,5, I5,3,5, I5,4,5, I5,5,5, I5,6,5, I5,7,5, I5,8,5, I5,9,5, I5,0,4, I5,1,4, I5,2,4, I5,3,4, I5,4,4, I5,5,4, I5,6,4, I5,7,4, I5,8,4, I5,9,4, I5,0,3, I5,1,3, I5,2,3, I5,3,3, I5,4,3, I5,5,3, I5,6,3, I5,7,3, I5,8,3, I5,9,3, I5,0,2, I5,1,2, I5,2,2, I5,3,2, I5,4,2, I5,5,2, I5,6,2, I5,7,2, I5,8,2, I5,9,2, I5,0,1, I5,1,1, I5,2,1, I5,3,1, I5,4,1, I5,5,1, I5,6,1, I5,7,1, I5,8,1, I5,9,1, I5,0,0, I5,1,0, I5,2,0, I5,3,0, I5,4,0, I5,5,0, I5,6,0, I5,7,0, I5,8,0, I5,9,0, I4,0,9, X4, I4,1,9, I4,2,9, I4,3,9, I4,4,9, I4,5,9, I4,6,9, I4,7,9, I4,8,9, I4,9,9, I4,0,8, I4,1,8, I4,2,8, I4,3,8, I4,4,8, I4,5,8, I4,6,8, I4,7,8, I4,8,8, I4,9,8, I4,0,7, I4,1,7, I4,2,7, I4,3,7, I4,4,7, I4,5,7, I4,6,7, I4,7,7, I4,8,7, I4,9,7, I4,0,6, I4,1,6, I4,2,6, I4,3,6, I4,4,6, I4,5,6, I4,6,6, I4,7,6, I4,8,6, I4,9,6, I4,0,5, I4,1,5, I4,2,5, I4,3,5, I4,4,5, I4,5,5, I4,6,5, I4,7,5, I4,8,5, I4,9,5, I4,0,4, I4,1,4, I4,2,4, I4,3,4, I4,4,4, I4,5,4, I4,6,4, I4,7,4, I4,8,4, I4,9,4, I4,0,3, I4,1,3, I4,2,3, I4,3,3, I4,4,3, I4,5,3, I4,6,3, I4,7,3, I4,8,3, I4,9,3, I4,0,2, I4,1,2, I4,2,2, I4,3,2, I4,4,2, I4,5,2, I4,6,2, I4,7,2, I4,8,2, I4,9,2, I4,0,1, I4,1,1, I4,2,1, I4,3,1, I4,4,1, I4,5,1, I4,6,1, I4,7,1, I4,8,1, I4,9,1, I4,0,0, I4,1,0, I4,2,0, I4,3,0, I4,4,0, I4,5,0, I4,6,0, I4,7,0, I4,8,0, I4,9,0, I3,0,9, X3, I3,1,9, I3,2,9, I3,3,9, I3,4,9, I3,5,9, I3,6,9, I3,7,9, I3,8,9, I3,9,9, I3,0,8, I3,1,8, I3,2,8, I3,3,8, I3,4,8, I3,5,8, I3,6,8, I3,7,8, I3,8,8, I3,9,8, I3,0,7, I3,1,7, I3,2,7, I3,3,7, I3,4,7, I3,5,7, I3,6,7, I3,7,7, I3,8,7, I3,9,7, I3,0,6, I3,1,6, I3,2,6, I3,3,6, I3,4,6, I3,5,6, I3,6,6, I3,7,6, I3,8,6, I3,9,6, I3,0,5, I3,1,5, I3,2,5, I3,3,5, I3,4,5, I3,5,5, I3,6,5, I3,7,5, I3,8,5, I3,9,5, I3,0,4, I3,1,4, I3,2,4, I3,3,4, I3,4,4, I3,5,4, I3,6,4, I3,7,4, I3,8,4, I3,9,4, I3,0,3, I3,1,3, I3,2,3, I3,3,3, I3,4,3, I3,5,3, I3,6,3, I3,7,3, I3,8,3, I3,9,3, I3,0,2, I3,1,2, I3,2,2, I3,3,2, I3,4,2, I3,5,2, I3,6,2, I3,7,2, I3,8,2, I3,9,2, I3,0,1, I3,1,1, I3,2,1, I3,3,1, I3,4,1, I3,5,1, I3,6,1, I3,7,1, I3,8,1, I3,9,1, I3,0,0, I3,1,0, I3,2,0, I3,3,0, I3,4,0, I3,5,0, I3,6,0, I3,7,0, I3,8,0, I3,9,0, I2,0,9, X2, I2,1,9, I2,2,9, I2,3,9, I2,4,9, I2,5,9, I2,6,9, I2,7,9, I2,8,9, I2,9,9, I2,0,8, I2,1,8, I2,2,8, I2,3,8, I2,4,8, I2,5,8, I2,6,8, I2,7,8, I2,8,8, I2,9,8, I2,0,7, I2,1,7, I2,2,7, I2,3,7, I2,4,7, I2,5,7, I2,6,7, I2,7,7, I2,8,7, I2,9,7, I2,0,6, I2,1,6, I2,2,6, I2,3,6, I2,4,6, I2,5,6, I2,6,6, I2,7,6, I2,8,6, I2,9,6, I2,0,5, I2,1,5, I2,2,5, I2,3,5, I2,4,5, I2,5,5, I2,6,5, I2,7,5, I2,8,5, I2,9,5, I2,0,4, I2,1,4, I2,2,4, I2,3,4, I2,4,4, I2,5,4, I2,6,4, I2,7,4, I2,8,4, I2,9,4, I2,0,3, I2,1,3, I2,2,3, I2,3,3, I2,4,3, I2,5,3, I2,6,3, I2,7,3, I2,8,3, I2,9,3, I2,0,2, I2,1,2, I2,2,2, I2,3,2, I2,4,2, I2,5,2, I2,6,2, I2,7,2, I2,8,2, I2,9,2, I2,0,1, I2,1,1, I2,2,1, I2,3,1, I2,4,1, I2,5,1, I2,6,1, I2,7,1, I2,8,1, I2,9,1, I2,0,0, I2,1,0, I2,2,0, I2,3,0, I2,4,0, I2,5,0, I2,6,0, I2,7,0, I2,8,0, I2,9,0, I1,0,9, X1, I1,1,9, I1,2,9, I1,3,9, I1,4,9, I1,5,9, I1,6,9, I1,7,9, I1,8,9, I1,9,9, I1,0,8, I1,1,8, I1,2,8, I1,3,8, I1,4,8, I1,5,8, I1,6,8, I1,7,8, I1,8,8, I1,9,8, I1,0,7, I1,1,7, I1,2,7, I1,3,7, I1,4,7, I1,5,7, I1,6,7, I1,7,7, I1,8,7, I1,9,7, I1,0,6, I1,1,6, I1,2,6, I1,3,6, I1,4,6, I1,5,6, I1,6,6, I1,7,6, I1,8,6, I1,9,6, I1,0,5, I1,1,5, I1,2,5, I1,3,5, I1,4,5, I1,5,5, I1,6,5, I1,7,5, I1,8,5, I1,9,5, I1,0,4, I1,1,4, I1,2,4, I1,3,4, I1,4,4, I1,5,4, I1,6,4, I1,7,4, I1,8,4, I1,9,4, I1,0,3, I1,1,3, I1,2,3, I1,3,3, I1,4,3, I1,5,3, I1,6,3, I1,7,3, I1,8,3, I1,9,3, I1,0,2, I1,1,2, I1,2,2, I1,3,2, I1,4,2, I1,5,2, I1,6,2, I1,7,2, I1,8,2, I1,9,2, I1,0,1, I1,1,1, I1,2,1, I1,3,1, I1,4,1, I1,5,1, I1,6,1, I1,7,1, I1,8,1, I1,9,1, I1,0,0, I1,1,0, I1,2,0, I1,3,0, I1,4,0, I1,5,0, I1,6,0, I1,7,0, I1,8,0, I1,9,0, I0,0,9, X0, I0,1,9, I0,2,9, I0,3,9, I0,4,9, I0,5,9, I0,6,9, I0,7,9, I0,8,9, I0,9,9, I0,0,8, I0,1,8, I0,2,8, I0,3,8, I0,4,8, I0,5,8, I0,6,8, I0,7,8, I0,8,8, I0,9,8, I0,0,7, I0,1,7, I0,2,7, I0,3,7, I0,4,7, I0,5,7, I0,6,7, I0,7,7, I0,8,7, I0,9,7, I0,0,6, I0,1,6, I0,2,6, I0,3,6, I0,4,6, I0,5,6, I0,6,6, I0,7,6, I0,8,6, I0,9,6, I0,0,5, I0,1,5, I0,2,5, I0,3,5, I0,4,5, I0,5,5, I0,6,5, I0,7,5, I0,8,5, I0,9,5, I0,0,4, I0,1,4, I0,2,4, I0,3,4, I0,4,4, I0,5,4, I0,6,4, I0,7,4, I0,8,4, I0,9,4, I0,0,3, I0,1,3, I0,2,3, I0,3,3, I0,4,3, I0,5,3, I0,6,3, I0,7,3, I0,8,3, I0,9,3, I0,0,2, I0,1,2, I0,2,2, I0,3,2, I0,4,2, I0,5,2, I0,6,2, I0,7,2, I0,8,2, I0,9,2, I0,0,1, I0,1,1, I0,2,1, I0,3,1, I0,4,1, I0,5,1, I0,6,1, I0,7,1, I0,8,1, I0,9,1, I0,0,0, I0,1,0, I0,2,0, I0,3,0, I0,4,0, I0,5,0, I0,6,0, I0,7,0, I0,8,0, I0,9,0}),backend=torch, dtype=torch.float32, data=tensor(1., device='cuda:0')

Note becuase its a large contraction, we perform in inplace and accumulate the norms of all intermediate tensors into tn.exponent.

mantissa, exponent = (tn.contract(), tn.exponent)
mantissa, exponent
(tensor(1., device='cuda:0'), tensor(379.5602, device='cuda:0'))

So our final partition function is \(Z=1\times10^{379.5602}\).

If we just change the entries of the tensor network (and not the actual geometry) then we can reuse the same path or optimizer. For example here we just change the inverse temperature of the model, \(\beta\):

tn = qtn.TN3D_classical_ising_partition_function(
    10, 10, 10, beta=0.25
)
tn.apply_to_arrays(to_backend)
tn.contract_compressed_(
    optimize=copt,  # here we demonstrate the cache of the optimizer
    max_bond=chi,
    equalize_norms=1.0,
    progbar=True,
)
log2[SIZE]: 0.00/21.00: 100%|███████████████████████████████████████| 999/999 [00:10<00:00, 91.62it/s]
TensorNetwork3D(tensors=1, indices=0, Lx=10, Ly=10, Lz=10, max_bond=1)
Tensor(shape=(), inds=[], tags={I9,0,9, X9, Y0, Z9, I9,1,9, Y1, I9,2,9, Y2, I9,3,9, Y3, I9,4,9, Y4, I9,5,9, Y5, I9,6,9, Y6, I9,7,9, Y7, I9,8,9, Y8, I9,9,9, Y9, I9,0,8, Z8, I9,1,8, I9,2,8, I9,3,8, I9,4,8, I9,5,8, I9,6,8, I9,7,8, I9,8,8, I9,9,8, I9,0,7, Z7, I9,1,7, I9,2,7, I9,3,7, I9,4,7, I9,5,7, I9,6,7, I9,7,7, I9,8,7, I9,9,7, I9,0,6, Z6, I9,1,6, I9,2,6, I9,3,6, I9,4,6, I9,5,6, I9,6,6, I9,7,6, I9,8,6, I9,9,6, I9,0,5, Z5, I9,1,5, I9,2,5, I9,3,5, I9,4,5, I9,5,5, I9,6,5, I9,7,5, I9,8,5, I9,9,5, I9,0,4, Z4, I9,1,4, I9,2,4, I9,3,4, I9,4,4, I9,5,4, I9,6,4, I9,7,4, I9,8,4, I9,9,4, I9,0,3, Z3, I9,1,3, I9,2,3, I9,3,3, I9,4,3, I9,5,3, I9,6,3, I9,7,3, I9,8,3, I9,9,3, I9,0,2, Z2, I9,1,2, I9,2,2, I9,3,2, I9,4,2, I9,5,2, I9,6,2, I9,7,2, I9,8,2, I9,9,2, I9,0,1, Z1, I9,1,1, I9,2,1, I9,3,1, I9,4,1, I9,5,1, I9,6,1, I9,7,1, I9,8,1, I9,9,1, I9,0,0, Z0, I9,1,0, I9,2,0, I9,3,0, I9,4,0, I9,5,0, I9,6,0, I9,7,0, I9,8,0, I9,9,0, I8,0,9, X8, I8,1,9, I8,2,9, I8,3,9, I8,4,9, I8,5,9, I8,6,9, I8,7,9, I8,8,9, I8,9,9, I8,0,8, I8,1,8, I8,2,8, I8,3,8, I8,4,8, I8,5,8, I8,6,8, I8,7,8, I8,8,8, I8,9,8, I8,0,7, I8,1,7, I8,2,7, I8,3,7, I8,4,7, I8,5,7, I8,6,7, I8,7,7, I8,8,7, I8,9,7, I8,0,6, I8,1,6, I8,2,6, I8,3,6, I8,4,6, I8,5,6, I8,6,6, I8,7,6, I8,8,6, I8,9,6, I8,0,5, I8,1,5, I8,2,5, I8,3,5, I8,4,5, I8,5,5, I8,6,5, I8,7,5, I8,8,5, I8,9,5, I8,0,4, I8,1,4, I8,2,4, I8,3,4, I8,4,4, I8,5,4, I8,6,4, I8,7,4, I8,8,4, I8,9,4, I8,0,3, I8,1,3, I8,2,3, I8,3,3, I8,4,3, I8,5,3, I8,6,3, I8,7,3, I8,8,3, I8,9,3, I8,0,2, I8,1,2, I8,2,2, I8,3,2, I8,4,2, I8,5,2, I8,6,2, I8,7,2, I8,8,2, I8,9,2, I8,0,1, I8,1,1, I8,2,1, I8,3,1, I8,4,1, I8,5,1, I8,6,1, I8,7,1, I8,8,1, I8,9,1, I8,0,0, I8,1,0, I8,2,0, I8,3,0, I8,4,0, I8,5,0, I8,6,0, I8,7,0, I8,8,0, I8,9,0, I7,0,9, X7, I7,1,9, I7,2,9, I7,3,9, I7,4,9, I7,5,9, I7,6,9, I7,7,9, I7,8,9, I7,9,9, I7,0,8, I7,1,8, I7,2,8, I7,3,8, I7,4,8, I7,5,8, I7,6,8, I7,7,8, I7,8,8, I7,9,8, I7,0,7, I7,1,7, I7,2,7, I7,3,7, I7,4,7, I7,5,7, I7,6,7, I7,7,7, I7,8,7, I7,9,7, I7,0,6, I7,1,6, I7,2,6, I7,3,6, I7,4,6, I7,5,6, I7,6,6, I7,7,6, I7,8,6, I7,9,6, I7,0,5, I7,1,5, I7,2,5, I7,3,5, I7,4,5, I7,5,5, I7,6,5, I7,7,5, I7,8,5, I7,9,5, I7,0,4, I7,1,4, I7,2,4, I7,3,4, I7,4,4, I7,5,4, I7,6,4, I7,7,4, I7,8,4, I7,9,4, I7,0,3, I7,1,3, I7,2,3, I7,3,3, I7,4,3, I7,5,3, I7,6,3, I7,7,3, I7,8,3, I7,9,3, I7,0,2, I7,1,2, I7,2,2, I7,3,2, I7,4,2, I7,5,2, I7,6,2, I7,7,2, I7,8,2, I7,9,2, I7,0,1, I7,1,1, I7,2,1, I7,3,1, I7,4,1, I7,5,1, I7,6,1, I7,7,1, I7,8,1, I7,9,1, I7,0,0, I7,1,0, I7,2,0, I7,3,0, I7,4,0, I7,5,0, I7,6,0, I7,7,0, I7,8,0, I7,9,0, I6,0,9, X6, I6,1,9, I6,2,9, I6,3,9, I6,4,9, I6,5,9, I6,6,9, I6,7,9, I6,8,9, I6,9,9, I6,0,8, I6,1,8, I6,2,8, I6,3,8, I6,4,8, I6,5,8, I6,6,8, I6,7,8, I6,8,8, I6,9,8, I6,0,7, I6,1,7, I6,2,7, I6,3,7, I6,4,7, I6,5,7, I6,6,7, I6,7,7, I6,8,7, I6,9,7, I6,0,6, I6,1,6, I6,2,6, I6,3,6, I6,4,6, I6,5,6, I6,6,6, I6,7,6, I6,8,6, I6,9,6, I6,0,5, I6,1,5, I6,2,5, I6,3,5, I6,4,5, I6,5,5, I6,6,5, I6,7,5, I6,8,5, I6,9,5, I6,0,4, I6,1,4, I6,2,4, I6,3,4, I6,4,4, I6,5,4, I6,6,4, I6,7,4, I6,8,4, I6,9,4, I6,0,3, I6,1,3, I6,2,3, I6,3,3, I6,4,3, I6,5,3, I6,6,3, I6,7,3, I6,8,3, I6,9,3, I6,0,2, I6,1,2, I6,2,2, I6,3,2, I6,4,2, I6,5,2, I6,6,2, I6,7,2, I6,8,2, I6,9,2, I6,0,1, I6,1,1, I6,2,1, I6,3,1, I6,4,1, I6,5,1, I6,6,1, I6,7,1, I6,8,1, I6,9,1, I6,0,0, I6,1,0, I6,2,0, I6,3,0, I6,4,0, I6,5,0, I6,6,0, I6,7,0, I6,8,0, I6,9,0, I5,0,9, X5, I5,1,9, I5,2,9, I5,3,9, I5,4,9, I5,5,9, I5,6,9, I5,7,9, I5,8,9, I5,9,9, I5,0,8, I5,1,8, I5,2,8, I5,3,8, I5,4,8, I5,5,8, I5,6,8, I5,7,8, I5,8,8, I5,9,8, I5,0,7, I5,1,7, I5,2,7, I5,3,7, I5,4,7, I5,5,7, I5,6,7, I5,7,7, I5,8,7, I5,9,7, I5,0,6, I5,1,6, I5,2,6, I5,3,6, I5,4,6, I5,5,6, I5,6,6, I5,7,6, I5,8,6, I5,9,6, I5,0,5, I5,1,5, I5,2,5, I5,3,5, I5,4,5, I5,5,5, I5,6,5, I5,7,5, I5,8,5, I5,9,5, I5,0,4, I5,1,4, I5,2,4, I5,3,4, I5,4,4, I5,5,4, I5,6,4, I5,7,4, I5,8,4, I5,9,4, I5,0,3, I5,1,3, I5,2,3, I5,3,3, I5,4,3, I5,5,3, I5,6,3, I5,7,3, I5,8,3, I5,9,3, I5,0,2, I5,1,2, I5,2,2, I5,3,2, I5,4,2, I5,5,2, I5,6,2, I5,7,2, I5,8,2, I5,9,2, I5,0,1, I5,1,1, I5,2,1, I5,3,1, I5,4,1, I5,5,1, I5,6,1, I5,7,1, I5,8,1, I5,9,1, I5,0,0, I5,1,0, I5,2,0, I5,3,0, I5,4,0, I5,5,0, I5,6,0, I5,7,0, I5,8,0, I5,9,0, I4,0,9, X4, I4,1,9, I4,2,9, I4,3,9, I4,4,9, I4,5,9, I4,6,9, I4,7,9, I4,8,9, I4,9,9, I4,0,8, I4,1,8, I4,2,8, I4,3,8, I4,4,8, I4,5,8, I4,6,8, I4,7,8, I4,8,8, I4,9,8, I4,0,7, I4,1,7, I4,2,7, I4,3,7, I4,4,7, I4,5,7, I4,6,7, I4,7,7, I4,8,7, I4,9,7, I4,0,6, I4,1,6, I4,2,6, I4,3,6, I4,4,6, I4,5,6, I4,6,6, I4,7,6, I4,8,6, I4,9,6, I4,0,5, I4,1,5, I4,2,5, I4,3,5, I4,4,5, I4,5,5, I4,6,5, I4,7,5, I4,8,5, I4,9,5, I4,0,4, I4,1,4, I4,2,4, I4,3,4, I4,4,4, I4,5,4, I4,6,4, I4,7,4, I4,8,4, I4,9,4, I4,0,3, I4,1,3, I4,2,3, I4,3,3, I4,4,3, I4,5,3, I4,6,3, I4,7,3, I4,8,3, I4,9,3, I4,0,2, I4,1,2, I4,2,2, I4,3,2, I4,4,2, I4,5,2, I4,6,2, I4,7,2, I4,8,2, I4,9,2, I4,0,1, I4,1,1, I4,2,1, I4,3,1, I4,4,1, I4,5,1, I4,6,1, I4,7,1, I4,8,1, I4,9,1, I4,0,0, I4,1,0, I4,2,0, I4,3,0, I4,4,0, I4,5,0, I4,6,0, I4,7,0, I4,8,0, I4,9,0, I3,0,9, X3, I3,1,9, I3,2,9, I3,3,9, I3,4,9, I3,5,9, I3,6,9, I3,7,9, I3,8,9, I3,9,9, I3,0,8, I3,1,8, I3,2,8, I3,3,8, I3,4,8, I3,5,8, I3,6,8, I3,7,8, I3,8,8, I3,9,8, I3,0,7, I3,1,7, I3,2,7, I3,3,7, I3,4,7, I3,5,7, I3,6,7, I3,7,7, I3,8,7, I3,9,7, I3,0,6, I3,1,6, I3,2,6, I3,3,6, I3,4,6, I3,5,6, I3,6,6, I3,7,6, I3,8,6, I3,9,6, I3,0,5, I3,1,5, I3,2,5, I3,3,5, I3,4,5, I3,5,5, I3,6,5, I3,7,5, I3,8,5, I3,9,5, I3,0,4, I3,1,4, I3,2,4, I3,3,4, I3,4,4, I3,5,4, I3,6,4, I3,7,4, I3,8,4, I3,9,4, I3,0,3, I3,1,3, I3,2,3, I3,3,3, I3,4,3, I3,5,3, I3,6,3, I3,7,3, I3,8,3, I3,9,3, I3,0,2, I3,1,2, I3,2,2, I3,3,2, I3,4,2, I3,5,2, I3,6,2, I3,7,2, I3,8,2, I3,9,2, I3,0,1, I3,1,1, I3,2,1, I3,3,1, I3,4,1, I3,5,1, I3,6,1, I3,7,1, I3,8,1, I3,9,1, I3,0,0, I3,1,0, I3,2,0, I3,3,0, I3,4,0, I3,5,0, I3,6,0, I3,7,0, I3,8,0, I3,9,0, I2,0,9, X2, I2,1,9, I2,2,9, I2,3,9, I2,4,9, I2,5,9, I2,6,9, I2,7,9, I2,8,9, I2,9,9, I2,0,8, I2,1,8, I2,2,8, I2,3,8, I2,4,8, I2,5,8, I2,6,8, I2,7,8, I2,8,8, I2,9,8, I2,0,7, I2,1,7, I2,2,7, I2,3,7, I2,4,7, I2,5,7, I2,6,7, I2,7,7, I2,8,7, I2,9,7, I2,0,6, I2,1,6, I2,2,6, I2,3,6, I2,4,6, I2,5,6, I2,6,6, I2,7,6, I2,8,6, I2,9,6, I2,0,5, I2,1,5, I2,2,5, I2,3,5, I2,4,5, I2,5,5, I2,6,5, I2,7,5, I2,8,5, I2,9,5, I2,0,4, I2,1,4, I2,2,4, I2,3,4, I2,4,4, I2,5,4, I2,6,4, I2,7,4, I2,8,4, I2,9,4, I2,0,3, I2,1,3, I2,2,3, I2,3,3, I2,4,3, I2,5,3, I2,6,3, I2,7,3, I2,8,3, I2,9,3, I2,0,2, I2,1,2, I2,2,2, I2,3,2, I2,4,2, I2,5,2, I2,6,2, I2,7,2, I2,8,2, I2,9,2, I2,0,1, I2,1,1, I2,2,1, I2,3,1, I2,4,1, I2,5,1, I2,6,1, I2,7,1, I2,8,1, I2,9,1, I2,0,0, I2,1,0, I2,2,0, I2,3,0, I2,4,0, I2,5,0, I2,6,0, I2,7,0, I2,8,0, I2,9,0, I1,0,9, X1, I1,1,9, I1,2,9, I1,3,9, I1,4,9, I1,5,9, I1,6,9, I1,7,9, I1,8,9, I1,9,9, I1,0,8, I1,1,8, I1,2,8, I1,3,8, I1,4,8, I1,5,8, I1,6,8, I1,7,8, I1,8,8, I1,9,8, I1,0,7, I1,1,7, I1,2,7, I1,3,7, I1,4,7, I1,5,7, I1,6,7, I1,7,7, I1,8,7, I1,9,7, I1,0,6, I1,1,6, I1,2,6, I1,3,6, I1,4,6, I1,5,6, I1,6,6, I1,7,6, I1,8,6, I1,9,6, I1,0,5, I1,1,5, I1,2,5, I1,3,5, I1,4,5, I1,5,5, I1,6,5, I1,7,5, I1,8,5, I1,9,5, I1,0,4, I1,1,4, I1,2,4, I1,3,4, I1,4,4, I1,5,4, I1,6,4, I1,7,4, I1,8,4, I1,9,4, I1,0,3, I1,1,3, I1,2,3, I1,3,3, I1,4,3, I1,5,3, I1,6,3, I1,7,3, I1,8,3, I1,9,3, I1,0,2, I1,1,2, I1,2,2, I1,3,2, I1,4,2, I1,5,2, I1,6,2, I1,7,2, I1,8,2, I1,9,2, I1,0,1, I1,1,1, I1,2,1, I1,3,1, I1,4,1, I1,5,1, I1,6,1, I1,7,1, I1,8,1, I1,9,1, I1,0,0, I1,1,0, I1,2,0, I1,3,0, I1,4,0, I1,5,0, I1,6,0, I1,7,0, I1,8,0, I1,9,0, I0,0,9, X0, I0,1,9, I0,2,9, I0,3,9, I0,4,9, I0,5,9, I0,6,9, I0,7,9, I0,8,9, I0,9,9, I0,0,8, I0,1,8, I0,2,8, I0,3,8, I0,4,8, I0,5,8, I0,6,8, I0,7,8, I0,8,8, I0,9,8, I0,0,7, I0,1,7, I0,2,7, I0,3,7, I0,4,7, I0,5,7, I0,6,7, I0,7,7, I0,8,7, I0,9,7, I0,0,6, I0,1,6, I0,2,6, I0,3,6, I0,4,6, I0,5,6, I0,6,6, I0,7,6, I0,8,6, I0,9,6, I0,0,5, I0,1,5, I0,2,5, I0,3,5, I0,4,5, I0,5,5, I0,6,5, I0,7,5, I0,8,5, I0,9,5, I0,0,4, I0,1,4, I0,2,4, I0,3,4, I0,4,4, I0,5,4, I0,6,4, I0,7,4, I0,8,4, I0,9,4, I0,0,3, I0,1,3, I0,2,3, I0,3,3, I0,4,3, I0,5,3, I0,6,3, I0,7,3, I0,8,3, I0,9,3, I0,0,2, I0,1,2, I0,2,2, I0,3,2, I0,4,2, I0,5,2, I0,6,2, I0,7,2, I0,8,2, I0,9,2, I0,0,1, I0,1,1, I0,2,1, I0,3,1, I0,4,1, I0,5,1, I0,6,1, I0,7,1, I0,8,1, I0,9,1, I0,0,0, I0,1,0, I0,2,0, I0,3,0, I0,4,0, I0,5,0, I0,6,0, I0,7,0, I0,8,0, I0,9,0}),backend=torch, dtype=torch.float32, data=tensor(1., device='cuda:0')
mantissa, exponent = (tn.contract(), tn.exponent)
mantissa, exponent
(tensor(1., device='cuda:0'), tensor(344.7334, device='cuda:0'))