NVIDIA Teaches Megatron-LM Market Forecasting
NVIDIA Technical Blog published a tutorial for preprocessing intraday market bars into tensors and training a Megatron-LM model to forecast returns and trading volume across multiple horizons. The example keeps price and volume as continuous features, uses learned patch embeddings, and supports shared models across instruments while including safeguards against cross-split data leakage.
The tutorial provides a concrete, reusable workflow for applying NVIDIA’s GPU-optimized Megatron training stack to financial time-series forecasting.
Market data arrives as a stream of trades and quotes: every execution, bid, and ask, timestamped to the microsecond. Preparing this data for AI-based market forecasting requires turning price and volume histories into consistent inputs for model training and inference. A common first step is aggregating the data into bars—one row per instrument per time unit—with price, volume, and other statistics. Neural networks can learn patterns from these histories across instruments and forecast horizons.
NVIDIA Megatron Core is an open-source library of GPU-optimized components for training transformer models at scale. Megatron-LM is a GitHub repository that combines that library with preconfigured training scripts. A preprocessing script turns intraday market bars into model-ready tensors, and a dataset provider feeds them into Megatron’s distributed training loop.
This post shows how to preprocess market-bar data and train a model with Megatron-LM to forecast returns and trading volume across multiple horizons.
Forecast returns and trading volume
Price and volume remain continuous features. A learned patch embedding turns each group of observations into a model input without converting market values into text.