VOOZH about

URL: https://deepwiki.com/inclusionAI/AReaL/11-data-structures-and-io

⇱ Data Structures and IO | inclusionAI/AReaL | DeepWiki


Loading...
Last indexed: 7 May 2026 (2e12c1)
Menu

Data Structures and IO

Purpose and Scope

This document describes the core data structures used for IO operations throughout AReaL. These dataclasses serve as the primary interfaces between different components of the system, enabling communication between training engines, inference servers, workflow executors, and configuration systems. The structures covered include:

  • Request and Response Types: ModelRequest and ModelResponse structures for inference. For details, see Request and Response Types.
  • Weight Update Metadata: WeightUpdateMeta for disk/NCCL weight synchronization and LoRA support. For details, see Weight Update Metadata.
  • Checkpoint Metadata: SaveLoadMeta, FinetuneSpec, and checkpoint-related structures. For details, see Checkpoint Metadata.
  • Configuration Dataclasses: Type-safe configuration objects for all system components. For details, see Configuration Dataclasses.
  • Runtime Information: DeviceRuntimeInfo, StepInfo, and server monitoring structures. For details, see Runtime Information.

For information about how these structures flow through training pipelines, see Training Engines. For workflow integration patterns, see Workflow and Rollout System. For comprehensive configuration reference, see Configuration System.


Request and Response Types

ModelRequest

The ModelRequest dataclass represents a request for model inference. It serves as the primary input structure for both local and remote inference engines.


Key Fields:

FieldTypePurpose
ridstrUnique request ID (UUID) areal/api/io_struct.py29
input_idslist[int]Tokenized input sequence areal/api/io_struct.py30
gconfigGenerationHyperparametersGeneration parameters (temperature, top_p, etc.) areal/api/io_struct.py31-33
image_datalist[str] | NoneBase64-encoded images for VLM inputs areal/api/io_struct.py39
vision_msg_vllmlist | NonevLLM-specific vision message format areal/api/io_struct.py43

Sources: areal/api/io_struct.py28-60 areal/engine/sglang_remote.py43-89 areal/engine/vllm_remote.py44-96 areal/api/workflow_api.py14-40 areal/api/engine_api.py258-268

ModelResponse

The ModelResponse dataclass contains the result of model inference, including generated tokens, log probabilities, and timing statistics.

Key Fields:

FieldTypePurpose
output_tokenslist[int]Generated token IDs areal/api/io_struct.py66
output_logprobslist[float]Log probability for each output token areal/api/io_struct.py67
stop_reasonstrWhy generation stopped (length, stop, tool_calls, abort) areal/api/io_struct.py69
latencyfloatTotal generation latency (seconds) areal/api/io_struct.py78
routed_expertsnp.ndarray | NoneMoE routing info if requested areal/api/io_struct.py83

Derived Properties:

Sources: areal/api/io_struct.py62-132 areal/engine/sglang_remote.py91-127 areal/engine/vllm_remote.py98-127


Weight Update Metadata

Weight synchronization between training and inference engines requires coordinating metadata structures that describe how weights should be transferred and applied.

WeightUpdateMeta

The WeightUpdateMeta dataclass coordinates weight synchronization. It supports disk, xccl (distributed), and awex update types areal/api/io_struct.py184

Core Fields:

Sources: areal/api/io_struct.py183-216 areal/api/engine_api.py175-183 areal/engine/sglang_remote.py129-187

ParamSpec

The ParamSpec dataclass describes a single parameter tensor for distributed weight updates.

FieldTypePurpose
namestrParameter name areal/api/io_struct.py151
shapetupleTensor shape areal/api/io_struct.py152
dtypestrData type string areal/api/io_struct.py153

Sources: areal/api/io_struct.py150-160


Checkpoint Metadata

SaveLoadMeta

The SaveLoadMeta dataclass contains information for checkpoint save/load operations, defining the target path, weight format, and associated tokenizer/processor. This is used by engines during initialization to restore model state areal/api/io_struct.py22 areal/api/engine_api.py22

FinetuneSpec

The FinetuneSpec dataclass encapsulates training configuration needed for optimizer and scheduler initialization areal/api/io_struct.py134-147

Derived Properties:

Sources: areal/api/io_struct.py134-147


Configuration Dataclasses

AReaL uses strongly-typed dataclasses for all configuration. These structures are defined primarily in areal/api/cli_args.py.

Configuration Hierarchy


Key Configuration Classes

Sources: areal/api/cli_args.py26 areal/api/io_struct.py17 examples/math/gsm8k_grpo_lora.yaml36-43


Runtime Information

DeviceRuntimeInfo

The DeviceRuntimeInfo dataclass provides a snapshot of GPU/device memory usage, including allocated and reserved stats. It is returned by TrainEngine and InferenceEngine to monitor health areal/api/io_struct.py17 areal/api/engine_api.py17

LocalInfServerInfo

The LocalInfServerInfo dataclass tracks information about a locally launched inference server subprocess areal/api/io_struct.py18

FieldTypeDescription
hoststrServer hostname/IP areal/api/io_struct.py18
portintServer port number areal/api/io_struct.py18
processsubprocess.PopenServer process handle areal/api/io_struct.py18

Sources: areal/api/io_struct.py16-24 areal/api/engine_api.py17-23