Skip to content
View as Markdown

tinker_cookbook.weights.download

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

tinker_cookbook.weights.download(tinker_path, output_dir, base_url)

Download a checkpoint from Tinker storage to local disk.

The path type selects how the files are fetched:

  • tinker://<run_id>/external_weights/<name>, as returned by TrainingClient.save_weights_external(): each file is downloaded from its own signed URL into output_dir. Files of an age-encrypted export keep their .age suffix; decrypt them with age -d before you use them.

  • tinker://<run_id>/weights/<name>, as returned by TrainingClient.save_state(): the checkpoint is loaded into a new training run and saved with save_weights_external(), encrypted to a key generated for this download. The files are downloaded and decrypted, and then the export is deleted. This starts a training session on the checkpoint's base model.

Sampler checkpoints (tinker://<run_id>/sampler_weights/<name>) cannot be downloaded. Save a training checkpoint or external weights instead.

File paths are validated before they are written (rejects path traversal).

Parameters:

  • tinker_path (str) – Tinker checkpoint path (see above).
  • output_dir (str) – Local directory where the checkpoint files are written.
  • base_url (str | None) – Custom Tinker service URL. If None (default), uses the default Tinker service endpoint (or TINKER_BASE_URL environment variable if set).

Returns: output_dir.

Raises:

  • WeightsDownloadError: If the path is invalid, the service cannot be
  • reached, a checkpoint cannot be exported, a file fails to download or decrypt, or a
  • file path is unsafe.
from tinker_cookbook import weights
tinker_path = training_client.save_weights_external("final").result().path
adapter_dir = weights.download(tinker_path=tinker_path, output_dir="./adapter")