Zephon
Zephon turns datasets into training batches. You choose the sources, their mixture, and how to prepare documents. Zephon handles reading, packing, and replay. NeMo AutoModel supplies the model and training loop.
This guide covers the AutoModel settings you need to get started. The Zephon User Guide (ZUG) explains the underlying concepts and APIs in more detail.
Start with a Recipe
Follow the AutoModel installation guide. Zephon is included in the dependencies. Choose a recipe for your model and input:
For example, run from the repository root:
The online recipes mix web, code, and arXiv documents. Prepacked recipes need your prepared tokens. Check the recipe’s process count and training budget. You might need to obtain access to gated checkpoints before running.
Datasets, Work Sources, and Pipelines
There are three parts to a Zephon data-loading setup:
- A dataset describes stored documents and their shards. A source
pathcan point to a local dataset directory, object storage, or Hugging Face, such ashf://org/dataset/subset/train. Zephon discovers the shard format. - A work source chooses which documents the pipeline processes, in what
order and from which datasets. A
StaticMixtureWorkSourceuses your source weights to define the requested mixture. - A pipeline prepares those documents using operators, such as fetching, tokenizing, packing, and batching. AutoModel constructs the pipeline from your recipe.
You can think of a pipeline as stream processing: samples flow through operators and change representation along the way. A text string becomes a sequence of tokens, which packing can split into several training sequences or combine with tokens from other documents.
See datasets and storage, mixing datasets, and pipelines in the ZUG.
Choose Your Input
Set dataset._target_ to the config for your documents. AutoModel selects the
matching Zephon loader when you omit dataloader._target_.
Raw Text and Source Mixtures
For JSONL or Parquet documents with a text field, configure sources under
dataset.zephon. For example:
Each path identifies a dataset directory containing shards. Use text_field
if your text column has another name. tokenize_special_tokens selects BOS/EOS
insertion. The example appends EOS to each document. Use the tokenizer that
belongs to the model you are training.
Token-aware mixing. A 70/30 mixture of long web documents and short code
snippets does not give a 70/30 token mixture when sampling by document count.
For multi-source text, AutoModel enables Zephon’s token estimation by default:
it measures a subset of each source with the training tokenizer and adjusts
sampling to approximate your requested token proportions. This also applies to
pretokenized text. Weights are relative and do not need to sum to one.
Set dataset.zephon.source.token_estimation: false for document-count mixing.
Dropping documents later can change the final token mixture. Estimation is
not a guarantee of exact output proportions. See the
mixing guide for calibration.
For a single source, dataset.path_or_dataset_id or dataset.paths is also
accepted in place of zephon.sources. Use a dataset root or a Hugging Face ID
with name/split. Use explicit zephon.sources for mixtures. The two source
declaration styles cannot be combined.
Use Pretokenized and Prepacked Text
Use ZephonPretokenizedTextDatasetConfig when tokenization happened offline.
Supply unshifted, unpadded token lists made with the exact model tokenizer.
tokens_field defaults to input_ids, and loss_mask_field defaults to loss_mask.
The optional loss mask is token-aligned and binary. Zephon handles the
next-token shift and padding during training. Do not store shifted labels.
Leave online packing enabled to combine tokenized documents, or set
dataset.zephon.packing.pack_algorithm: null for prepacked input. Each stored
sequence must then have at most seq_len + 1 tokens: a 1,024-token model input
needs up to 1,025 unshifted tokens. Longer sequences are rejected.
Prepacked sequences can carry Zephon’s positions field to retain subdocument
boundaries. Without it, each stored sequence is one document, even if it
contains EOS tokens. Supplied positions require online packing to be disabled.
See packing and
building training batches
for the Zephon formats. The prepacked recipes above show the complete AutoModel
configuration and local input paths.
Packing and Attention
All settings below are under dataset.zephon:
packing.seq_lenis the model input-token limit for a packed document. If omitted, it uses the model’s context limit. Set a shorter window when needed; values above a known model limit are rejected.packing.pack_algorithmdefaults towrapfor text. It fills sequences and can split documents. Usefirst_fitorbest_fitto keep documents whole, ornullto disable online text packing. Whole-document packing drops oversized documents by default; setdrop_oversized: falseto raise instead.training.allow_cross_document_attentiondefaults tofalse: subdocuments within a pack cannot attend to one another. Set it totrueto allow causal attention across their boundaries. Positions reset with isolation and run continuously when joined. Separate packed documents in a batch stay independent.training.mask_segment_startsindependently controls loss at subdocument boundaries. Its default,false, allows those next-token targets, andtrueexcludes them.
Packing does not select an attention backend. Keep the backend under
model.attn_implementation. dataset.output_format defaults to batched.
Choose thd only for a model and backend that support that variable-length layout.
Both formats can contain packed documents, and batched output can use Flash
Attention. The packing guide
explains algorithm choices.
Caching and Throughput
Zephon’s fetch operator reads the selected records. For remote data, the shard cache keeps downloaded shards on local disk and evicts them as needed. Use fast node-local storage and set a budget below its available capacity:
If your shards are in Parquet format, a separate row-group cache stores decoded data and has its own budget. Neither disk budget bounds pipeline RAM. See storage and shard caching and Parquet for sizing and behavior.
Tune operator parallelism under dataset.zephon.workers and execution and queue
depths under runtime. source.prefetch: {} separately enables cache lookahead.
See pipeline execution
and the config reference below for tuning and defaults.
Stopping and Resuming
Set a positive step_scheduler.max_steps. Operators can split one document
into several sequences, combine documents, or drop them, so the number of
training batches cannot be inferred from the source document count. Zephon
therefore does not expose a precomputed pipeline length.
Training stops at this upper bound or when the work source finishes. By default,
a mixture ends after every source completes a pass. Exhausted sources can repeat
to maintain the mixture while others finish. Configure source.exhausted_policy,
max_repeats, and stop_after_passes when you need another policy. See
shuffling and repeating samples.
Incomplete final microbatches are dropped.
AutoModel checkpoints include the Zephon stream state. Give each distributed
run a unique dataset.zephon.checkpoint.run_id. Keep it, the data, tokenizer,
seed, and pipeline settings unchanged on resume. To resume with different DP sizes,
set dataset.zephon.checkpoint.canonical_replicas to a common multiple before
starting, and global_batch_size / local_batch_size must also be divisible by it.
See distributed training
and checkpointing.
DP, TP, and PP support follows the selected AutoModel model and backend. Context parallelism is unsupported by this integration. Zephon supplies training data; AutoModel’s native validation loaders remain available.
Configuration Reference
The config dataclasses
are the full reference for fields, defaults and validation. Pipeline options
live under dataset.zephon; model and optimizer settings stay in their usual
AutoModel sections.
You can put the Zephon groups in a TOML file using dataset.zephon.data_config.
Inline YAML overrides individual fields. Relative paths in TOML are resolved
against that file. For Zephon APIs and behavior, use the ZUG
and API reference.
How the Integration Works
This section is for readers extending the integration. AutoModel’s dataset
config constructs a Zephon pipeline. Its loader supplies batches directly
to the recipe.
The work source owns selection and mixing, operators own preparation, and
Zephon’s to_training() performs final shifting, padding and collation.
The dataset config chooses how documents are prepared and reuses the same source, cache, packing and batching setup. AutoModel supplies runtime inputs such as the tokenizer, batch size, input-length limit and distributed rank information. The pipeline runs independently of the training model. Its configuration and the work source’s progress are enough to replay the stream when AutoModel restores a checkpoint.
After to_training(), the loader adapts the result to AutoModel’s layout and
attention interface. AutoModel supplies model-specific position requirements.
Reading and caching stay inside Zephon’s fetch path. All ranks participate in
checkpointing, including TP/PP peers.
For the construction and delivery code, see
config.py,
pipeline.py,
and loader.py.