#8027·verl

[Feature] Make Hugging Face safetensors export configurable

Author: lbaolinCreated Sep 26, 2026Updated Sep 26, 2026

Motivation

The current in-training Hugging Face safetensors export path is not very user-friendly. Users cannot customize the PreTrainedModel.save_pretrained call or artifact layout, and FP32-master/BF16 mixed-precision training exports FP32 weights unless users perform a separate conversion. Evaluation and serving commonly need BF16 artifacts without changing the training parameter dtype.

Issue #296 previously requested control over the saved model dtype and remains open. Setting the training model dtype to BF16 is not equivalent to selecting BF16 only for the exported Hugging Face model. The offline FSDP merger is also not a direct replacement because it consumes verl's native per-rank checkpoints rather than an already exported Hugging Face safetensors model.

Example

Consider an 8B model trained with the default mixed-precision configuration:

  • Training: BF16 compute with FP32 master weights.
  • Current Hugging Face export: One roughly 32 GB FP32 model.safetensors file.
  • Missing controls: No option to export BF16 weights or configure the safetensors shard size.

Proposed changes

The following PRs have been created to address these limitations:

  • #7997 forwards optional hf_save_pretrained_kwargs to PreTrainedModel.save_pretrained, including max_shard_size for sharded safetensors.
  • #8019 adds hf_export_dtype to select an export-only floating-point dtype independently of training precision.

Both preserve the current behavior when the new options are unset.