Command Line Arguments#

There are several command line arguments that can control the behavior of Einsums. This is the documentation for these arguments.

Run any Einsums program with --help to get the same list from the program itself, including the default in effect for your build and the environment variable each option reads.

How Options Reach#

Every option below resolves through three sources. Each is free to overwrite the one before it:

1. the default compiled into the option
2. an environment variable
3. the command line

Environment variables#

Every option is readable from the environment under a name derived from its own: upper-case the long name and turn each run of separators into a single underscore. So --einsums:log:level reads EINSUMS_LOG_LEVEL and --einsums:profile:wait-for-viewer reads EINSUMS_PROFILE_WAIT_FOR_VIEWER.

This is what lets an inherited variable configure a job without editing its command line, while the command line still wins when it says so. An unset or empty variable counts as not specified, so FOO= leaves the default in place.

Added in version 2.0.0.

Flags and their negations#

Every flag is declared once, in the positive, and Einsums generates the no- spelling for it. So --einsums:profile:report is turned off with --einsums:profile:no-report, and a flag that is off by default is turned on by naming it.

--help lists the positive spelling and names the negation beside it rather than listing both.

From the environment a flag can only be switched on: a false value counts as not specified. To turn off a flag that is on by default, set the negation’s variable, such as EINSUMS_PROFILE_NO_REPORT=1.

Added in version 2.0.0: Flags used to be declared in whichever polarity was not the default, which is why several of the options below changed name in this release. The old no- spellings all still parse.

Basic Arguments#

--einsums:max-memory <size>#

Ceiling on the memory Einsums plans against. It takes a string containing a number and units; see einsums::string_util::memory_string. Set to 0 to disable.

Defaults to 80% of the machine’s physical RAM.

This is a planning ceiling, not an allocator meter: chunked algorithms size their working sets to it, and einsums::MemoryPool refuses a reservation that would push the process’s total pooled bytes past it - at the reserve site, on the pool’s owning thread, before the OS is asked for anything. Ordinary tensor allocations are not checked against it, which is what keeps the check from ever throwing inside a kernel.

Added in version 2.0.0.

--einsums:buffer-size <size>#

The ceiling on contraction workspace drawn from Einsums’ buffer allocator: buffer tensors and LAPACK work arrays. Ordinary tensors are not counted; see --einsums:max-memory for the planning ceiling. It takes a string containing a number and units. The units are either bytes or words. See einsums::string_util::memory_string for more information.

Defaults to 64MB. The ceiling exists to catch a runaway temporary with a named error, not to ration legitimate workspace; the default is sized so a wide machine’s worth of concurrent contractions fits under it with room to spare.

Added in version 1.0.0.

--einsums:work-buffer-size <size>#

The largest piece of a disk-backed tensor that a contraction reads into memory at once. The pieces count against --einsums:buffer-size, along with the other workspace drawn from the buffer allocator, so keep it well below that. Zero, the default, means an eighth of --einsums:buffer-size.

Added in version 1.0.0.

Logging#

--einsums:log:level <level>#

Set the level to see in the logger. Lower values provide more information: 0 is trace, 1 debug, 2 info, 3 warning, 4 error. A release build defaults to 4, so it reports only errors, and a debug build to 1.

  • 0: Tracing messages. Very verbose.

  • 1: Debugging messages.

  • 2: Information messages

  • 3: Warnings.

  • 4: Errors.

Values outside 0-4 are rejected.

Added in version 1.0.0.

Changed in version 1.1.0: This option now also sets the HIP log level if Einsums was built with GPU support.

Changed in version 2.0.0: This option no longer sets the HIP log level. Use the AMD_LOG_LEVEL environment variable. This option’s name has also been changed.

--einsums:log:destination <cerr|cout|file>#

Where log records go: cerr (the default), cout, or any other value, which is taken as the name of a file to log to.

The optimization passes’ narration (--einsums:pass:verbosity) goes to the same place. On the console it carries a time and thread prefix of its own; in a file it shares the log’s format.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed.

--einsums:log:format <format>#

A format string used for the logger output.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed.

Profiling#

--einsums:profile:disable#

Do not record profiling zones or annotations at all. This is a large speedup for workloads made of many small operations, where the bookkeeping can cost more than the work being measured.

Added in version 2.0.0.

--einsums:profile:report#

Write the profiling report when the program exits. On by default; turn it off with --einsums:profile:no-report.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed, and again later in the 2.0.0 cycle to its positive spelling.

--einsums:profile:filename <filename>#

The name of the file for the profiler output. Defaults to profile.txt.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed.

--einsums:profile:append#

Append the profiling information to the profiling file rather than replacing it. Off by default, so each run leaves one report.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed to its positive spelling. It was previously documented as --einsums:profiler:no-append, which never parsed.

Changed in version 2.0.0: Off by default. It was documented as on by default, but every report replaced the file regardless, so it now appends when given and the default keeps the behavior every run had.

--einsums:profile:detailed#

Print a detailed profile report rather than the summary.

Added in version 2.0.0.

--einsums:profile:save <filename>#

Save the profile session as JSON, which einsums profiler --load opens. Empty, the default, means do not save one.

Requires --einsums:profile:server, since the session is exported through the server; without it no file is written and the run logs an error saying so.

Added in version 2.0.0.

--einsums:profile:server#

Run the profile server, so a viewer can attach and stream this process’s profiling data.

Off by default. The server is a cost a run should opt into rather than one it pays for having been built with profiling: it holds a listening socket for the life of the process and is driven by the consumer thread, which services it on the same periodic tick that drains the event buffers.

It streams JSON Lines over TCP, binds to 127.0.0.1, and accepts up to four simultaneous clients. There is no authentication and no transport security of any kind, so the loopback bind is what keeps it private and is not something to work around. On macOS it also advertises itself over Bonjour as _waggle._tcp.

See --einsums:profile:port for the port it listens on, and --einsums:profile:wait-for-viewer to hold a short run open until a viewer has attached.

Added in version 2.0.0.

--einsums:profile:port <PORT>#

The port the profile server listens on. Defaults to 19216.

Added in version 2.0.0.

--einsums:profile:wait-for-viewer#

Block at startup until a profiler viewer connects, so that a short run cannot finish before the viewer has attached.

Added in version 2.0.0.

--einsums:profile:max-distinct-children <N>#

How many distinct zone names one parent zone keeps as separate entries in the profile. Defaults to 256; zero means no limit.

Some zone names are built at run time from a graph’s or a loop’s name, so a program that names each graph after its iteration adds a new entry, and every zone beneath it, for as long as it runs. Once a parent holds this many named children, each further name is timed under that parent’s (other) entry instead, whose distinct annotation counts the names it holds. The names that appeared first keep their own entries.

Added in version 2.0.0.

--einsums:profile:sources <LIST>#

The profiler’s optional instruments to turn on, comma-separated; each is off unless named here. The profile report and the viewer say why one that was asked for records nothing.

counters records each zone’s hardware counters: cycles, instructions, cache and branch misses through Linux perf (kernel.perf_event_paranoid must be 2 or less, and a virtual machine often has no hardware counters), and cycles and instructions, with the efficiency cores’ share, on macOS, where no root is needed. Reading them costs a few hundred nanoseconds as each zone opens and closes, so it suits coarse zones. A thread counts if the source was asked for when it first recorded.

energy records the energy each zone used, and the share of it on the efficiency cores, on macOS. The figure is the kernel’s per-thread estimate from the CPU’s power model, which it updates every few milliseconds, so the profiler samples it as it collects events rather than reading it at each zone: a zone pays nothing, a zone of about 100 ms or more gets its own figure, and shorter ones get theirs on average over many calls. Linux has no per-thread energy.

signposts also emits every zone as an os_signpost interval on macOS, under the subsystem waggle with a category per library, so Instruments shows Einsums’ zones beside its own CPU, GPU, Metal and memory tracks. Record with Instruments’ Logging template, or xcrun xctrace record --template Logging --launch -- ./program.

openmp records each OpenMP parallel region, named after the function it is in, each thread’s share of the region, and the barrier waits inside, through the runtime’s OMPT interface. The OpenMP runtime must support OMPT: LLVM’s libomp does, and runs GCC-compiled code too; GCC’s own libgomp does not. The runtime looks for a tool once, when it starts, so the option must be given before the program’s first OpenMP call, as it is on the command line or in the environment.

Added in version 2.0.0.

--einsums:profile:trace <PATH>#

Write every zone to a Perfetto trace at this path, to see each call on its thread’s timeline at ui.perfetto.dev, beside device work, the live-bytes curve and, with the energy source, each thread’s energy. {pid} in the path becomes the process id, so the ranks of an MPI run each write their own. A zone costs about 32 bytes of trace, written by the profiler’s own thread.

Added in version 2.0.0.

ComputeGraph Pass Options#

--einsums:pass:disable <PASSES>#

Comma-separated list of optimization pass names to skip when PassManager::run() is called. Use this to A/B test whether a specific pass helps or hurts performance.

Example: --einsums:pass:disable CSE,Reorder

Added in version 2.0.0.

--einsums:pass:analyze#

Run all passes in analysis-only mode. Each pass executes normally and reports what it found, but the graph is restored to its original state afterward. No modifications persist.

Added in version 2.0.0.

--einsums:pass:verbose#

Log node count and wall-clock time before and after each optimization pass, even for passes that don’t modify the graph.

Added in version 2.0.0.

--einsums:pass:verify#

After every optimization pass, check the graph’s structural invariants and fail with the name of the pass that broke one: every node id unique within its graph, every operand a registered tensor, every lifecycle node naming the tensor it manages, and every contraction and permutation carrying the index lists its operands’ ranks call for.

A pass that leaves a graph malformed usually still produces a graph that runs, so the damage otherwise surfaces far from its cause. The test suite turns this on; a program that suspects a pass can too. It costs one walk over the graph per pass.

Added in version 2.0.0.

--einsums:pass:verbosity <LEVEL>#

How much the optimization passes narrate: 0 silent, 1 a summary line per pass, 2 each modification and each declined candidate, 3 the per-candidate detail behind a decline.

A program that calls PassManager.set_verbosity chooses its own level and this leaves it alone; the option supplies a level only where nothing else did.

The narration goes where --einsums:log:destination says, and is printed whatever --einsums:log:level is: that level governs the library’s log, and a program that asked the passes to explain themselves is not also asked to lower it.

This is the only way to observe a thread plan. Graph.plan_threads() builds its planner directly rather than through a pass manager, so at level 0 it reports nothing and whether it widened any node, or declined and at which gate, cannot be seen from the outside. At 1 it says how many nodes it widened, to what width, and the makespan it expected; at 2 it names every node and its width.

Distinct from --einsums:pass:verbose, which logs node count and timing around each pass and says nothing about what a pass decided.

Added in version 2.0.0.

--einsums:graph:dump-regions#

Dump the algebra each region rewrite raised, before and after it rewrote, in the algebraic form rather than as a node list.

This is the first thing to turn on when an optimized graph produces a wrong number. A diff of two node-list dumps tells you which nodes changed; a diff of the algebra tells you what the rewrite claimed, which is where the mistake actually is. Output goes to stderr at pass verbosity 2 and above, and is also kept on the pass so a test can read it.

Costs one rendering per region, so it is off by default.

Added in version 2.0.0.

Let the structural-algebraic phase run its search passes, which is MultiTermFactorization today.

Off by default, and the default is the point rather than caution. Every other pass in that phase is a recognizer: it walks the graph once and its runtime is a function of the node count. A search pass’s runtime is a function of how many candidates the graph offers, which nobody can predict from outside, and the saved graph IR exists precisely so that a search runs ONCE and a replay does not.

So the interactive default is off, and the capture-optimize-save workflow turns it on deliberately. A caller who wants it for one pipeline can switch it on there instead: MultiTermFactorization::set_search_enabled overrides this option in both directions, which is also what makes two pipelines with different settings runnable at the same time.

See also --einsums:graph:optimizer-budget, which bounds how long the search may run.

Added in version 2.0.0.

--einsums:graph:factorization-cache#

Keep each search pass’s chosen plan in memory and replay it when a structurally identical graph comes back. On by default.

The search MultiTermFactorization runs is a pure function of the region’s structure, so its answer is worth keeping. An entry is keyed on einsums::compute_graph::Graph::content_hash together with the region’s node span and the factor cap, and it holds a plan rather than a graph: the shared pairs that were committed, in order, and the contraction tree chosen for each term, written as positions rather than as tensor identities so a plan found on one graph applies to another that hashes the same.

The case it pays for is a pipeline whose stages present the same program under the same name: the first stage searches and the rest replay. It does not pay for re-running a script, which is a new process with an empty cache; that case is what saving the optimized graph IR is for. A search that ran out of its budget is never kept, so a plan that comes back out is one an unbounded search would have found.

MultiTermFactorization::set_cache_enabled overrides this for one pipeline and clear_cache empties it. Switch it off when bisecting a wrong number: two supposedly identical graphs getting one plan is the first thing to rule out.

Added in version 2.0.0.

--einsums:graph:factorization-max-factors <COUNT>#

The largest number of factors a term may have before MultiTermFactorization declines it instead of searching it.

The cap is a property of the program a caller brings rather than of the pass, which is why it is an option. A density-fitted opposite-spin correlation energy, flattened through its direct product and its dot, is nine leaves; the same energy through a grid fit is fourteen; an amplitude residual term is more. A cap chosen for the first of those declines the other two silently, and a caller has no way to lift it without editing the pass.

The cost is stated rather than hidden. The per-term program is 3^N in the factor count, so fourteen leaves is a few million subset splits and runs in seconds, and twenty is over three billion and does not finish unaided. A value in the twenties is therefore a request to run under --einsums:graph:optimizer-budget and keep the best tree found when it expires, which is what that budget was built to do. Raising this changes what the search is offered and never how the search itself scales.

MultiTermFactorization::set_max_factors overrides this for one pipeline, in both directions. A pass that builds its own cone out of a provider’s factors, which FactorizationPass does, knows how many leaves it is about to hand over and takes this as a floor rather than a ceiling.

Added in version 2.0.0.

--einsums:graph:factorization-max-readers <COUNT>#

How many consumers a definition may be inlined into before MultiTermFactorization leaves it whole.

An author-named intermediate several statements read is inlined into each of them whose bracketing it improves and kept for the rest, so a value two consumers want no longer pins the algebra around it. Every copy is a term of its own, which is the growth this bounds: the search sees as many terms as the copies it made, and each of them is capped by --einsums:graph:factorization-max-factors separately. Raising this costs search time linearly where raising the factor cap costs it exponentially.

Four is the default because the shapes that ask for this have two or three consumers, a correlation energy split into its spin halves and an integral a residual reads from two routes, and because a value more consumers than that read is far more likely to be a quantity the program genuinely shares than an artifact of how the author bracketed it. A definition past the cap is reported through the pass’s skip tally rather than dropped silently.

A copy is never emitted for its own sake: a consumer that gains nothing from the inlining reads the definition instead, and the whole rewrite is still measured against the captured bracketing before anything is emitted.

MultiTermFactorization::set_max_readers overrides this for one pipeline, in both directions.

Added in version 2.0.0.

--einsums:graph:laplace-epsilon <EPS>#

Target relative accuracy for the quadrature LaplaceTransform substitutes for a tagged energy denominator.

A tolerance rather than a point count, deliberately. A tolerance composes with the accuracy budget and is what an approximation record can state; a count is a means, and the same count over a wider spectral range is a different approximation that says nothing about what the result is worth. The count is derived from this option together with the range of the signed energy sum the bound orbital energies form, and it reaches the setup node’s descriptor, so a graph saved here means the same thing wherever it is loaded.

The rule is the truncated trapezoidal sum of the exponential integral on a logarithmic grid. Its three error terms, the discretization and the two truncations, are each bounded analytically and are given half, a quarter and a quarter of the target between them, which is what fixes the grid. Tightening the tolerance shrinks the step, so the point count and the arithmetic the rewrite emits both grow roughly with the logarithm of the reciprocal tolerance; on a typical orbital-energy range, 1e-4 needs around twenty points and 1e-6 around forty.

LaplaceTransform::set_epsilon overrides this for one pipeline, and LaplaceTransform::set_points overrides the derived count outright, which exists for reproducing a published number rather than for ordinary use. The error the rule actually reaches is measured rather than assumed: it is recorded on the graph as an approximation record, and it is measured again on every bind into the tensor LaplaceTransform::error_tensor_name names.

Added in version 2.0.0.

--einsums:graph:thc-epsilon <EPS>#

Relative error a ThcFactorization asserts for the grid fit it substitutes for a tagged four-index tensor, when the caller states none of its own.

A tolerance, spelled the way every per-lossy-pass knob is, and it reaches the PROVIDER rather than living in a pass, so a graph saved after a grid fit means one thing wherever it is loaded.

What it is not is a measurement. The error of a tensor-hypercontraction fit against the exact four-index tensor cannot be computed without forming the tensor the fit exists to avoid, so the number in the approximation record is the caller’s assertion, exactly as the density fit’s is. What IS measured, on every bind, is the least-squares residual of the grid fit against the three-index tensor it was fitted from: two parameters named by ThcFactorization.residual_param_name and ThcFactorization.reference_param_name, whose ratio’s square root is the relative residual. A residual far above this option is the signal that the grid was too coarse for the accuracy the record claims.

The grid itself is not chosen here. The pass takes the collocation matrix it is handed, and pruning a grid is a setup the caller performs; this option says what the result is asserted to be worth and the measured residual says whether the grid delivered it.

Added in version 2.0.0.

--einsums:graph:naf-threshold <FRACTION>#

Fraction of the largest singular value below which a NaturalAuxiliaryFactorization drops an auxiliary direction, when the caller states no threshold of its own.

A tolerance, spelled the way every per-lossy-pass knob is, and it reaches the PROVIDER rather than living in a pass, so a graph saved after a truncation means one thing wherever it is loaded. Loosening it shrinks the auxiliary index and grows the error; at water/cc-pVDZ a threshold of 1e-1 keeps 39 of 84 auxiliary functions and 1e-2 keeps 61.

RELATIVE, where the drop threshold of a metric fit is absolute, and the difference is where the two guards run. A metric fit’s is a captured element operation whose policy number is bound when its executor is built, so a relative cutoff there needs a reduction feeding a value into a guard. This one runs in ordinary code at optimize time over eigenvalues held in a local buffer, where comparing against the largest of them costs nothing.

What the record carries is not this number. The exact tensor is the one being truncated and the truncation reads it, so the error is measured rather than claimed: the norm of the dropped singular values against the norm of all of them. That number is a bound on the tensor and therefore a loose one on any energy computed from it.

The spectrum is read off the eigenvalues of the Gram matrix, which are the squares of the singular values, so a singular value is resolved to about the square root of machine epsilon. A threshold below 1e-8 is asking the fit to distinguish a numerically absent direction from a genuinely small one, which it cannot.

Added in version 2.0.0.

--einsums:graph:fno-occupation <OCCUPATION>#

Occupation below which BasisTruncation drops a natural orbital from the correlated space, when the caller states no cutoff of its own.

A tolerance, spelled the way every per-lossy-pass knob is, and ABSOLUTE where the auxiliary truncation’s threshold is relative: an occupation number already is a fraction, since it says how much of an electron a virtual orbital carries, and the conventional cutoffs are quoted as such rather than against whichever orbital happens to be the most occupied.

It reaches the PASS rather than a provider, because a basis truncation factors nothing: it replaces one index space by a contained subspace and projects every tensor that runs over the space it replaced.

What the approximation record carries is not this number. It is the MP2 correlation energy the truncation removed, measured at optimize time from the amplitudes the pass was handed, which is an absolute energy-like effect rather than a relative one.

Loosening it shrinks the virtual index and removes more correlation energy. At water/cc-pVDZ the natural occupations run from 2.3e-2 down to 4.7e-5 over 19 virtual orbitals, so a cutoff of 1e-3 keeps 9 of them and one of 1e-4 keeps 17; there is no cutoff that halves that molecule’s virtual space cheaply, which is a property of a small basis rather than of the method.

Added in version 2.0.0.

--einsums:graph:tiling-memory-cap <BYTES>#

Largest a single live intermediate may be, in bytes, before AxisTiling rewrites the program as a loop over slices of its free axes.

This is a resource knob and not a tolerance. Nothing about tiling trades accuracy: the algebra at one slice is the algebra the capture wrote, and the only thing that moves is which axes are loop variables and which are tensor axes. What the pass does owe is the summation order of the reduction it turns into an accumulation across iterations, which is why it declares the re-associating tier.

The number is read three times. It decides whether to tile, since a program whose largest intermediate already fits is declined and left alone. It decides which axes and blocks, since the pass keeps the candidate the cost model predicts fastest among those that bring the footprint under the cap. And it decides how deep, since the chunk is the largest number of slices whose intermediates still fit.

Zero disables the pass. A negative value, the default, derives the cap from the machine: an intermediate may take whatever --einsums:max-memory leaves after every other tensor alive beside it. The caller’s tensors are alive throughout, an intermediate of the graph from its first writer to its last reader, and a tensor only a body that runs before or after the one being tiled uses is not alive beside it at all. In a program whose peak fits the budget, an intermediate also takes no more than --einsums:graph:tiling-budget-share of the budget; in one over its budget, a loop may take all that the budget leaves. The pass therefore fires when the program would not fit and when one of its intermediates is over its share, and leaves every other program as captured, which is what makes it a member of the default pipeline. A positive value caps each intermediate on its own, for a caller who wants a smaller footprint than the machine allows.

Added in version 2.0.0.

--einsums:graph:tiling-budget-share <FRACTION>#

Largest fraction of --einsums:max-memory one intermediate may hold before AxisTiling streams it, in a program that fits the budget as well as in one that does not.

Fitting is not the only reason to stream. An intermediate that takes a large part of the machine is written and read back at memory bandwidth, and the kernels around it work on panels far larger than they need, so a program that holds it whole can be slower than the same program streaming it in blocks. The share bounds the result as well as the trigger: a tiled region’s buffers, remainder loops included, are held to the same share together.

The same share decides when SlabStreaming reads a backed tensor (one annotated with a backing, read from storage at every replay) a slab at a time instead of loading it whole, and bounds each slab it reads.

AxisTiling reads it only when --einsums:graph:tiling-memory-cap is derived, the default. A positive cap is the caller’s own bound and is taken as given. Zero or one turns the rule off, leaving the budget as the only bound.

Added in version 2.0.0.

--einsums:graph:storage-byte-weight <WEIGHT>#

Bytes of memory traffic one byte moved to or from storage counts as, when AxisTiling chooses the loop over a region that reads or writes a backed tensor (one annotated with a backing, held in storage rather than memory).

The pass prices the bytes a loop moves at memory bandwidth beside its contractions’ time, and a byte that comes from a file costs more than one that comes from memory. The default of 20 is measured: on an M4 laptop memory reads at 66.6 GB/s and an .etn entry read from the drive at 3.26 GB/s. A file the page cache still holds reads at 16.6 GB/s there, a weight of 4; the default takes the drive’s figure, since a tensor is streamed because it does not fit, and a tensor that does not fit is not cached.

Added in version 2.0.0.

--einsums:graph:storage-run-bytes <BYTES>#

Bytes of memory traffic one contiguous run of storage costs beyond the bytes it moves, when AxisTiling chooses the loop over a region that reads or writes a backed tensor.

A block of a stored tensor is one run when it covers every axis stored before its first partial one, and many short runs otherwise, each a system call. The default of 512 KiB is measured on the same machine: a short run read from the drive takes 8.1 microseconds, as long as reading about 512 KiB from memory. From the page cache it takes 0.3 microseconds, about 22 KiB.

Added in version 2.0.0.

--einsums:graph:optimizer-budget <value>#

Wall-clock allowance in milliseconds for each search pass. Zero means unlimited.

A pass that exhausts its allowance keeps the best candidate it had found, applies it, and reports that it was cut off, so running out of time costs optimization rather than correctness or determinism. PassManager.explain() says which happened, because a report that could not tell “this graph was already optimal” from “I ran out of time on the first candidate” would be silent in exactly the case a budget exists for.

The default is a starting point rather than a measurement, which is what an option is for. PassManager::set_optimizer_budget overrides it for one pipeline.

Added in version 2.0.0.

--einsums:graph:profile-groups#

Break a grouped batched GEMM into one profiler zone per shape class.

This deliberately changes how the contraction runs: it takes the slower unfused form, because a per-group breakdown of one parallel loop is not obtainable any other way. Read it for where the arithmetic is, not for what the node costs.

Added in version 2.0.0.

--einsums:graph:verify-levels#

Before each level-scheduled replay, check that no execution level holds two nodes touching overlapping storage.

On by default in debug builds. This option is how a release build turns it on, which is what a nondeterministic result wants. It costs a second pass over every operand and can report a conflict it cannot disprove.

Added in version 2.0.0.

Hardware Profile#

--einsums:hardware:l1-cache-size <BYTES>#

The L1 data cache size, in bytes, that einsums assumes in place of the detected one. Zero, the default, detects it.

The cache sizes decide how the packed contraction engine blocks its operands, so a wrong value changes speed, never the result. Set the three cache sizes to compare blockings from one binary, or to model another machine’s caches on this one.

Added in version 2.0.0.

--einsums:hardware:l2-cache-size <BYTES>#

The L2 cache size, in bytes, that einsums assumes in place of the detected one. Zero, the default, detects it. See --einsums:hardware:l1-cache-size.

Added in version 2.0.0.

--einsums:hardware:l3-cache-size <BYTES>#

The L3 cache size, in bytes, that einsums assumes in place of the detected one. Zero, the default, detects it. See --einsums:hardware:l1-cache-size.

Added in version 2.0.0.

--einsums:cache-dir <PATH>#

The directory where einsums looks for measurements kept between runs. Empty, the default, uses the platform’s cache location: an einsums directory under %LOCALAPPDATA% on Windows, and under $XDG_CACHE_HOME or ~/.cache elsewhere.

Today that is this machine’s hardware profile, in profiles/<fingerprint>.json, see --einsums:hardware:profile. Point this somewhere disposable to keep a test or a CI job from reading the machine’s own profile.

Added in version 2.0.0.

--einsums:hardware:profile <PATH>#

Use this hardware profile instead of searching for one.

A hardware profile is one JSON file holding everything einsums tune measured on a machine: the GEMM efficiency curve and bandwidths the cost model prices its candidates against (ContractionPlanning’s chain ordering, GEMMBatching’s profitability gate, GPUPlacement), the cost of an OpenMP parallel region at each team size, which sets when kernels go parallel, and tuned values of performance options, applied below the environment and the command line. Left empty, the default, einsums looks for this machine’s profile under --einsums:cache-dir and then under --einsums:hardware:site-profiles, by a fingerprint of the hardware, and uses the first that applies. Without one, the cost model comes from a table of known devices and the region cost is measured in each process.

A file applies when it describes this machine, the BLAS in use, and an Einsums version that differs from this one at most in the patch number. A named file is used even when another machine measured it, with a warning, since naming a file says you mean it; another Einsums minor version or BLAS still makes it stale. A file that does not apply, or will not load, is reported at --einsums:log:level 3 or lower and never an error: the profile shapes which optimization is chosen, never whether the answer is right.

Sharing a profile between machines of the same kind is copying this file.

Added in version 2.0.0.

--einsums:hardware:site-profiles <PATH>#

A directory of hardware profiles searched after the user’s own cache directory. Empty, the default, is the installation’s share/einsums/profiles.

An administrator runs einsums tune --output once per kind of node and installs the files here, and every user without a profile of their own gets the measured numbers. Files are named by the machine’s fingerprint, so one directory serves a cluster with several kinds of node.

Added in version 2.0.0.

--einsums:hardware:omp-region-cost-ns <NS>#

Pin the cost of entering an OpenMP parallel region, in nanoseconds. Negative, the default, takes the hardware profile’s value when there is one and measures otherwise.

The thresholds that decide whether a loop or a contraction is worth a team are derived from this cost. A pin holds them fixed across machines and runs without touching any file.

Added in version 2.0.0.

--einsums:hardware:omp-break-even-flops-per-ns <RATE>#

The rate that turns the cost of an OpenMP region into the work at which a contraction goes parallel: the threshold is the region cost in nanoseconds times this. A calibration, not a flop rate. The default, 12, landed on the measured optimum across two tiled CCSD residuals on an Apple M4 Pro; einsums tune measures it on the machine at hand, as the work at which a packed contraction on a team overtakes the same contraction on one thread, and writes it to the hardware profile. --einsums:hardware:omp-min-parallel-flops pins the threshold itself instead.

Added in version 2.0.0.

--einsums:hardware:omp-min-parallel-elements <N>#

Pin the element count at which an elementwise kernel opens a parallel region. Negative, the default, derives it from the region cost. Zero parallelizes every loop.

This is for comparing thresholds from one binary, since rebuilds move timings for unrelated reasons. Any value gives the same results.

Added in version 2.0.0.

--einsums:hardware:omp-min-parallel-flops <N>#

Pin the work, in flops, at which a contraction opens a parallel region. Negative, the default, derives it from the region cost. Zero parallelizes every contraction.

This is for comparing thresholds from one binary, since rebuilds move timings for unrelated reasons. Any value gives the same results.

Added in version 2.0.0.

GPU#

--einsums:gpu:disable#

Keep every node on the host, making the GPU placement pass a no-op.

Added in version 2.0.0.

HPTT#

--einsums:hptt:selection-method <METHOD>#

The plan selection method used by the tensor transpose backend: one of estimate, measure, patient, or crazy. Defaults to estimate. The later methods spend more time choosing a plan in exchange for a faster transpose, which pays off when one plan is reused many times.

Added in version 2.0.0.

Tensor Storage#

--einsums:scratch-dir <DIR>#

The scratch directory for Einsums tensor files. Defaults to the system temporary directory.

Added in version 1.0.0.

--einsums:hdf5-file-name <filename>#

The name of the HDF5 scratch file. The default carries the process id, so concurrent runs do not collide.

Added in version 1.0.0.

--einsums:delete-hdf5-files#

Clean up the HDF5 scratch file on exit. On by default; keep the file for inspection with --einsums:no-delete-hdf5-files.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed to its positive spelling.

--einsums:tensor:huge-pages#

Back large tensor buffers with transparent huge pages. Off by default. When set, on Linux, a tensor’s storage is advised with madvise(MADV_HUGEPAGE) before it is first touched, so buffers of a few megabytes or more fault in 2 MB pages instead of 4 KB ones; the option does nothing elsewhere, or when the kernel’s THP policy is never. It helps contractions whose inner walk through an operand spans many pages, which otherwise take a TLB miss on every step. It hurts operands whose strides are multiples of 32 KB or more: huge pages fix the low 21 address bits, so those strides alias on the same DRAM channel and cache sets that 4 KB page placement used to scatter. Measure before turning it on for a workload.

Added in version 2.0.0.

--einsums:row-major#

Construct tensors in row-major order rather than column-major.

Off by default: Einsums tensors are column-major at construction, which is what the BLAS and LAPACK backends expect.

Added in version 2.0.0: The setting was read from the tensor constructors in earlier releases but no option ever set it.

Advanced Arguments#

--einsums:debug:crash-handler#

On Windows, install the crash handler that reports a fatal exception and writes a minidump. On by default; turn it off with --einsums:debug:no-crash-handler. Elsewhere it has no effect, and crashes are reported by the signal handlers.

Deliberately separate from --einsums:debug:install-signal-handlers. On Windows the two are different mechanisms, since signals never see a memory fault there, so a Python process can keep its own faulthandler on the signals and still get a report out of a hard crash.

Added in version 2.0.0.

--einsums:debug:crash-dump-dir <DIR>#

Directory for crash minidumps, on Windows. Empty, the default, means the working directory.

Added in version 2.0.0.

--einsums:debug:install-signal-handlers#

Install Einsums’ custom signal handlers. On by default; turn them off with --einsums:debug:no-install-signal-handlers, which is what a host process that installs its own handlers wants.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed, and again later in the 2.0.0 cycle to its positive spelling.

--einsums:debug:attach-debugger#

Offer the chance to attach a debugger when an error is detected.

Off by default, because the offer BLOCKS: a process that hits an error waits for a human who, in a test harness or a batch job, is not there. Turn it on with --einsums:debug:attach-debugger when you are at the keyboard and want the process held open at the point of failure.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed, and again later in the 2.0.0 cycle to its positive spelling. Its default has also changed from on to off.

--einsums:debug:diagnostics-on-terminate#

Print extra diagnostics on termination. On by default; turn it off with --einsums:debug:no-diagnostics-on-terminate.

Added in version 1.0.0.

Changed in version 2.0.0: This option’s name has been changed, and again later in the 2.0.0 cycle to its positive spelling.

PackedGemm#

--einsums:packed-gemm:flatten-budget <MIB>#

Cap the temporary buffers the multi-K flatten route allocates, in MiB. Zero, the default, means no cap.

A contraction that sums over several indices has to make one index of each operand contiguous before a single GEMM can span them, and the flatten route does that by transposing whole operands. On the largest case in the head-to-head suite that is 448 MiB, both sides, held in thread-local buffers that only ever grow. With a cap it transposes a chunk of the summed index at a time instead, and the contraction becomes a short chain of large GEMMs over buffers that fit the budget.

Chunking is not free, which is why it is off unless asked for. It slices one summed index, and what that costs depends on where that index sits in each operand: the one whose slowest axis it is reads its chunk contiguously, while the one whose fastest axis it is reads a fraction of every cache line it touches. Both happen at once on the contraction above, where the cost against the uncapped route is about 4% in single precision and 2% in double at a 64 MiB budget, rising as the budget falls.

Only contractions that reach this route are affected, which is a small minority: most take the packed loops instead, and those block their own buffers against the cache.

Added in version 2.0.0.

--einsums:packed-gemm:complex-1m#

Run complex contractions on x86 through the real vector tile kernel, using the 1m method. Off by default.

The vector tile kernel exists only for real types. Without this flag a complex contraction that reaches the packed loops calls one vendor GEMM per cache block when its output must be scattered, and runs a portable complex tile otherwise. With it, both pack the complex operands into the expanded real form of the 1m method, and the real tile of the underlying type computes the complex result directly.

Only the kernel changes. Which contractions reach the packed loops is decided exactly as before. The flag has no effect below x86-64-v2 or on other architectures, and the SME rung always uses the 1m method for complex types.

Added in version 2.0.0.

--einsums:packed-gemm:cores-per-l3 <N>#

The number of physical cores the packed engine assumes share one L3 cache. Zero, the default, detects it.

On Linux the count is read from sysfs as the CPUs sharing CPU 0’s L3 divided by its SMT siblings. Where that cannot be read, macOS included, the engine assumes 1.

The count decides whether a threaded contraction splits its threads into teams, one per L3, that each share a packed panel of the right-hand operand. A wrong value changes how the work is divided and how fast it runs, never the result. Set it when detection gets a machine wrong, or to model a particular part on another machine.

Added in version 2.0.0.

--einsums:packed-gemm:c-temp-budget <KIB>#

The budget, in KiB, for the temporary block of the output that the block-GEMM strategy computes into before scattering it. Zero, the default, derives it as four times the L1 cache, and never less than 512 KiB.

The budget bounds the blocks that strategy works in, so it trades memory against speed and never changes a result. It exists for sweeps.

Added in version 2.0.0.

--einsums:packed-gemm:outer-product-floor <ELEMENTS>#

Output elements below which an outer product of rank three or more is left to the generic loop rather than the packed passes, whose fixed setup a small product does not repay. The default, 768, was measured on an Apple M4, and where the generic loop stops winning moves with the machine and with that loop; einsums tune measures it and writes it to the hardware profile. From 4096 elements a matrix-shaped outer product takes the direct BLAS paths instead, so the floor matters only below that.

Added in version 2.0.0.

--einsums:packed-gemm:outer-gemm-max <ELEMENTS>#

Output elements from which a contiguous outer product with a prefactor on its output takes ger and a separate scaling pass rather than a GEMM of inner extent one. ger has no beta, so the prefactor costs a pass over the output; the GEMM folds it in and wins until its blocking overhead outgrows that pass. Measured between 65k and 332k elements on an Apple M4, with a default of 131072; einsums tune measures it.

Added in version 2.0.0.

--einsums:packed-gemm:stream-min-elems <ELEMENTS>#

Elements of the supplying operand below which a contraction shaped like a matrix-vector product whose axes do not form a matrix (the exchange K(i,j) = A(i,k,j,l) B(k,l)) is not streamed but left to the packed engine. Below the default, 4096, the call takes a few microseconds either way; einsums tune measures where the stream starts to win.

Added in version 2.0.0.

--einsums:packed-gemm:stream-elems-per-thread <ELEMENTS>#

Elements of the streamed operand each thread must have before the stream forks another. Below it the region’s fork and the per-thread buffers cost more than the elements they would share. The default, 65536, was measured on an Apple M4, where 16384 forked too early and was slower at every mid size. A matrix-vector product the vendor’s BLAS cannot thread is streamed from two threads’ worth. einsums tune picks the value closest to the best across a range of sizes.

Added in version 2.0.0.

--einsums:packed-gemm:dump-plan#

Print the resolved plan and blocking of every packed contraction to standard error: the dimensions and strides of each operand group, the register and cache blocks, and how the result is written back. Off by default, and meant for diagnosis.

Added in version 2.0.0.

SIMD#

--einsums:simd:arch <RUNG>#

Cap the SIMD rung that runtime-dispatched kernels run at. Empty, the default, leaves the choice to Stripes, the SIMD library: its STRIPES_ARCH environment variable if set, and otherwise the highest rung the CPU and operating system support. Accepted rungs are baseline, v2, v3, v4 and sme, and the aliases sse2, sse4.2, avx2, avx512 and sme2.

This can only lower the rung. A rung the machine cannot run is replaced, with a warning shown at --einsums:log:level 3 or lower, by the next one below it that it can, and a rung of another architecture is ignored. It is how a test runs every rung of a dispatch ladder on one machine.

Added in version 2.0.0.

TensorIO#

--einsums:io:sync#

Sync an .etn file to disk before and after each commit rewrites its header. A commit puts new data and a new entry table where the file’s last commit does not reach and only then rewrites the header, so a process killed at any point leaves the file as its last commit left it whether or not this is on. With it on, the default, a power loss or a crash of the machine does too, at the cost of two syncs per commit. A commit happens when a handle closes or is flushed and at each copy, rename, swap, removal, restage or compaction of an entry.

Added in version 2.0.0.