Configuration Reference
- material-cpu-64-bit:
ModelConfig
Architecture-only config for
Transformer. Use with the new Paradigm API.- material-lightning-bolt:
TrainingConfig
Training hyper-parameters, dataset, and device settings. Completely independent of architecture.
- material-file-cog:
Config (monolithic)
Legacy flat config used by the CLI and YAML files. Combines all fields from both classes above.
- material-wave:
FlowMatchingConfig
Architecture config for
FlowMatchingTransformer(the continuous flow-matching / ELF-recipe paradigm).ELFConfigis a deprecated alias for the same class.
!!! abstract “Key constraint”
dim must always equal n_heads × head_size. This is validated in __post_init__ and will raise ValueError if violated.
```python
ModelConfig(dim=512, n_heads=8, head_size=64) # ✓ 512 = 8 × 64
ModelConfig(dim=512, n_heads=8, head_size=32) # ✗ raises ValueError
```
ModelConfig
Architecture specification for Transformer (AR and Diffusion). Everything here describes what the model is — not how it trains.
import dantinox as dx
# The paradigm= key selects which training objective and generation strategy to use
cfg = dx.ModelConfig(paradigm="ar", dim=512, n_heads=8, head_size=64,
num_blocks=12, vocab_size=32000)
paradigm = dx.Paradigm(cfg) # causal=True set automatically for "ar"
Paradigm selection
Field |
Type |
Default |
Valid values |
Description |
|---|---|---|---|---|
|
|
|
|
Selects the training objective and generator. Also auto-configures |
causal is set automatically when paradigm is provided:
paradigm in ("ar", "embedder")→causal=Trueparadigm in ("discrete", "continuous")→causal=False
Core dimensions
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Model hidden dimension. Must equal |
|
|
|
Number of query attention heads. |
|
|
|
Per-head key/value dimension. |
|
|
|
Number of transformer layers. |
|
|
|
Vocabulary size. Auto-set from the tokenizer by |
|
|
|
Maximum sequence length for positional encoding and KV cache. |
Architecture choices
Field |
Type |
Default |
Valid values |
Description |
|---|---|---|---|---|
|
|
|
|
Attention variant. |
|
|
|
|
Feed-forward variant. |
|
|
|
|
Normalisation type. |
|
|
|
|
Positional encoding. |
|
|
|
— |
|
Embedder fields (paradigm="embedder")
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Pooling strategy for sentence representation: |
|
|
|
InfoNCE softmax temperature. |
Regularisation
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Dropout probability after attention and FFN. |
|
|
|
Tie input embedding and output projection (reduces parameters). |
|
|
|
Recompute activations in backward pass — saves memory, costs extra FLOPs. |
Attention settings
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
KV heads for GQA. |
|
|
|
Flash Attention kernel (requires Ampere GPU or newer). |
|
|
|
RoPE frequency scaling. Values > 1 extend the effective context window. |
|
|
|
Limit attention to a local sliding window. |
|
|
|
Number of blocks in the sliding window (used when |
|
|
|
Disable attention sink token. |
??? note “MLA-specific fields”
Only relevant when attention="mla". Skip if using MHA or GQA.
| Field | Type | Default | Description |
|:------|:-----|:-------:|:------------|
| `down_dim_q` | `int` | `256` | Query latent compression dimension. |
| `down_dim_kv` | `int` | `256` | Key/value latent compression dimension. |
| `rope_dim` | `int` | `32` | RoPE subspace dimension. Must be ≤ `head_size`. |
| `inference_mode` | `bool` | `False` | Absorb KV projection at inference for reduced compute. |
Feed-forward
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
FFN hidden width = |
|
|
|
SwiGLU gate activation (gated linear unit). |
|
|
|
Activation when |
??? note “MoE fields (ffn=”moe” only)”
Only relevant when ffn="moe". Skip for dense models.
| Field | Type | Default | Description |
|:------|:-----|:-------:|:------------|
| `n_experts` | `int` | `4` | Number of expert FFN heads. |
| `top_k` | `int` | `2` | Active experts per token. |
| `moe_balance_coeff` | `float` | `0.1` | Load-balancing auxiliary loss coefficient. |
LoRA
!!! tip “LoRA fine-tuning”
Set use_lora=True to inject adapter matrices. The Trainer automatically freezes base nnx.Param weights — only LoRAParam weights are updated. See Cookbook → LoRA fine-tuning.
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Inject LoRA adapters. When |
|
|
|
Rank |
|
|
|
Scaling factor; effective LR multiplier = |
|
|
|
Dropout inside LoRA adapters. |
|
|
|
Where to inject: |
TrainingConfig
Training hyperparameters, dataset, and hardware settings. Completely independent of model architecture — mix and match with any ModelConfig.
from dantinox.core.config import TrainingConfig
cfg = TrainingConfig(lr=3e-4, batch_size=32, epochs=100, optimizer="adamw")
Optimisation
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Peak learning rate (after warmup). |
|
|
|
Micro-batch size per device per step. |
|
|
|
Gradient accumulation steps. Effective batch = |
|
|
|
Maximum training epochs. |
|
|
|
Linear warmup steps before LR schedule begins. |
|
|
|
LR schedule after warmup: |
|
|
|
Optimizer: |
|
|
|
Global gradient-norm clipping threshold. |
|
|
|
Early stopping patience in epochs. |
|
|
|
Validation batches per evaluation. |
|
|
|
Random seed for weight initialisation and data shuffling. |
|
|
|
bfloat16 mixed precision. Requires NVIDIA Ampere+. |
Hardware
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
GPU count. |
Dataset
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
|
|
|
HuggingFace dataset identifier (e.g. |
|
|
|
HuggingFace dataset config (e.g. |
|
|
|
Column containing text in HF datasets. |
|
|
|
Dataset split to use. |
|
|
|
Token budget for training. Corpus is truncated if larger. |
|
|
|
HF streaming mode — avoids downloading the full dataset. |
Tokenizer
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
|
|
|
HF tokenizer identifier (e.g. |
Diffusion training
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Masking schedule: |
Config (monolithic)
The Config class is the legacy flat config used by the CLI and YAML files. It combines all ModelConfig and TrainingConfig fields, plus continuous flow-matching fields.
!!! tip “Prefer the split API for new experiments”
Use ModelConfig + TrainingConfig for new code — the split is cleaner and more composable. Use Config when working with the CLI, existing YAML files, or Trainer directly.
cfg = Config.from_yaml("configs/medium_gqa.yaml")
# Convert to split APIs when needed
model_cfg = cfg.to_model_config()
elf_cfg = cfg.to_elf_config() # only when model_type="elf"
Architecture fields (Config-specific names)
The field names below are what Config uses; where the name differs from ModelConfig the equivalent is noted.
Field |
Type |
Default |
Notes |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Auto-set from tokenizer by |
|
|
|
|
|
|
|
GQA KV heads. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Equivalent to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Diffusion fields
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Total noise levels |
|
|
|
|
|
|
|
Token ID used as the MASK symbol. |
|
|
|
Denoising steps at inference (≤ |
Discrete diffusion in DantinoX has no time conditioning — the backbone is
a plain bidirectional transformer with no AdaLayerNorm and no time-embedding
MLP (core/diffusion.py explicitly runs “bidirectional transformer, no
AdaLayerNorm”). time_emb_dim (below) belongs to the flow-matching fields,
not diffusion, even though it’s stored on the same monolithic Config object.
Continuous flow-matching fields
??? note “Continuous flow-matching fields — expand for details”
Only relevant when model_type="elf". The shared fields (dim, n_heads, etc.) are reused from the architecture section above.
| Field | Type | Default | Description |
|:------|:-----|:-------:|:------------|
| `embed_dim` | `int` | `512` | Token embedding / flow-space dimension. |
| `bottleneck_dim` | `int` | `128` | Bottleneck between embed space and transformer. |
| `time_emb_dim` | `int` | `256` | Sinusoidal embedding dimension for `t` and the CFG scale `w`, projected into control tokens (not `AdaLayerNorm` — continuous flow-matching uses control tokens, not adaptive norm conditioning). |
| `num_time_tokens` | `int` | `4` | Control tokens encoding timestep `t`. |
| `num_cfg_tokens` | `int` | `4` | Control tokens encoding CFG scale `w`. |
| `num_mode_tokens` | `int` | `4` | Control tokens encoding denoiser/decode mode. |
| `denoiser_pmean` | `float` | `-1.5` | Logit-normal time sampling mean (training). |
| `denoiser_pstd` | `float` | `0.8` | Logit-normal time sampling std. |
| `denoiser_noise_scale` | `float` | `2.0` | ε corruption scale — denoiser branch. |
| `decoder_pmean` | `float` | `0.8` | Logit-normal p mean — decoder branch. |
| `decoder_pstd` | `float` | `0.8` | Logit-normal p std — decoder branch. |
| `decoder_noise_scale` | `float` | `5.0` | ε corruption scale — decoder branch. |
| `denoiser_prob` | `float` | `0.8` | Fraction of training steps using the denoiser branch. |
| `self_cond_prob` | `float` | `0.5` | Probability of using self-conditioning. |
| `cfg_scale_min` | `float` | `0.5` | Min CFG scale during training. |
| `cfg_scale_max` | `float` | `5.0` | Max CFG scale during training. |
| `elf_cfg_scale` | `float` | `1.0` | CFG scale at inference time. |
| `elf_n_steps` | `int` | `64` | Euler ODE steps at inference time. |
| `t5_model_name` | `str` | `"t5-base"` | Frozen T5 variant used as embedding oracle. |
MoE fields (Config)
??? note “MoE fields — expand for details”
Only relevant when use_moe=True.
| Field | Type | Default | Description |
|:------|:-----|:-------:|:------------|
| `use_moe` | `bool` | `False` | Enable Mixture-of-Experts FFN. |
| `n_experts` | `int` | `4` | Number of experts. |
| `top_k_mlp` | `int` | `2` | Active experts per token. |
| `expansion` | `int` | `4` | FFN expansion factor. |
| `alpha_balance` | `float` | `0.1` | Load-balancing loss coefficient. |
Attention & position (Config)
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
RoPE positional encoding. |
|
|
|
Learned positional embeddings. |
|
|
|
Sinusoidal absolute PE. |
|
|
|
RoPE frequency scaling (>1 extends effective context). |
|
|
|
Flash Attention kernel. |
|
|
|
Sliding-window attention. |
|
|
|
Window blocks for sliding-window attention. |
|
|
|
Enable gated attention / attention-sink suppression (Qiu et al. 2026). |
??? note “MLA fields (Config) — expand for details”
Only relevant when attention_type="mla".
| Field | Type | Default | Description |
|:------|:-----|:-------:|:------------|
| `mla` | `bool` | `False` | Use Multi-Latent Attention. Overridden by `attention_type="mla"`. |
| `inference` | `bool` | `False` | MLA inference mode (absorbed KV projection). |
| `down_dim_q` | `int` | `256` | Query latent dim. |
| `down_dim_kv` | `int` | `256` | KV latent dim. |
| `rope_dim` | `int` | `32` | RoPE subspace dim. Must be ≤ `head_size`. |
Training (Config)
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Peak learning rate. |
|
|
|
Micro-batch size per device. |
|
|
|
Gradient accumulation steps. |
|
|
|
Max training epochs. |
|
|
|
Warmup steps. |
|
|
|
LR schedule: |
|
|
|
|
|
|
|
Gradient clipping. |
|
|
|
Early stopping patience. |
|
|
|
bfloat16 precision. |
|
|
|
Validation batches per eval. |
|
|
|
Random seed. |
LoRA (Config)
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Inject LoRA adapters. |
|
|
|
LoRA rank |
|
|
|
LoRA scaling factor. |
|
|
|
LoRA dropout. |
|
|
|
|
Hardware & logging (Config)
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
GPU count ( |
|
|
|
Tensor-parallel factor. |
|
|
|
CSV log path (relative to run dir). |
|
|
|
JSON architecture summary. |
FlowMatchingConfig
Dedicated architecture config for FlowMatchingTransformer (core/flow.py),
the continuous flow-matching paradigm that follows the ELF recipe
(Hu et al., 2026). Use this class when instantiating flow-matching models
directly rather than through the Config/ModelConfig + Trainer pipeline.
ELFConfig, ELFTransformer, and dantinox.core.elf are deprecated aliases
for FlowMatchingConfig, FlowMatchingTransformer, and dantinox.core.flow
respectively — they still work but emit a DeprecationWarning and will be
removed in v1.0.
from dantinox.core.config import FlowMatchingConfig
from dantinox.core.flow import FlowMatchingTransformer
from flax import nnx
cfg = FlowMatchingConfig(
embed_dim=512, bottleneck_dim=128,
model_dim=768, n_heads=12, head_size=64,
num_blocks=12, vocab_size=32128,
)
model = FlowMatchingTransformer(cfg, rngs=nnx.Rngs(42))
!!! abstract “Key constraint”
model_dim must equal n_heads × head_size, just like in ModelConfig.
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Token embedding and flow-space dimension. |
|
|
|
Bottleneck between embed space and transformer hidden dim. |
|
|
|
Transformer hidden dim. Must equal |
|
|
|
Attention heads. |
|
|
|
Per-head dimension; must be set explicitly (or leave |
|
|
|
Transformer layers. |
|
|
|
Vocabulary size. Auto-set from the T5 tokenizer by |
|
|
|
Max sequence length (excluding control tokens). |
|
|
|
Positional encoding. |
|
|
|
Normalisation type. |
|
|
|
Dropout rate. |
|
|
|
Recompute activations in backward pass. |
|
|
|
Sinusoidal embedding dim for |
|
|
|
Time control tokens. |
|
|
|
Frozen HuggingFace T5 encoder used to produce embeddings. |
|
|
|
Default number of Euler ODE integration steps at inference. |
|
|
|
Default Classifier-Free Guidance scale. |
|
— |
— |
Same attention/FFN/MoE toggles as |
|
|
|
CFG scale control tokens. |
|
|
|
Mode control tokens. |
|
|
|
SDE noise re-injection at inference ( |
|
|
|
Frozen T5 embedding oracle. |
??? note “Training-time continuous flow-matching fields — expand for details” These control the denoiser/decoder dual-branch training procedure.
| Field | Type | Default | Description |
|:------|:-----|:-------:|:------------|
| `denoiser_pmean` | `float` | `-1.5` | Logit-normal time sampling mean. |
| `denoiser_pstd` | `float` | `0.8` | Logit-normal time sampling std. |
| `denoiser_noise_scale` | `float` | `2.0` | Noise corruption scale (denoiser branch). |
| `decoder_pmean` | `float` | `0.8` | Logit-normal p mean (decoder branch). |
| `decoder_pstd` | `float` | `0.8` | Logit-normal p std (decoder branch). |
| `decoder_noise_scale` | `float` | `5.0` | Noise corruption scale (decoder branch). |
| `denoiser_prob` | `float` | `0.8` | Denoiser branch fraction. |
| `self_cond_prob` | `float` | `0.5` | Self-conditioning probability. |
| `cfg_scale_min` | `float` | `0.5` | Min CFG training scale. |
| `cfg_scale_max` | `float` | `5.0` | Max CFG training scale. |
Complete YAML example
# Architecture
dim: 512
n_heads: 8
head_size: 64
num_blocks: 12
vocab_size: 32000
max_context: 1024
attention_type: gqa
kv_heads: 2
use_rotary_pos: true
norm_type: rmsnorm
use_swiglu: true
gradient_checkpointing: true
# Training paradigm
model_type: autoregressive
# Optimiser
lr: 3e-4
batch_size: 64
grad_accum: 4
epochs: 500
warmup_steps: 400
lr_schedule: cosine
optimizer: adamw
grad_clip: 1.0
use_bf16: true
# Dataset
dataset_source: huggingface
dataset_name: wikitext
dataset_config: wikitext-103-raw-v1
dataset_text_field: text
tokenizer_type: bpe
tokenizer_path: t5-base
See also
- material-console:
CLI Reference
All 14 CLI subcommands with full argument tables.
- material-chef-hat:
Cookbook
Copy-paste recipes for common patterns.
- material-school:
Tutorials
Step-by-step guides for training, diffusion, LoRA.