Skip to content
View as Markdown

tinker_cookbook.weights.build_lora_adapter

Generated from tinker-cookbook at commit 8bf7dd6. Source links point at that snapshot.

tinker_cookbook.weights.build_lora_adapter(base_model, adapter_path, output_path, trust_remote_code)

Convert a Tinker LoRA adapter to standard PEFT format for serving.

The output can be loaded directly by vLLM (--lora-modules), SGLang (--lora-paths), or any framework supporting PEFT LoRA adapters. No merging into base model weights is performed.

Parameters:

  • base_model (str) – HuggingFace model name (e.g. "Qwen/Qwen3-8B") or local path. Needed to resolve model-specific weight naming.
  • adapter_path (str) – Local path to the Tinker adapter directory (must contain adapter_model.safetensors and adapter_config.json).
  • output_path (str) – Directory where the PEFT adapter will be saved. Must not already exist.
  • trust_remote_code (bool | None) – Whether to trust remote code when loading HF model configs. If None (default), falls back to the HF_TRUST_REMOTE_CODE environment variable, then False.

Returns: None

Raises:

  • FileNotFoundError: If adapter files are missing.
  • FileExistsError: If output_path already exists.
  • WeightsAdapterError: If the model family does not support LoRA
  • adapter serving, or adapter keys cannot be remapped.

Referenced by