ReferenceReference

Configuration reference

Look up CMake backends plus model, program branch, lowering, intervention, training, post-training, and serving configuration contracts.

docs/CONFIGURATION_REFERENCE.md

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#

RequirementValue
CMake3.24 or newer
C++C++20, extensions disabled
C ABI consumersC11, extensions disabled
Required dependencyPlatform threads
Python3.10 or newer; zero runtime package dependencies
CUDA buildCUDA Toolkit 12 or newer plus a compatible driver/GPU
TPU buildLinux x86-64 plus a compatible libtpu.so and Cloud TPU

CMake options#

Cache variableTop-level defaultEffect and constraints
RIFTCO_TRANSFORMER_ENABLE_INSTALLONGenerates install rules and the exported CMake package.
RIFTCO_TRANSFORMER_BUILD_PYTHON_WHEELOFFInstalls only the C shared library into the wheel layout; driven by pyproject.toml.
RIFTCO_TRANSFORMER_BUILD_TESTSBUILD_TESTING at top level; OFF as a subprojectBuilds the repository test suite.
RIFTCO_TRANSFORMER_ENABLE_METALON on Apple; otherwise OFFRequires an Apple platform. Disable explicitly to exercise the stub.
RIFTCO_TRANSFORMER_ENABLE_CUDAOFFRequires CUDA Toolkit 12+. Cannot be combined with sanitizers.
RIFTCO_TRANSFORMER_ENABLE_TPUOFFRequires Linux x86-64. The runtime is loaded dynamically.
RIFTCO_TRANSFORMER_ENABLE_SANITIZERSOFFEnables 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#

PresetBuild directoryImportant settings
debugbuild/debugDebug, tests on
releasebuild/releaseRelease, tests on
sanitizebuild/sanitizeDebug, tests, ASan + UBSan; unavailable on Windows
cuda-releasebuild/cuda-releaseRelease, tests, CUDA on; hidden on macOS
tpu-releasebuild/tpu-releaseRelease, tests, TPU on, Metal off; Linux only
tpu-hardwarebuild/tpu-hardwareInherits TPU release, requires an addressable TPU, and rejects the repository fake plugin
bashcmake --preset release
cmake --build --preset release
ctest --preset release

Backend selection#

SurfaceAccepted valuesDefault
C++ExecutionBackend::{Cpu, Metal, Cuda, Tpu}Thread-local Cpu
Python stage configsauto, cpu, metal, cuda, tpuauto

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#

SettingDefaultAccepted 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_size64Power-of-two choice from 32 through 4096
nf4_scale_block_size256Power-of-two choice from 32 through 4096
double_quantizationTrueBoolean
optimizer_state"auto"auto, contiguous, paged; auto selects paged for QLoRA
optimizer_page_size4096Positive 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.

FieldDefaultMeaning
strategy"auto"auto, linear, linear_attention, dense, mlp, or a registered strategy ID
automatic_strategy_orderlinear, linear-attention, denseFirst supported exact strategy wins.
unsupported_strategyRejectReject or permit dense fallback.
precisionexact FP32 requiredReject rounded coefficients or allow them.
initializationcompiledPreserve compiled coefficients or seeded random-uniform control.
trainablefalseExpose coefficients through Module::parameters().
backendCPUStorage/backend for the lowered module.
seed / random_scale42 / 0.02Random-control initialization.
max_coefficient_elements2^24Pre-allocation safety limit.
attention_query_axisunsetQuery 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:

FieldDefaultMeaning
vocabulary_sizerequired in PythonToken embedding and logit width.
context_lengthrequired in PythonExact fixed input time dimension.
model_width / head_countrequired in PythonResidual width and heads per causal-attention branch; width must divide evenly.
feed_forward_widthrequired in PythonReLU feed-forward hidden width.
attention_branch_count2Number 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_seed42Deterministic 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#

VariableUse
RIFTCO_TRANSFORMER_LIBRARYExact native shared-library path used by the Python loader.
RIFTCO_TRANSFORMER_TPU_LIBRARYPreferred exact libtpu.so path.
TPU_LIBRARY_PATHTPU loader fallback before the system libtpu.so lookup.
RIFTCO_TRANSFORMER_TPU_REJECT_TEST_PLUGINHardware-evidence guard set to 1 by the tpu-hardware test preset; ordinary users should select the preset rather than set it manually.
CMAKE_ARGSStandard 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.