Skip to main content

Megatron's multi-modal data loader

Megatron Energon

Tests Documentation
Report Bug · Request Feature


DISCLAIMER: This package contains research code. APIs may change.

What is this?

Megatron Energon is the multi-modal data loader of Megatron (you can also use it independently).

It's best at

  • loading large training data to train large multi-modal models
  • blending many different datasets together
  • distributing the work across many nodes and processes of a cluster
  • ensuring reproducibility and resumability
  • adapting easily to various types of data samples and processing

Try using it together with Megatron Core.

Quickstart

Megatron Energon is a pip-installable python package that offers

  • dataset-related classes that you can import in your project
  • a command line utility for data preprocessing and conversion

This document is just a quick start. Please also check out the documentation.

Installation

To install the latest stable version:

pip install megatron-energon

Or to install the current development version:

pip install git+https://github.com/NVIDIA/Megatron-Energon.git

NOTE: We encourage you to install the package (and not just import a local copy). This will ensure you have all the needed dependencies and that you can use the command line tool.

For more details on installing this package, see here.

Usage of command line tool

After installation, the command energon will be available.

Here are some examples for things you can do:

Command Description
energon prepare DATASET_ROOT Interactively prepare WebDataset indexes, splits, and configuration
energon prepare DATASET.jsonl Create an index for a single JSONL file
energon prepare-media --media-metadata-by-extension MEDIA_ROOT Collect media metadata, such as image dimensions and video duration
energon mount DATASET_ROOT MOUNTPOINT --sample-folders Browse a prepared WebDataset as a read-only virtual filesystem, grouped by sample
energon --help List available commands and options

For example, prepare a crude WebDataset without interactive prompts:

energon prepare /path/to/dataset \
    --non-interactive \
    --sample-type=CrudeWebdataset \
    --split-ratio=98,1,1

Its samples are processed by cookers registered in your application's TaskEncoder.

Usage of the library

To get started, pick a WebDataset-compliant dataset and run energon prepare DATASET_ROOT on it, to run the interactive assistant and create the .nv-meta folder. As an alternative to WebDataset, Energon also supports the JSONL format, see here.

Once done, try to load it from your Python program:

from megatron.energon import get_train_dataset, get_loader, WorkerConfig


simple_worker_config = WorkerConfig(rank=0, world_size=1, num_workers=2)


train_ds = get_train_dataset(
    '/my/dataset/path',
    batch_size=2,
    shuffle_buffer_size=None,
    max_samples_per_sequence=None,
    worker_config=simple_worker_config,
)

train_loader = get_loader(train_ds)

for batch in train_loader:
    # Do something with batch
    # Infer, gradient step, ...
    pass

For more details, read the documentation.

Metadata

Release files for megatron-energon 8.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for megatron-energon 8.0.0
File Size Uploaded Provenance Actions
megatron_energon-8.0.0.tar.gz 283.3 kB With provenance Details for megatron_energon-8.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for megatron-energon 8.0.0
File Interpreter ABI Platform Actions
megatron_energon-8.0.0-py3-none-any.whl Python 3 none any Details for megatron_energon-8.0.0-py3-none-any.whl

Total release size: 666.5 kB

Release files / megatron_energon-8.0.0.tar.gz

Download URL megatron_energon-8.0.0.tar.gz
Size 283.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dd9335201934e558c0713f9c9e93077a37f7a26a3056cc7c88dbde1f92fa4e7c
BLAKE2b-256 checksum
How to use checksums
6412c32926f04449611f289c6f1248db70ac0576b4851d0ffd9a50493c3de6f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / megatron_energon-8.0.0-py3-none-any.whl

Download URL megatron_energon-8.0.0-py3-none-any.whl
Size 383.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d70a4ff8b503047a1cee905a3d40c748ad6817ae7e1ed64f64cf3d88a28d2c3
BLAKE2b-256 checksum
How to use checksums
09da9ba25a1a76abe61712f2c945666370fac11122112d523575f2f5943ce740
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for megatron-energon 8.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for megatron_energon-8.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page