Linear algebra you can step through.
Contiguous row-major tensors, explicit shapes and strides, checked broadcasting, batched matmul, reductions, indexing, and backend-owned storage.
An auditable decoder-only Transformer stack: Python owns training and research orchestration, while the C++20 runtime owns tensor math, autograd, models, Adam, serving primitives, accelerators, and programs compiled into attention.
The readable CPU path defines the numerical contract. Python composes datasets, training loops, evaluation, and labs; C++ implements reusable computation, serving, compilation, and analysis primitives behind stable boundaries.
Contiguous row-major tensors, explicit shapes and strides, checked broadcasting, batched matmul, reductions, indexing, and backend-owned storage.
Fresh operation graphs, reverse-topological traversal, gradient accumulation, finite-difference checks, custom VJPs, and activation checkpoint replay.
Follow backward →Pre-normalized blocks, materialized or exact memory-linear Flash attention, GELU/ReLU feed-forwards, and a causal language-model head.
Model anatomy →Full fine-tuning, low-rank adapters, or QLoRA with frozen blockwise NF4 weights, double-quantized scales, and bounded-page Adam state.
Packed-weight training →Cajal-lite compilation plus dense or sparse map import feeds configurable neural lowering and the generic task-neutral program-augmented model.
program→map→lower→composeStable named traces and differentiable batch-roll/steering sites feed model-neutral PCA and paired causal analysis outside the model.
Analysis stage →Use the dependency-free Python surface for training and labs, link focused native CMake targets for reusable primitives, or build the stack from source. Python calls the same C++ runtime through the stable C ABI.
python3 -m pip install riftco-transformer
python3 -c \
"from riftco_transformer import Context; \
print(Context().backend)"
git clone https://github.com/quangng2000/riftco-transformer.git
cd riftco-transformer
cmake --preset debug
cmake --build --preset debug
ctest --preset debug
PYTHONPATH=python:. python3 -m \
labs.conditional_reverse.run \
--profile quick --variants F \
--backend cpu \
--output runs/conditional-reverse/quick.json
# Verify current flags with --help.
Backend identity belongs to tensor storage. Operations validate shapes and placement, then dispatch through focused storage, math, attention, quantized-linear, and optimizer capabilities.
The complete readable oracle, available in every build.
Persistent shared buffers and native compute kernels on compatible Macs.
Toolkit 12+ source build with managed storage and native kernels.
Linux x86-64 PJRT/StableHLO adapter requiring external libtpu.
Honest boundary: accelerator selection does not imply every operation is device-resident or faster. Autograd scheduling, safety checks, and some reference paths remain host-controlled. Capability matrix →
The framework now exposes generic compilation, lowering, ProgramAugmentedModel execution, stable traces, interventions, and target-time-range loss through ABI 2.8 and riftco_transformer.programmed. The Python lab owns sparse F/P/T/I specifications, data, training, evaluation, analysis, and reports.
Scope: one clean, source-disjoint, current Python-lab run. Program resampling was causal; PCA was descriptive. Selector values come from multiplicative basis masking on a 386-example balanced held-out subset. This is not a multi-seed paper reproduction or a hardware benchmark.
Reviewed run record ↗Exported targets encode the dependency direction, keeping the compiler and interpretation algorithms independent from the tensor runtime.
riftco_transformer::library
riftco_transformer::c_api · ABI 2.8
riftco_transformer::compiler
riftco_transformer::lowering
riftco_transformer::programmed
riftco_transformer::analysis
riftco_transformer.programmed
labs/* · repository only
Learn progressively, solve a focused task, understand a concept, or look up an exact interface. Every page remains connected to its maintained source.
Install, build, and run a verified first example.
Build understanding from tensors through the decoder stack.
Complete focused training, adaptation, and serving tasks.
Understand the algorithms, contracts, and system boundaries.
Look up public APIs, configuration, commands, and terms.
Trace ownership, dispatch, kernels, and extension seams.
Read protocols, evidence, limitations, and interpretation results.
Build, test, document, and extend the framework consistently.
ctypes surface over this native runtime.