Skip to main content

Crate presk_manual

Crate presk_manual 

Source
Expand description

§Presk compiler — user manual

Version 0.16.0 (plans 0.1.0 to 0.16.0 and the patches 0.10.1 and 0.14.1 done; status). This manual describes the presk tool as it is implemented, no more: every chapter was updated at each step of each plan, and features that exist only in the language specification are marked not implemented. The reference for the language itself is the specification repository presk-specs (report/chapters/02-spec.tex); this manual documents what the compiler accepts and does.

Presk is a domain-specific language for describing, training and running neural networks. A Presk program denotes a mathematical function over tensors of real numbers: the language has no machine number types (float32, bfloat16…), and the precision of an execution is a compilation choice made under a declared error budget. Shapes, with named and symbolic axes, are part of the types; every function carries a regularity class that decides whether it may be differentiated; randomness is an explicit effect.

§Chapters

  • install — building the tool from source, requirements.
  • tutorial — a guided tour, from a first module to a PyTorch export; start here. Its programs are in tutorial/, its commands in make tutorial.
  • cli — the presk command line.
  • language — the syntax accepted by this version; reading a program as the reference’s equations (0.13.0).
  • training — presk train: the training loop on any backend, checkpoints, a precision budget on the step.
  • serve — inference serve, presk serve: the generation loop on any backend, serve.py in the export.
  • data — .psk.d data files, presk data, the training data pipeline.
  • native — the runtime seam, PSK-Kernel v0 (--backend kernel) and its vector form, the realization (--realize f64|f32|bf16|@FILE), the Cranelift backend, the layouts of a contraction, threads at any depth, the conformance suite.
  • export_c — presk export --target c: an entry as a C program that computes the native backend’s bits, under a plan, on threads, sampling, with integer weights; why its bits are the native backend’s, what is checked; the SCoP mode for polyhedral tools.
  • realize — PSK-Realize: fusion groups, what shares a loop nest, and the launches and traffic it removes; the realization plan (--plan), a layout per nest, its decisions and how a plan is chosen.
  • optimization — --opt: e-graph rewriting of PSK-Core, exact over ℝ, checked against the interpreter; the cost model calibrated per machine type; the layout cost model, its load term and its fresh test.
  • explain — presk explain: one compilation as a document, every stage’s representation and its decisions, each figure the commands’ own (0.11.0); its JSON, and the pipeline view: the stages as columns, every element linked to what it was made from, its equations and each kernel’s machine code (0.13.0); the network diagram, the program as boxes and arrows in the view’s second tab, presk dump --stage network (0.14.0); any set of its boxes opened, and the exploded view (0.14.1).
  • explain_loss — the document presk explain writes for the tutorial’s loss, generated.
  • explain_network — the course GPT’s network diagram at level 2, generated.
  • memory — presk memory: what a program needs in memory, counted from the program at its dimensions and types: the peak of live bytes and each call’s share, the C program’s arena beside it, a training step under both --remats, the polynomials in the dimensions, the Network tab’s overlay.
  • corpus — models from an NLP course, transcribed as a forcing function.
  • coverage — what the shape fragment can say, measured on the MLPerf architectures; BERT-large run at MLPerf’s constants.
  • precision — precision as a resource: the envelope, the bound and the condition number, sensitivities, the solver and its defaults (the measured rounding term, the cost per sample, three ways to spend the budget), integer weights, a budget on a training step, and what a budget promises.
  • experiments — exact versus almost, the statements of 0.4.0 to 0.10.0 answered by measurement, MLPerf’s rule beside a budget, the three tests of RA4, the C export’s statements, a training step that pays, the solver’s defaults judged out of sample, the rows of record at 0.16.0, and what the experiments do not show.
  • diagnostics — error reports and codes.
  • dependencies — every tool and library, what it is and why.
  • status — what is implemented, step by step.

§Where things are

ItemLocation
Compiler sourcescrates/ of the presk repository (Rust workspace)
Example programs (acceptance tests)tests/examples/ (copied from presk-specs/examples/)
Tutorial programstutorial/*.psk, run by make tutorial
The NLP-course corpuscorpus/nlp/, run by make corpus and make corpus-gpt
MLPerf transcriptionscoverage/, checked by make coverage
Implementation planspresk-specs/implementation/presk-plan-0.1.0.md … presk-plan-0.10.0.md
Experiment scriptsexperiments/*.sh and *.py, run by make curve, quant-table, step-table, j-step, step-train, foil, bert, ra4-small, ra4, ra4-check, ra4-20, ra4-day2, ra4-dev, ra4-ablation, ra4-f2*, ra4-f1*, c-speed and pytorch-baseline
The RA4 measurement of 0.7.0docs/ra4-2026-09-24.md and docs/ra4-20cores-2026-09-24.md, written by presk rank
The RA4 test of 0.8.0the development set under the frozen model, docs/ra4-dev-model-0.8.0.md; the fresh sweeps, docs/ra4-f2-2026-09-25.md, docs/ra4-f1a-2026-09-25.md and docs/ra4-f1b-2026-09-25.md, written by presk rank; the ablation and the rules, docs/ra4-dev-*-2026-09-24.md
Architecture decisionsdocs/decisions.md
Open questions sent to the specificationdocs/spec-questions.md, copied at each version to presk-specs/implementation/presk-spec-questions-0.X.0.md
This manualcrates/presk-manual/manual/*.md, rendered by cargo doc -p presk-manual --open (or make doc)

Modules§

cli
The presk command line: subcommands, flags, exit codes.
corpus
The corpus: models from an NLP course, used as a forcing function.
coverage
Coverage: what the shape fragment can say, measured on the MLPerf architectures — which families are expressible and what the rest cost — and BERT-large run at MLPerf’s constants.
data
Data files: the .psk.d container, presk data, the training pipeline.
dependencies
Every external tool and library, what it is and why it is used.
diagnostics
Diagnostics: how errors are reported and the list of codes.
experiments
Experiments: shapes as types, the realization gap of training against the exact reference, the statements of 0.4.0 to 0.10.0 answered by measurement, MLPerf’s acceptance rule beside a budget, the three tests of RA4, the C export’s statements, and a training step that pays.
explain
presk explain: one compilation as a document, every stage’s representation and its decisions, each figure the commands’ own.
explain_loss
The document presk explain writes for the tutorial’s loss, generated (make explain-manual) and held current by a test.
explain_network
The course GPT’s network diagram at level 2, generated (make network-figure) and held current by a test.
export_c
The C export: an entry as a C program computing the native backend’s bits (presk export --target c), how it is made, its exactness rules, its threads, sampling and integer weights, what is checked, and the SCoP mode for polyhedral tools.
install
Building and running the tool.
language
The Presk language as accepted by this version: lexical structure, declarations, types, expressions, configuration blocks.
memory
presk memory: what a program needs in memory, counted from the program: the peak of live bytes beside the C arena, a training step under both --remats, the polynomials, the page’s overlay (0.15.0).
native
Native execution: the Backend seam, PSK-Kernel v0 and its vector form, realizations, the Cranelift backend, the layouts of a contraction, threads at a depth, the conformance suite.
optimization
Optimization: e-graph rewriting of PSK-Core (--opt, presk dump --stage core-opt), the rules, the oracle, what changes; the calibrated cost models, the layout model’s load term, and what its fresh test found.
precision
Precision as a resource: the magnitude envelope, the bound and the condition number, sensitivities, the solver, integer weights, a budget on the training step, and what a budget does and does not promise.
realize
PSK-Realize: fusion groups, what shares a loop nest, and what that buys; realization plans, a layout per nest, and how a plan is chosen.
serve
Serving: the inference serve block, presk serve on any backend, serve.py in the export.
status
What each version and step implements; what is not there yet.
training
Training: presk train on any backend, the loop, checkpoints, and what a precision budget binds in a training run.
tutorial
A guided tour: write programs, run them, read the errors, export to PyTorch, train, give a budget, choose a layout, export to C, test everything (make tutorial runs every command).