cotengra.presets

Preset configured optimizers.

Attributes

Classes

AutoOptimizer

An optimizer that automatically chooses between optimal and

AutoHQOptimizer

An optimizer that automatically chooses between optimal and

Functions

estimate_optimal_hardness(inputs)

Provides a very rough estimate of how long it would take to find the

get_auto_optimizer()

Cache and reuse for speed. But only construct dynamically.

auto_optimize(inputs, output, size_dict, **kwargs)

auto_optimize_tree(inputs, output, size_dict, **kwargs)

Get a contraction tree using the auto optimizer.

get_auto_hq_optimizer()

Cache and reuse for speed. But only construct dynamically.

auto_hq_optimize(inputs, output, size_dict, **kwargs)

auto_optimize_hq_tree(inputs, output, size_dict, **kwargs)

Get a contraction tree using the auto optimizer.

Module Contents

cotengra.presets.estimate_optimal_hardness(inputs)[source]

Provides a very rough estimate of how long it would take to find the optimal contraction order for a given set of inputs. The runtime is very approximately exponential in this number:

\[T \propto \exp {n^2 * k^0.5}\]

Where \(n\) is the number of tensors and \(k\) is the average degree of the hypergraph.

class cotengra.presets.AutoOptimizer(optimal_cutoff=250, minimize='combo', cache=True, **hyperoptimizer_kwargs)[source]

Bases: cotengra.oe.PathOptimizer

An optimizer that automatically chooses between optimal and hyper-optimization, designed for everyday use.

minimize = 'combo'
optimal_cutoff = 250
_optimize_optimal_fn
kwargs
_hyperoptimizers_by_thread
_get_optimizer_hyper_threadsafe()[source]
search(inputs, output, size_dict, **kwargs)[source]
__call__(inputs, output, size_dict, **kwargs)[source]
class cotengra.presets.AutoHQOptimizer(**kwargs)[source]

Bases: AutoOptimizer

An optimizer that automatically chooses between optimal and hyper-optimization, designed for everyday use on harder contractions or those that will be repeated many times, and thus warrant a more extensive search.

cotengra.presets.get_auto_optimizer()[source]

Cache and reuse for speed. But only construct dynamically.

cotengra.presets.auto_optimize(inputs, output, size_dict, **kwargs)[source]
cotengra.presets.auto_optimize_tree(inputs, output, size_dict, **kwargs)[source]

Get a contraction tree using the auto optimizer.

cotengra.presets.get_auto_hq_optimizer()[source]

Cache and reuse for speed. But only construct dynamically.

cotengra.presets.auto_hq_optimize(inputs, output, size_dict, **kwargs)[source]
cotengra.presets.auto_optimize_hq_tree(inputs, output, size_dict, **kwargs)[source]

Get a contraction tree using the auto optimizer.

cotengra.presets.greedy_optimize
cotengra.presets.optimal_optimize
cotengra.presets.optimal_outer_optimize
cotengra.presets.edgesort_optimize