convert_any_model

Convert a HuggingFace model to AnyModel format.

Functions

convert_model

Convert a HuggingFace model to AnyModel format.

convert_model(input_dir, output_dir, converter)

Convert a HuggingFace model to AnyModel format.

This function converts a HuggingFace checkpoint to the AnyModel format used for compression. The conversion process:

  1. Copies non-weight files (config, tokenizer, etc.)

  2. Creates block_configs for each layer

  3. Reorganizes weights into subblock checkpoints

Parameters:
  • input_dir (str) – Path to the input HuggingFace checkpoint directory.

  • output_dir (str) – Path to the output AnyModel checkpoint directory.

  • converter (Converter | str) – Either a converter name (e.g., “llama”) or a Converter class.

Example

>>> convert_model(
...     input_dir="/path/to/Llama-3.1-8B-Instruct",
...     output_dir="/path/to/output/ckpts/teacher",
...     converter="llama",
... )