paiml/aprender
소개
Next Generation Machine Learning, Statistics and Deep Learning in PURE Rust
과학 및 공학측정된 스타 증가
- in 24h
- +1
- in 7 days
- +2
- in 15 days
- +5
- in 1 month
- +7
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalschema_version: "1.0" kind: library entrypoints: [crates/aprender-contracts-cli] contract_count: 1837
aprender
Next-generation ML framework in pure Rust — cargo install aprender for the apr CLI
What it is
A machine-learning framework in pure Rust. One cargo install gives you apr, a single binary that runs, serves, fine-tunes, quantizes and inspects models in GGUF, SafeTensors and its own .apr format. The same code is available as a Rust library.
Install
cargo install aprender # CPU build, no GPU backend
The default build is CPU only. GPU backends and the training and visualization extras are feature flags. A pre-built binary for Linux (x86_64 and aarch64) has an installer that verifies the release archive against its published checksum; download it and read it before you run it.
cargo install aprender --features cuda
cargo install aprender --features full
curl -LsSf https://paiml.com/apr/install.sh -o install.sh
sh install.sh
First run, with a model fetched from Hugging Face:
apr run hf://Qwen/Qwen2.5-Coder-0.5B-Instruct "Explain quicksort." --temperature 0
Quick start
cargo install aprender
apr run hf://Qwen/Qwen2.5-Coder-0.5B-Instruct "Explain quicksort in three sentences."
apr run downloads the model, caches it and generates. apr list shows what is cached and apr rm removes it. These are the target commands of the first-run plan; not all of them work in the current release yet, and #7477 tracks which do.
What apr does
| Stage | Commands |
|---|---|
| Inference | apr run, apr chat, apr serve |
| Training | apr finetune, apr train, apr pretrain, apr distill |
| Model operations | apr convert, apr quantize, apr merge, apr export, apr compile |
| Inspection | apr inspect, apr validate, apr tensors, apr diff, apr trace, apr lint |
| Profiling | apr profile, apr bench, apr qa |
| Registry | apr pull, apr list, apr rm, apr publish, apr registry |
| GPU | apr gpu, apr parity, apr ptx |
| Observability | apr tui, apr monitor, apr cbtop |
apr --help lists every command, and the book has a chapter for each. The command tour takes one model through them.
Usage
The apr commands:
| Command | What it does |
|---|---|
apr run |
Run model directly (auto-download, cache, execute) |
apr serve |
Inference server (plan/run) |
apr inspect |
Inspect model metadata, vocab, and structure |
apr debug |
Simple debugging output ("drama" mode available), or a debug subcommand |
apr validate |
Validate model integrity and quality |
apr validate-manifest |
Validate a publish manifest (FALSIFY-PM-001..006) |
apr diff |
Compare two models |
apr tensors |
List tensor names and shapes |
apr trace |
Layer-by-layer trace analysis |
apr lint |
Check for best practices and conventions |
apr beat-run |
Evaluate a BeatBenchmark contract against a measured value (PMAT-741) |
apr manifest |
Emit a SHA-256 manifest of input files (CRUX-G-05) |
apr explain |
Explain errors, architecture, tensors, and kernel dispatch |
apr canary |
Manage canary tests for regression |
apr export |
Export model to other formats |
apr import |
Import from external formats (hf://org/repo, local files, URLs) |
apr pull |
Download and cache model OR HuggingFace dataset (Ollama-like UX) |
apr registry |
Registry operations (CRUX-A-01): inspect alias map, etc |
apr list |
List cached models |
apr rm |
Remove model from cache |
apr convert |
Convert/optimize model |
apr stamp |
Stamp provenance fields (license, data_source, data_license) onto an existing .apr file |
apr compile |
Compile model into standalone executable (APR-SPEC §4.16) |
apr merge |
Merge multiple models |
apr quantize |
Quantize model weights (GH-243) |
apr finetune |
Fine-tune model with LoRA/QLoRA (GH-244) |
apr prune |
Prune model (structured/unstructured pruning) (GH-247) |
apr distill |
Knowledge distillation (teacher -> student) (GH-247, ALB-011) |
apr mcp |
Start the MCP (Model Context Protocol) server over stdio |
apr tui |
Interactive terminal UI |
apr check |
Model self-test: 10-stage pipeline integrity check (APR-TRACE-001) |
apr gpu |
GPU status and VRAM reservation management (GPU-SHARE-001) |
apr code |
Sovereign AI coding assistant — all inference local via realizar (PMAT-182) |
apr chat |
Interactive chat with language model |
apr bench |
Benchmark throughput (spec H12: >= 10 tok/s) |
apr eval |
Evaluate model perplexity (spec H13: PPL <= 20) or classification metrics |
apr profile |
Deep profiling with Roofline analysis |
apr qa |
Falsifiable QA checklist for model releases |
apr parity |
GPU/CPU parity check (PMAT-232: genchi genbutsu — see where GPU diverges) |
apr ptx-map |
Model-to-PTX source mapping (Mieruka: make GPU kernel dispatch visible) |
apr ptx |
PTX analysis and bug detection [unavailable in this build: cargo install aprender --features ptx; apr ptx-debug is always built] |
apr tune |
ML tuning: LoRA/QLoRA configuration, memory planning, and HPO (GH-176, SPEC-TUNE-2026-001) |
apr monitor |
Attach live TUI to a running training session |
apr runs |
List, show, and compare training experiment runs |
apr experiment |
Interactive experiment browser (TUI with loss curves) |
apr cbtop |
ComputeBrick pipeline monitor (cbtop) |
apr test |
Test harness for web, LLM, media and replay — powered by probador |
apr compare-hf |
Compare APR model against HuggingFace source |
apr modelfile |
CRUX-K-11: parse Ollama-style Modelfile DSL into apr config |
apr hex |
Format-aware binary forensics (10X better than xxd) |
apr capability |
What this build can and cannot do, and why — read from the capability contract (#3856) |
apr devices |
Backend discovery: probe, enumerate, print — every kind is a line (PP-066 R-0) |
apr tree |
Model architecture tree view |
apr flow |
Data flow visualization |
apr qualify |
Cross-subcommand smoke test (does every tool handle this model?) |
apr train |
Training pipeline (plan/apply) — forjar-style pre-flight validation |
apr pretrain |
Pretraining loop driver (SHIP-TWO-001 MODEL-2) |
apr tokenize |
Tokenizer training pipeline (plan/apply) — BPE vocabulary learning |
apr data |
Data quality pipeline (audit, split, balance) — powered by alimentar |
apr pipeline |
Pipeline orchestration (plan/apply/status) — wraps forjar DAG engine |
apr diagnose |
Automated Five Whys diagnosis on a training checkpoint |
apr ollama-chat-lint |
Lint an Ollama /api/chat response for schema + NDJSON invariants (CRUX-C-04) |
apr ollama-tools-lint |
Lint an Ollama /api/chat function-calling response (CRUX-I-04) |
apr dry-sampling-lint |
Lint a captured DRY-sampling observation (CRUX-C-23) |
apr awq-lint |
Lint a captured AWQ quality/compression/flags observation (CRUX-B-08) |
apr fp8-lint |
Lint a captured FP8 (E4M3) round-trip + SM-capability observation (CRUX-B-11) |
apr nf4-lint |
Lint a captured NF4 codebook/roundtrip/storage/parity observation (CRUX-B-10) |
apr gptq-lint |
Lint a captured GPTQ compression/cosine/flags observation (CRUX-B-09) |
apr oom-lint |
Lint a captured CUDA OOM postmortem report (CRUX-F-13) |
apr nccl-diag-lint |
Lint a captured NCCL failure-diagnostics JSON from stderr (CRUX-F-15) |
apr react-trace-lint |
Lint an externally captured ReAct loop trace JSON (CRUX-I-06 — no apr producer yet) |
apr hang-trace-lint |
Lint a captured $APR_TRACE_DIR hang stack-dump directory (CRUX-F-14) |
apr ddp-metrics-lint |
Lint two externally captured DDP metrics JSONs, N=1 and N=k (CRUX-D-11 — no apr producer yet) |
apr dataset |
Dataset inspection tools (CRUX-H-13) |
apr kernel |
Kernel-level parity measurements (CRUX-L-02) |
apr audio-inspect-lint |
Lint an audio-inspect JSON body, e.g. from apr dataset audio-inspect clip.wav --format json -o audio.json (CRUX-H-13) |
apr attn-parity-lint |
Lint attention parity + provenance JSON, e.g. from apr kernel parity --impl tiled --ref naive --json -o parity.json (CRUX-L-02) |
apr attn-viz-lint |
Lint an externally captured attention dump (CRUX-F-17 — no apr producer yet) |
apr check-finite-lint |
Lint an externally captured check-finite error and/or coverage JSON (CRUX-F-11 — no apr producer yet) |
apr embed-viz-lint |
Lint an embedding-projection CSV, e.g. from apr debug embed-viz --model model.apr --seed 42 -o emb.csv (CRUX-F-18) |
apr explain-token-lint |
Lint an externally captured token-selection JSONL trace (CRUX-F-19 — no apr producer yet) |
apr gpu-memtrace-lint |
Lint a captured GPU memory Chrome Trace Event Format JSON (CRUX-F-07) |
apr kv-timeline-lint |
Lint a captured KV-cache utilization timeline (CRUX-F-06) |
apr otlp-lint |
Lint a captured OTLP/JSON ExportTraceServiceRequest body (CRUX-K-08) |
apr prometheus-lint |
Lint a captured Prometheus /metrics response (CRUX-K-07) |
apr tool-use-lint |
Lint a captured OpenAI tool-use response (CRUX-C-11) |
apr gbnf-lint |
Lint a GBNF grammar-constrained observation (CRUX-C-10) |
apr typical-p-lint |
Lint a typical-p sampling observation (CRUX-C-22) |
apr grad-norm |
Gradient-norm telemetry analysis (CRUX-F-09) |
apr registry-quota-lint |
Lint a captured registry byte-quota observation (CRUX-A-22) |
apr imatrix-lint |
Lint a captured imatrix calibration observation (CRUX-B-07) |
apr embeddings-lint |
Lint a captured /v1/embeddings observation (CRUX-C-13) |
apr unified-search-lint |
Lint a captured Hub+local unified-search merge observation (CRUX-A-23) |
apr rm-gc-lint |
Lint a captured apr rm / externally captured gc blob-GC observation (CRUX-A-25) |
apr shared-cache-lint |
Lint a captured APR_MODELS shared-cache observation (CRUX-A-21) |
apr ppl |
Perplexity classifier (CRUX-E-02) |
apr quant-preservation-lint |
Validate dequant→requant metadata preservation (CRUX-B-19) |
apr shard |
Split a safetensors file into shards + weight-map index (CRUX-B-05) |
apr unshard |
Reconstruct a single safetensors file from a sharded directory (CRUX-B-05) |
apr showcase |
Qwen2.5-Coder showcase demo |
apr rosetta |
Rosetta Stone - Universal model format converter (PMAT-ROSETTA-001) |
apr publish |
Publish model to HuggingFace Hub (APR-PUB-001) |
apr oracle |
Model Oracle: identify family, size, constraints, and contract compliance |
apr encrypt |
Encrypt model weights at rest using BLAKE3-derived keystream + MAC |
apr decrypt |
Decrypt model weights encrypted with apr encrypt |
apr rerank |
Score a query/passage pair (or rank multiple passages) with a BERT cross-encoder loaded from an APR v2 file (GH-326 Phase 3) |
apr embed |
Produce sentence embeddings from a BERT APR file or an EmbeddingGemma 2 GGUF file |
apr rag |
RAG pipeline: index, query, transcribe (was the trueno-rag binary) |
apr zram |
zram device management (was the trueno-zram binary) |
apr sim |
Discrete-event simulation: run, render, validate, verify, emc-check (was the simular binary) |
apr cgp |
Compute-graph profiling: profile, bench, roofline, doctor (was the aprender-cgp binary) |
apr ptx-debug |
PTX falsification analysis and FKR test generation: analyze, gen-fkr (was the aprender-ptx-debug binary; pure Rust, so unlike apr ptx it needs no build feature) |
apr pv |
Provable-contracts: validate, lint, score, kani, proof-status (the pv binary keeps shipping under its own name; this is the in-apr route to the same commands) |
apr plot |
Draw a plot from CSV data (terminal or SVG), limited to the grammar the ggplot2 conformance rows prove. Proven-only: refuses by name whatever no ggplot2 row proves |
apr readme |
README.md rendered from docs/readme/: render, comply, score |
apr map |
Map artefacts (APR-MAP-001 MAP-4): bundle writes a parquet bundle from shapes and a CSV |
Serve a model
apr serve exposes an OpenAI-style chat completions endpoint:
apr serve run Qwen/Qwen2.5-Coder-0.5B-Instruct --port 18080 &
curl -sf localhost:18080/v1/chat/completions -H content-type:application/json \
-d '{"model":"Qwen/Qwen2.5-Coder-0.5B-Instruct","messages":[{"role":"user","content":"What is 2+2?"}]}'
Wait until the server answers on /health before the first request. It runs until you stop it (kill %1).
Library usage
// Fit a line with the `aprender` library. The README includes this file verbatim.
use aprender::linear_model::LinearRegression;
use aprender::prelude::{Matrix, Vector};
use aprender::traits::Estimator;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// y = 2x + 1
let x = Matrix::from_vec(4, 1, vec![1.0, 2.0, 3.0, 4.0])?;
let y = Vector::from_slice(&[3.0, 5.0, 7.0, 9.0]);
let mut model = LinearRegression::new();
model.fit(&x, &y)?;
assert!(model.score(&x, &y) > 0.99);
Ok(())
}
Library coverage
The library covers linear and logistic regression, decision trees, random forests, gradient boosting, naive Bayes, KNN, SVM, k-means, PCA, ICA, ARIMA, GLMs, graph algorithms, Bayesian inference, and text and audio processing. API documentation is on docs.rs.
Workspace
Workspace crates:
| Crate | Description |
|---|---|
apr-cli |
CLI tool for APR model inspection, debugging, and operations |
apr-format |
Sovereign .apr model container format (read + write, v1 APRN + v2 APR\0) — zero ML/GPU/tokenizer dependencies |
aprender |
Next-generation ML framework in pure Rust — cargo install aprender for the apr CLI |
aprender-bench-compute |
Head-to-head compute benchmarks: aprender/trueno vs ndarray for LLM inference hotspots |
aprender-bench-tokenizer |
Head-to-head BPE tokenizer benchmarks: aprender vs HuggingFace tokenizers v0.22 |
aprender-build-sha |
Build-script helper that stamps APR_GIT_SHA into every aprender binary's --version |
aprender-cbtop |
Compute Block Top - Real-time load testing and hardware monitoring TUI |
aprender-cgp |
Compute-GPU-Profile: Unified performance analysis CLI for scalar, SIMD, wgpu, and CUDA workloads |
aprender-ci-tools |
CI and build helpers ported from scripts/**/*.py (C301: no Python in the build) |
aprender-common |
Shared utilities for the Batuta stack: formatting, system info, display helpers |
aprender-compute |
High-performance SIMD compute library with GPU support, LLM inference engine, and GGUF model loading (was: trueno) |
aprender-compute-xtask |
|
aprender-contracts |
Papers to Math to Contracts in Code — YAML contract parsing, validation, scaffold generation, and Kani harness codegen for provable Rust kernels |
aprender-contracts-cli |
CLI for provable-contracts — validate, scaffold, verify, status, audit |
aprender-contracts-macros |
Proc macros for compile-time contract enforcement — #[contract] attribute |
aprender-contrastive-data |
Deterministic, leakage-safe contrastive data construction: class buckets, balanced few-shot selection, bounded pair sampling |
aprender-core |
Next-generation machine learning library in pure Rust |
aprender-cuda-edge |
GPU edge-case test framework — null fuzzing, shared memory probing, lifecycle chaos, quantization parity, PTX poison trapping |
aprender-cupti |
Rust bindings for NVIDIA CUPTI profiling - ComputeBrick analysis |
aprender-data |
Data Loading, Distribution and Tooling in Pure Rust |
aprender-db |
GPU-first embedded analytics database with SIMD fallback and SQL query interface |
aprender-decide |
Method-neutral decision models (Laya first) over aprender-core |
aprender-distribute |
Sovereign AI-grade distributed computing primitives for Rust (CPU, GPU, HPC) |
aprender-explain |
PTX/SIMD/wgpu visualization and tracing CLI for Trueno |
aprender-fft |
Fast Fourier Transform — Stockham auto-sort algorithm with SIMD acceleration |
aprender-gemm-codegen |
Compile-time GEMM microkernel code generation for trueno (sovereign, no external BLAS) |
aprender-gpu |
Pure Rust PTX generation for NVIDIA CUDA - no LLVM, no nvcc |
aprender-graph |
GPU-first embedded graph database for code analysis (call graphs, dependencies, AST traversals) |
aprender-image |
GPU image processing primitives — convolution, Gaussian blur, Sobel, Canny edge detection |
aprender-legacy-codec |
serde codec that reads and writes the bincode 1.x legacy layout byte-for-byte (fixint, little-endian), without the unmaintained bincode crate (RUSTSEC-2025-0141) |
aprender-mcp |
Model Context Protocol (MCP) server for aprender — exposes apr CLI as MCP tools |
aprender-monte-carlo |
Monte Carlo simulations for finance, stock market, and business forecasting |
aprender-orchestrate |
Sovereign AI orchestration: autonomous agents, ML serving, code analysis, and transpilation pipelines |
aprender-present-cli |
CLI for Presentar WASM apps - serve and bundle |
aprender-present-core |
Core types and traits for Presentar UI framework |
aprender-present-layout |
Layout engine for Presentar UI framework |
aprender-present-lib |
WASM-first visualization and rapid application framework |
aprender-present-terminal |
Terminal backend for Presentar UI framework with zero-allocation rendering |
aprender-present-test |
Testing harness for Presentar applications |
aprender-present-test-macros |
Proc macros for Presentar testing framework |
aprender-present-widgets |
Widget implementations for Presentar UI framework |
aprender-present-yaml |
YAML manifest parser for Presentar UI framework |
aprender-profile |
Pure Rust system call tracer with source-aware correlation for Rust binaries |
aprender-profile-core |
Core tracing primitives for renacer — zero-dep span/event types for CPU-GPU pipelining instrumentation |
aprender-ptx-debug |
Pure Rust PTX debugging and static analysis tool |
aprender-qa-certify |
Model certification tools and README synchronization |
aprender-qa-cli |
CLI for APR model qualification testing |
aprender-qa-gen |
Property-based scenario generator for APR model qualification |
aprender-qa-report |
Popperian report generator and MQS scoring for APR model qualification |
aprender-qa-runner |
Playbook executor for APR model qualification testing |
aprender-quant |
K-quantization formats (Q4_K, Q5_K, Q6_K) for GGUF/APR model weights |
aprender-rag |
Pure-Rust Retrieval-Augmented Generation pipeline built on Trueno |
aprender-rag-cli |
CLI for Trueno-RAG pipeline |
aprender-rand |
Counter-based parallel RNG — Philox 4x32-10 with provable statistical properties |
aprender-registry |
Model, Data and Recipe Registry with full lineage tracking |
aprender-review-experiment |
REX-001 review-lane experiment: pre-registration lock, corpus, receipts and the frozen analysis code (Wilson, McNemar exact, seeded bootstrap, Holm) |
aprender-rollup |
Rollup bot core: picks small green PRs to land as one merge-queue entry (T-rollup, #5394) |
aprender-serve |
Pure Rust ML inference engine built from scratch - model serving for GGUF and safetensors |
aprender-shell |
AI-powered shell completion trained on your history |
aprender-simulate |
Unified Simulation Engine for the Sovereign AI Stack |
aprender-solve |
Dense linear algebra solvers — LU, QR, SVD, Cholesky with provable contracts |
aprender-sparse |
Sparse matrix formats and operations — CSR, COO, BSR with SIMD-accelerated SpMV/SpMM |
aprender-tensor |
N-dimensional tensor contractions — Einstein summation via TTGT (cuTENSOR parity) |
aprender-test-cli |
CLI for Probar: Rust-native testing framework for WASM games |
aprender-test-derive |
Proc-macro crate for Probar type-safe ECS selectors (Poka-Yoke) |
aprender-test-js-gen |
NASA/DO-178B-grade Rust DSL for type-safe JavaScript generation |
aprender-test-lib |
Probar: Rust-native testing framework with pixel coverage, TUI snapshots, and visual regression |
aprender-test-showcase |
100% test coverage calculator showcase demonstrating Probar TUI + WASM testing |
aprender-train |
Training & Optimization library with autograd, LoRA, quantization, and model merging |
aprender-train-bench |
Distillation benchmarking and hyperparameter sweep tool |
aprender-train-common |
Shared infrastructure for entrenar CLI tools |
aprender-train-distill |
End-to-end knowledge distillation CLI |
aprender-train-inspect |
SafeTensors model inspection and format conversion |
aprender-train-lora |
LoRA/QLoRA configuration optimizer and memory planner |
aprender-train-shell |
Interactive REPL for HuggingFace model exploration and distillation |
aprender-train-wasm |
WASM bindings for Entrenar training monitor |
aprender-tsp |
Local TSP optimization with personalized .apr models |
aprender-update |
Update check and self-update for sovereign binaries: newer of release and green nightly, sha256-verified, atomic swap |
aprender-verify |
A scientific experiment into realistic provability with Rust - asymptotic test effectiveness framework |
aprender-verify-ml |
Synthetic Data Factory for Domain-Specific Code Intelligence |
aprender-viz |
SIMD/GPU/WASM-accelerated visualization library for data science and ML |
aprender-zram |
SIMD-accelerated LZ4/ZSTD compression engine for Linux zram devices |
aprender-zram-adaptive |
ML-driven compression algorithm selection for trueno-zram |
aprender-zram-cli |
CLI tool for zram device management (zramctl replacement) |
aprender-zram-core |
SIMD-accelerated LZ4/ZSTD compression for memory pages |
aprender-zram-generator |
systemd generator for zram device configuration |
Make targets
| Target | What it does |
|---|---|
make test-smoke |
Smoke tests (<2s target, Section P: P2) |
make test-fast |
Fast unit tests (<30s target) |
make test |
Standard tests (<2min target) |
make test-full |
Comprehensive tests (all features) |
make coverage |
Coverage summary + threshold check (warm: ~3min) |
make book-build |
Build the book |
make contract-validate |
Validate all kernel contracts (schema + staleness) |
make lint-scripts |
Lint shell scripts with bashrs (determinism + idempotency + safety) |
make guards-local |
Run every guard-cargo/guard-tree step CI runs, all of them, streaming |
make gate |
Fail-closed, comparand-pinned composite gate (BSE-16) |
make hooks-install |
Install PMAT pre-commit hooks |
Quality signal
cargo test -p aprender-contracts --test validate_contracts
cargo test -p aprender-contracts --test probar_test_generation
bash scripts/contracts_gate.sh
bash scripts/check_readme_claims.sh
Provable contracts
Each CLI command and compute kernel is bound to a YAML contract that states its equations, preconditions and postconditions, with tests written to falsify them. CI fails when code and contract disagree.
equations:
validate_exit_code:
formula: exit_code = if score < 50 then 5 else 0
invariants:
- score < 50 implies exit_code != 0
falsification_tests:
- id: FALSIFY-CLI-001
prediction: apr validate bad-model.apr exits non-zero
The contracts live under contracts/ and cover inference, training, quantization, tokenization, model formats and the CLI.
Documentation
- Book: a chapter for each CLI command and library module.
paiml/apr-cookbook: worked examples, from data preparation to serving.- Command tour: one model through download, inspection, conversion, inference, serving and profiling.
- Migration guide: moving from the
trueno,entrenar,realizarandbatutacrates. - GPU support.
- Architecture: the crate layout.
- Known issues: open limits on particular hardware and models.
- Performance: where a throughput figure comes from and when it may be quoted.
- Benchmarks you can rerun:
paiml/candle-vs-aprfor inference andpaiml/ground-truth-apr-ludwigfor training.
Contributing
Open an issue or a pull request. This file is rendered: edit docs/readme/, then run apr readme render --lock and commit the result. apr readme comply runs in CI.
License
MIT. See LICENSE.
관련 프로젝트 살펴보기
불러오는 중…