Engine and memory

Engine and memory settings control training speed, memory use and the checks before training starts.

Attention in a packed pass

Use config.model.attentionImplementation to choose attention. Optimize permits flex_attention for Gemma 4 E2B, E4B, 12B, and 26B-A4B. It refuses other model types.

For flex attention, keep engine.pad_to_length enabled and engine.pad_to_length_bucket at least 128. If startup reports insufficient shared memory, choose a larger GPU or use sdpa.

Default kernels by model type

A supervised run under verl on H200 devices that does not set attentionImplementation or a liger.* setting takes its model type’s default. The defaults apply only on H200 devices. A run on any other device profile takes no defaults. The following table lists the defaults for H200 devices:

Model type attentionImplementation Liger kernels

Gemma 4 E2B and E4B

flex_attention

liger.rms_norm and liger.geglu

Gemma 4 12B

flex_attention

None

Gemma 4 26B-A4B

flex_attention

None

Any other model

sdpa

None

Flex attention trains more tokens a second than sdpa, more so on longer sequences. On Gemma 4 12B it can take more device memory than sdpa. Set attentionImplementation to sdpa for a run that does not fit a device under the default.

Set attentionImplementation or a liger.* setting explicitly to override its default. To keep SDPA when copying a plan from JSON output, add attentionImplementation: sdpa; the output can omit that default value.

Check the chosen kernels with training runs get --settings or training runs start --dry-run --show-resolved. A branch keeps its parent’s kernels.

Engine settings

Use engineSettings to set the training engine’s settings directly. Most settings affect only memory use and speed. Use them to fit your model to its devices. Precision settings change the arithmetic used during training. The engineSettings object has the following fields:

Field Description

engine

Required. Set verl. No other engine takes engine settings.

settings

Each setting’s value, by its name. Required.

A run can set the following settings, where its deployment allows each one:

Setting Default Description

engine.forward_prefetch

false

Fetches the next layer’s weights while the current layer computes. A step can be faster, and it needs more memory.

engine.reshard_after_forward

true

Frees each layer’s gathered weights after the forward pass. Setting false keeps them for the backward pass, which can be faster and needs more memory.

engine.pad_to_length

false, true for a flex_attention run

Pads each pass up to a multiple of engine.pad_to_length_bucket tokens, so the kernels see fewer shapes. It can speed up a run whose sequence lengths vary. Padding requires additional computation.

engine.pad_to_length_bucket

1024

The multiple engine.pad_to_length pads to.

engine.use_no_sync_for_gradient_accumulation

true for a run that trains an adapter

Set false to combine gradients after each pass instead of each update. This can slow runs with unequal sequence lengths and change rounding. Available for adapter training.

engine.mixed_precision.param_dtype

bf16

The data type used for computation in the forward and backward passes: bf16 or fp32. Setting fp32 is slower and needs more memory. SFT only.

engine.mixed_precision.reduce_dtype

fp32

The data type used to sum gradients across devices: bf16 or fp32. Setting bf16 transfers half as many bytes but reduces the precision of the sum. SFT only.

engine.mixed_precision.buffer_dtype

fp32

The data type used to store the model’s buffers, such as its rotary tables: bf16 or fp32. SFT only.

compile.recompile_limit

8

The maximum number of compiled versions of a function that Torch compile keeps for one layer. For example, each sequence shape can have its own version. After this limit, the function runs without compilation. SFT only.

compile.accumulated_recompile_limit

256

The maximum number of compiled versions of a function that Torch compile keeps across all layers that run it. SFT only.

compile.fail_on_recompile_limit_hit

false

Setting true fails the run when either recompile limit is reached. Setting false runs the function without compilation from then on. This is slower and does not report that the limit was reached. SFT only.

liger.rms_norm

Normally false; true for a Gemma 4 E2B or E4B run on H200 devices, see [kernel-defaults]

Enable Liger RMS normalization to improve speed and memory use on verified model types. Not available for Gemma 4 12B. SFT only.

liger.geglu

Normally false; true for a Gemma 4 E2B or E4B run on H200 devices, see [kernel-defaults]

Enable Liger GeGLU to improve speed and memory use on verified model types. Not available for Gemma 4 12B. SFT only.

checks.start

true

Checks the run’s numerics before its first update. Setting false trains without the checks. SFT only. See Checks before the first update.

checks.head.max_logprob_error

0.01

The head check’s bound on the largest difference in a log-probability. SFT only. See Checks before the first update.

checks.head.max_gradient_error

0.005

The head check’s bound on the gradient’s difference relative to its size. SFT only.

checks.isolation.max_logprob_error

0.0001

The isolation check’s bound on how far a conversation’s log-probabilities move. SFT only, with data.use_dynamic_bsz left on.

checks.packing.max_loss_error

0.005

The packing check’s bound on the difference in the step’s mean loss. SFT only, with data.use_dynamic_bsz left on.

checks.reference.max_logprob_error

Automatic, at least 1.0

Maximum log-probability difference at the run’s precision. SFT only. Change only when the fp32 checks pass. See Checks before the first update.

checks.reference.mean_logprob_error

Automatic, at least 0.03

Mean log-probability difference at the run’s precision. SFT only. Change only when the fp32 checks pass.

checks.reference.max_nll_error

Automatic, at least 0.005

Mean loss difference at the run’s precision. SFT only. See Checks before the first update.

checks.reference.fp32_max_logprob_error

Automatic, at least 0.002

Maximum log-probability difference at fp32. SFT only.

checks.reference.fp32_mean_logprob_error

0.0001

The reference check’s bound on the mean difference in a log-probability at fp32. SFT only.

head.chunk_tokens

512

Tokens computed at once by the output head. Lower it to reduce memory. Must be positive. SFT only.

checkpoint.compare_replicas

true

Leave true to fail if unsharded devices disagree on optimizer state before saving. Set false to skip the comparison. SFT only.

rollout.enable_chunked_prefill

true

Splits a long prompt’s prefill into chunks. Reinforcement runs only.

rollout.enable_prefix_caching

true

Reuses the cache for prompts with a common prefix, such as the completions of one group. Reinforcement runs only.

rollout.enforce_eager

false

Runs the rollout engine without CUDA graphs. It starts faster and uses less memory, but generates more slowly. Reinforcement runs only.

rollout.max_num_seqs

The step’s rollouts

The most sequences the rollout engine generates at once. Reinforcement runs only.

rollout.max_num_batched_tokens

The larger of maxSeqLength and the step’s rollouts

The most tokens the rollout engine processes in one batch. Reinforcement runs only.

reward.num_workers

Automatic, at most 8

Reward worker processes. Lower the count to reduce host memory use if the failure names this setting. Reinforcement learning only.

data.use_dynamic_bsz

true

Set false for one conversation per pass. Then leave microBatchPerGpu unset or set it to 1, and omit tokensPerGpu. SFT only.

The following example sets engine.forward_prefetch and rollout.enforce_eager:

engineSettings:
  engine: verl
  settings:
    engine.forward_prefetch: true
    rollout.enforce_eager: true

Inspect resolved settings with training runs get --settings or training runs start --dry-run --show-resolved. Before submitting, check that the device profile supports the named engine. Optimize refuses engine settings on one-GPU SFT runs.

If a setting is refused, check its method and deployment support with a dry run. A branch keeps applicable settings from its parent.

To see how many reward workers your run uses, read training runs engine-config.

Each reward worker holds host memory for the whole reinforcement run. If host memory runs out and the run has more than one reward worker, the failure names reward.num_workers and its current value. Lower this setting to use less host memory where your deployment allows it.

Memory settings

Use these settings to adjust memory use, training speed, or learning. You cannot set them on a supervised run on one device. If you omit a setting with a deployment value, your run uses that value. The execution.memory.offload.optimizer field and execution.memory.offload.activations default to false. The execution.memory.sharding field defaults to all. The following table explains each setting’s tradeoffs:

Setting Tradeoff

execution.rollout.memoryShare

A larger share gives the rollout engine more room for its cache, so it generates more completions at once. It leaves less memory for training. A model that fills most of the device needs a larger share to load at all. A reinforcement run only, since a supervised run has no rollout engine.

config.model.weightPrecision

Setting bf16 halves the memory that the weights take. A small update can round away, so the run can learn less than the same run at fp32.

execution.memory.offload.weights

Set true to move the weights to host memory between passes, which frees the device for the rollout engine. Each step takes longer because the weights move back and forth.

execution.memory.offload.optimizer

Set true to reduce device memory use at the cost of host memory and slower updates. For adapter training, this saves less device memory than offloading the model weights.

execution.memory.offload.activations

Set true to reduce device memory use for long sequences. This uses host memory and slows training. The hostMemoryGiB field does not count this memory. Optimize refuses this setting for image-text models.

execution.memory.sharding

Use all to split model state across GPUs. Use none if the state fits on each GPU and you want to test whether avoiding sharding is faster. Both have the same effect on one GPU.

Check resolved values with training runs get --settings. If a setting is unavailable for your engine or device profile, remove it or select a compatible profile. A run and its branches keep the values recorded at submission.

Checks before the first update

A multi-GPU SFT run checks its numerical results before training. Read the verdict in training runs get. Use --checks for each check’s result, bound, and controlling setting.

akka optimize training runs get RUN_ID --checks

The following example shows the check results:

akka optimize training runs get 2c7f4e9a1b3d --checks
State
  Run              2c7f4e9a1b3d5e601acde0294582a2e4fd460d953e233a7926d4bed4e6c61f3f
  Project          triage
  Method           SFT
  Base model       unsloth/Llama-3.2-1B-Instruct
  Dataset          triage/train:v1 — 2000 example(s)
  Evaluated on     triage/llama-3.2-1b-instruct:v2 on triage/eval:v1 by json-label-match, score 0.8600 (6a1d3f5b7c9e)
  Phase            Completed
  Progress         120/120 steps (100%), loss 0.1960
  Saved            step 120 (latest reported step)

Results
  Model            triage/llama-3.2-1b-instruct:v2
  Validation loss  0.2310 (perplexity 1.26)
  Training loss    2.3100 → 0.1960 (mean 0.4120)
  Start checks     ✓ passed 4 of 4 in 41s with a warning: packing lossError 0.0062 against 0.005, refused over 0.025

Cost
  GPU              3384.0 seconds over 2000 examples
  Duration         31m, ended 3h28m ago (waiting for devices 41s, queued 14s, preparing 96s, training 28m, other 20s)
  Throughput       1,005 tokens per second per device, the mean over its steps
  Training peak    9.8 GiB per device, held by the training pass
  Host memory      41.3 GiB in use on node 1 at peak (12.4 GiB at start)
  Memory           at step 88, of 79.6 GiB: weights 1.2, adapter 0.0, gradients 0.0, activations 7.9, optimizer 0.1, other 0.5, allocator 0.8, outside 0.5, free 68.5

Start checks
  head             ✓ passed   gradientError 0.0009 against 0.005 (checks.head.max_gradient_error), logProbError 0.0021 against 0.01 (checks.head.max_logprob_error)
  packing          ✓ passed   lossError 0.0062 against 0.005, refused over 0.025 (checks.packing.max_loss_error)
  isolation        ✓ passed   logProbError 0 against 0.0001 (checks.isolation.max_logprob_error)
  reference        ✓ passed   fp32LogProbError 0.00108 against 0.002 (checks.reference.fp32_max_logprob_error), fp32MeanLogProbError 3.33e-05 against 0.0001 (checks.reference.fp32_mean_logprob_error), logProbError 0.61 against 1 (checks.reference.max_logprob_error), meanLogProbError 0.0175 against 0.03 (checks.reference.mean_logprob_error), nllError 0.0075 against 0.011 (checks.reference.max_nll_error)

A failure stops the run before training. Read the check and setting named in the failure. Widen a bound at the run’s precision only when its fp32 results pass. To skip the checks, set checks.start: false if your deployment permits it.

Bounds must be non-negative. Optimize refuses bounds when checks.start is false, and packing or isolation bounds when data.use_dynamic_bsz is false. Remove those bounds if the checks are disabled.