How to execute multiple lattices#

Multiple lattices (whether in the form of different workflows or the same workflow with different parameters) can be executed with just some minor tweaks. For example, consider the lattice shown below, that we’d like to run for different parameters.

import covalent as ct

def identity(x):
    return x

def square(x):
    return x * x

def workflow(a):
    val_1 = identity(x=a)
    return square(x=val_1)

In order to run the workflow for different parameters, we can simply use a for loop to dispatch the tasks.

params = [1, 2, 3, 4]
dispatch_ids = [ct.dispatch(workflow)(a=param) for param in params]


We store the dispatch ids so that we can later query the results.