Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Linnea

Linnea is an experimental tool for the automatic generation of optimized code for linear algebra problems. It is developed at the High-Performance and Automatic Computing group at RWTH Aachen University.

Installation

Linnea requires Python 3.6 and can be installed with pip install git+git://github.com/HPAC/linnea.git. (Depending on your setup, you may have to use pip3 instead of pip.) To uninstall Linnea, use pip uninstall linnea. This also removes the commandline tool.

Development Installation

If you intend to contribute to Linnea, you can install it from local sources by running pip install -e . in your local development directory.

Overview

Linnea is a prototype of a compiler/program synthesis tool that automates the translation of the mathematical description of a linear algebra problem to an efficient sequence of calls to BLAS and LAPACK kernels. The main idea of Linnea is to construct a search graph that represents a large number of programs, taking into account knowledge about linear algebra, numerical linear algebra and high-performance computing. The algebraic nature of the domain is used to reduce the size of the search graph, without reducing the size of the search space that is explored.

The input to Linnea are linear algebra expressions. As operands, matrices, vectors and scalars are supported. Operands can be annotated with properties, such as 'lower triangular' or 'symmetric'. Supported operations are addition, multiplication, transposition and inversion. At the moment, Linnea generates Julia code (see https://julialang.org), using BLAS and LAPACK wrappers whenever possible.

Usage

Linnea can be used in two different ways.

Python Module

At the moment, Linnea is primarily a Python module. An example script for how to use Linnea within Python can found in examples/run_linnea.py. The input expressions are represented as Python objects. As an example, consider the description of a lower triangular linear system (omitting imports):

n = 1000

L = Matrix("L", (n, n))
L.set_property(properties.LOWER_TRIANGULAR)
L.set_property(properties.FULL_RANK)
x = Vector("x", (n, 1))
y = Vector("y", (n, 1))

input = Equations(Equal(y, Times(Inverse(L), x)))

Further examples of input problems are provided in the examples/inputX.py files.

Options can be set with a number of linnea.config.set_X() functions.

Commandline Tool

When installing Linnea via pip, the commandline tool linnea is installed. As input, it takes a description of the input problem in a simple custom language. With this language, the same lower triangular system is described as:

n = 1000

Matrix L(n, n) <LowerTriangular, FullRank>
ColumnVector x(n) <>
ColumnVector y(n) <>

y = inv(L)*x

Further examples are provided in examples/inputX.la. Notice that the primary purpose of this input format is to make it slightly easier to try out Linnea. There are no plans to establish this as an actual language. New features will probably not be immediately available in this language, and the language may change in the future without being backward compatible.

The list of commandline options is available via linnea -h.

Output

As output, Linnea generates a directory structure that contains code files, as well a file containing a description of the derivation graph, the primary datastructure used by Linnea. Which files are generated can be set as options. Likewise, the location of the output can be specified. By default, it is the current directory.

For the linear system from the previous examples, the following code will be generated:

using LinearAlgebra.BLAS
using LinearAlgebra

function algorithm0(ml0, ml1)
    # cost 1e+06
    # L: ml0, full, x: ml1, full
    # tmp1 = (L^-1 x)
    trsv!('L', 'N', 'N', ml0, ml1)

    # tmp1: ml1, full
    # y = tmp1
    return (ml1)
end

Options

Linnea offers a number of options which can be set through linnea.config in Python or as commandline options for the commandline tool. Alternatively, all options can also be specified in a linnea_config.json file (see examples) which has to be located in the same directory where Linnea is run, or at the user's $HOME folder. Both commandline options and linnea.config options override what is specified in linnea_config.json. As a fallback, reasonable default values are used.

There are the following options (those are the names used in Python, the commandline options have slightly different names. See linnea -h):

  • output_code_path The output of Linnea will be stored in this directory. The default is the current directory.

  • output_name Linnea creates a new directory that contains all output files. This is the name of this directory. The default is tmp.

  • language Not available for the commandline tool. For now, the only allowed option is Julia.

  • julia_data_type The data type used in the generated code. Either Float32 or Float64. The default is Float64.

  • merging_branches Whether or not to merge branches in the derivation graph. The default is true.

  • dead_ends Whether or not to eliminate dead ends in the derivation graph early. The default is true.

  • algorithms_limit The upper limit for the number of algorithms that are written to files. The default is 100.

  • strategy The strategy used to find algorithms. Either constructive or exhaustive. The default is constructive.

  • generate_graph Whether or not to generate a .gv file of the derivation graph. The default is false.

  • graph_style Style of the derivation graph. Either full, simple, or minimal. The default is full. Only applies if generate_graph is set to True.

  • generate_derivation Whether or not to generate a description of how the algorithms were derived. The default is false.

  • generate_code Whether or not to generate the actual code of the algorithms. The default is true.

  • generate_experiments Whether or not to generate code that can be used to run the algorithms. The default is false.

  • verbosity Level of verbosity. The default is 1.

Publications

A number of publications that discuss different aspects of Linnea can be found here.

Contributors

  • Henrik Barthels
  • Marcin Copik
  • Diego Fabregat Traver
  • Julius Hohnerlein
  • Manuel Krebber

Metadata

Release files for linnea 0.1.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linnea 0.1.dev1
File Size Uploaded Provenance Actions
linnea-0.1.dev1.tar.gz 132.3 kB Without provenance Details for linnea-0.1.dev1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linnea 0.1.dev1
File Interpreter ABI Platform Actions
linnea-0.1.dev1-py3-none-any.whl Python 3 none any Details for linnea-0.1.dev1-py3-none-any.whl

Total release size: 300.1 kB

Release files / linnea-0.1.dev1.tar.gz

Download URL linnea-0.1.dev1.tar.gz
Size 132.3 kB
Tags Source
SHA-256 checksum
How to use checksums
028a4fe611f63de5c9ead4df3996134090fd17c7a9109d49cbcf3d037d90b132
BLAKE2b-256 checksum
How to use checksums
351af2364629e42f5106c38de2d138a167155515026b43419cc9808538e920b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

Release files / linnea-0.1.dev1-py3-none-any.whl

Download URL linnea-0.1.dev1-py3-none-any.whl
Size 167.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15aeb08e8d68fda1ed622dd3f2d4d7b3ca44dc42c0e596c71da658972c997d74
BLAKE2b-256 checksum
How to use checksums
ce6b090b5892a1943e634dd3abfef6ecde5f1278592df6676575bcb64075dd0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

Security for linnea 0.1.dev1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page