Riftco Transformer has four independent configuration layers: CMake chooses the native engine that is built, backend selectors choose storage and kernels, Python workflow configs choose training behavior, and source-only lab configs choose evaluation protocols. Changing one layer does not silently rewrite another.
Build requirements#
| Requirement | Value |
|---|---|
| CMake | 3.24 or newer |
| C++ | C++20, extensions disabled |
| C ABI consumers | C11, extensions disabled |
| Required dependency | Platform threads |
| Python | 3.10 or newer; zero runtime package dependencies |
| CUDA build | CUDA Toolkit 12 or newer plus a compatible driver/GPU |
| TPU build | Linux x86-64 plus a compatible libtpu.so and Cloud TPU |
CMake options#
| Cache variable | Top-level default | Effect and constraints |
|---|---|---|
RIFTCO_TRANSFORMER_ENABLE_INSTALL | ON | Generates install rules and the exported CMake package. |
RIFTCO_TRANSFORMER_BUILD_PYTHON_WHEEL | OFF | Installs only the C shared library into the wheel layout; driven by pyproject.toml. |
RIFTCO_TRANSFORMER_BUILD_TESTS | BUILD_TESTING at top level; OFF as a subproject | Builds the repository test suite. |
RIFTCO_TRANSFORMER_ENABLE_METAL | ON on Apple; otherwise OFF | Requires an Apple platform. Disable explicitly to exercise the stub. |
RIFTCO_TRANSFORMER_ENABLE_CUDA | OFF | Requires CUDA Toolkit 12+. Cannot be combined with sanitizers. |
RIFTCO_TRANSFORMER_ENABLE_TPU | OFF | Requires Linux x86-64. The runtime is loaded dynamically. |
RIFTCO_TRANSFORMER_ENABLE_SANITIZERS | OFF | Enables AddressSanitizer and UndefinedBehaviorSanitizer with AppleClang, Clang, or GCC. |
Source: CMakeLists.txt, RiftcoTransformerBackends.cmake, and RiftcoTransformerSanitizers.cmake.
When tests are enabled, RIFTCO_TRANSFORMER_BUILD_PYTHON_TESTS defaults to ON. The test-only switches RIFTCO_TRANSFORMER_TEST_REQUIRE_METAL, RIFTCO_TRANSFORMER_TEST_REQUIRE_CUDA, and RIFTCO_TRANSFORMER_TEST_REQUIRE_TPU default to OFF; turn one on to make absence of that accelerator fail the relevant conditional tests instead of skip them.
Presets#
| Preset | Build directory | Important settings |
|---|---|---|
debug | build/debug | Debug, tests on |
release | build/release | Release, tests on |
sanitize | build/sanitize | Debug, tests, ASan + UBSan; unavailable on Windows |
cuda-release | build/cuda-release | Release, tests, CUDA on; hidden on macOS |
tpu-release | build/tpu-release | Release, tests, TPU on, Metal off; Linux only |
tpu-hardware | build/tpu-hardware | Inherits TPU release, requires an addressable TPU, and rejects the repository fake plugin |
bashcmake --preset release
cmake --build --preset release
ctest --preset release
Backend selection#
| Surface | Accepted values | Default |
|---|---|---|
| C++ | ExecutionBackend::{Cpu, Metal, Cuda, Tpu} | Thread-local Cpu |
| Python stage configs | auto, cpu, metal, cuda, tpu | auto |
Python auto selects the first available backend in this order: TPU, CUDA, Metal, CPU. Explicit unavailable selections fail; they never fall back. C++ operations use the intrinsic backend of their tensor inputs, and newly created objects capture the calling thread's construction default. Use Tensor::to, Module::to, or Python .to() for explicit transfer.
Backend limitations and availability probes are documented in Backends and Python ABI.
Native dense Llama/Mistral settings#
LlamaMistralConfig selects the architecture identity plus vocabulary, maximum context, model/feed-forward widths, block count, query/KV head counts, RMSNorm epsilon, and RoPE theta. All dimensions are positive; model width must divide by query heads, query heads by KV heads, and the resulting head width must be even. Epsilon and theta are finite and positive.
An optional sliding window is accepted only when it covers the complete maximum context, where dense causal attention is equivalent. Smaller windows are rejected. The current full-sequence runtime is exposed through native C++, C ABI 2.8, and Python. These surfaces are not external checkpoint or tokenizer loaders and do not add incremental decode semantics. See the complete Llama/Mistral support matrix.
Native C++ serving settings#
stages::serving::ServingConfig#
Defaults: CPU, at most 256 new tokens, paged KV cache, 16-token blocks, and kv_cache_block_count=0. Zero block count allocates enough blocks for one maximum-length context. Serving has no optimizer or gradient settings.
The reusable native serving composition remains framework-owned. Its authoritative declarations are under include/riftco_transformer/stages.
Python stage settings#
Python configs are immutable dataclasses and validate at construction.
PretrainingConfig#
In addition to native model/execution choices, Python controls a validation fraction (0.1), validation batch count (4), evaluation interval (10), loss-average window (10), validation seed (17), and Adam state layout. Defaults are BPE, backend="auto", materialized attention, disabled block checkpointing, contiguous optimizer state, and 4096-element state pages.
PostTrainingConfig#
| Setting | Default | Accepted values or rule |
|---|---|---|
fine_tuning_method | "full" | full, lora, qlora |
sampling_strategy | "example_uniform" | example_uniform, window_uniform |
backend | "auto" | auto, cpu, metal, cuda, tpu |
attention | "materialized" | materialized, flash |
activation_checkpointing | "disabled" | disabled, block |
nf4_block_size | 64 | Power-of-two choice from 32 through 4096 |
nf4_scale_block_size | 256 | Power-of-two choice from 32 through 4096 |
double_quantization | True | Boolean |
optimizer_state | "auto" | auto, contiguous, paged; auto selects paged for QLoRA |
optimizer_page_size | 4096 | Positive scalar count |
serving.ServingConfig#
Defaults: backend="auto", 256 maximum new tokens, 1 MiB maximum request, kv_cache="paged", and block size 16. The HTTP server is dependency-free and is configured through create_http_server or serve_model; there is no installed server CLI.
Source: python/riftco_transformer.
Neural-lowering settings#
lowering::NeuralLoweringConfig belongs only to the optional compiler-to-neural bridge.
| Field | Default | Meaning |
|---|---|---|
strategy | "auto" | auto, linear, linear_attention, dense, mlp, or a registered strategy ID |
automatic_strategy_order | linear, linear-attention, dense | First supported exact strategy wins. |
unsupported_strategy | Reject | Reject or permit dense fallback. |
precision | exact FP32 required | Reject rounded coefficients or allow them. |
initialization | compiled | Preserve compiled coefficients or seeded random-uniform control. |
trainable | false | Expose coefficients through Module::parameters(). |
backend | CPU | Storage/backend for the lowered module. |
seed / random_scale | 42 / 0.02 | Random-control initialization. |
max_coefficient_elements | 2^24 | Pre-allocation safety limit. |
attention_query_axis | unset | Query input for bilinear linear-attention lowering. |
mlp is a registered diagnostic strategy, but the current GELU MLP cannot exactly preserve a general multilinear map. It reports unsupported unless the configured policy permits a dense fallback.
See Compiling to transformers.
Program-augmented model settings#
The C++ ProgramAugmentedModelConfig and installed Python programmed.ProgramAugmentedModelConfig describe only generic model shape and initialization:
| Field | Default | Meaning |
|---|---|---|
vocabulary_size | required in Python | Token embedding and logit width. |
context_length | required in Python | Exact fixed input time dimension. |
model_width / head_count | required in Python | Residual width and heads per causal-attention branch; width must divide evenly. |
feed_forward_width | required in Python | ReLU feed-forward hidden width. |
attention_branch_count | 2 | Number of independent causal-attention modules concatenated before the learned merge; must be at least one. |
attention | "materialized" | Full-sequence materialized or exact memory-linear flash implementation. |
random_seed | 42 | Deterministic learned-parameter initialization. |
An optional Python ProgramBranch adds map, source and target offsets and lengths, logical ProgramInputLayout records, lowering policy, input_projection_bias, and merge_bias. Each layout selects whole_source or one source_position; equal projection_group values share one learned projection and parameter identity. Source and target spans must fit the fixed context, but their offsets are otherwise task-neutral.
ProgramAugmentedForwardOptions controls capture_representations, learned attention batch roll, affine steering, selected program-input batch rolls, program-output batch roll, and their shared positive batch_roll_shift. MultilinearMap.from_sparse accepts output-major nonzero indices and values; the current lowerer still applies max_coefficient_elements before allocating its dense native representation.
Research-lab settings#
Top-level labs/ owns experiment configuration, fixed seeds, candidate construction, held-out selection, and report paths. Those modules compose only public Python framework APIs and are not installed. Inspect a lab's current configuration with:
bashPYTHONPATH=python:. python3 -m labs.lora_rank.run --help
PYTHONPATH=python:. python3 -m labs.fine_tuning.run --help
PYTHONPATH=python:. python3 -m labs.conditional_reverse.run --help
The conditional-reversal lab owns named quick and paper profiles, F/P/T/I variant selection, backend, seeds, data sizes, optimization, validation/test policy, interpretation, and report paths. A short explicit invocation is:
bashPYTHONPATH=python:. python3 -m labs.conditional_reverse.run \
--profile quick --variants F --backend cpu \
--output runs/conditional-reverse/quick.json
Run --help to verify exact current flags and defaults before launching a profile. These settings are lab policy layered over riftco_transformer.programmed; they are not fields added to the C++ generic model.
Environment variables#
| Variable | Use |
|---|---|
RIFTCO_TRANSFORMER_LIBRARY | Exact native shared-library path used by the Python loader. |
RIFTCO_TRANSFORMER_TPU_LIBRARY | Preferred exact libtpu.so path. |
TPU_LIBRARY_PATH | TPU loader fallback before the system libtpu.so lookup. |
RIFTCO_TRANSFORMER_TPU_REJECT_TEST_PLUGIN | Hardware-evidence guard set to 1 by the tpu-hardware test preset; ordinary users should select the preset rather than set it manually. |
CMAKE_ARGS | Standard build-backend mechanism for passing options while installing the Python package from source. |
Example CUDA wheel build:
bashCMAKE_ARGS="-DRIFTCO_TRANSFORMER_ENABLE_CUDA=ON" python3 -m pip install .
For failure diagnosis, use Troubleshooting.