Skip to main content

Loading Safetensor from HF to Equinox

Project description

Saferax: Loading Safetensor from HF to Equinox

Saferax Logo

Python License PyPI version Code style: ruff

Saferax is a lightweight utility library that enables seamless loading of SafeTensor files from Hugging Face Hub into Equinox models. It provides efficient handling of model weights with support for sharded loading and direct Hugging Face Hub integration.

Features

  • 🔄 Load SafeTensor files directly into Equinox models
  • 💾 Support for sharded model weights
  • 🤗 Direct integration with Hugging Face Hub
  • 📦 Simple to use API

Installation

Saferax can be installed using pip like every python library and requires Python 3.11 or later.

pip install saferax

Saving Models

You can save your models in two ways with Saferax:

  1. Save to your computer: Consolidated or Sharded.
  2. Save directly to Hugging Face Hub

To save locally you just pass the equinox model and path to save it locally:

sx.save_model(model, "path/to/save")

To save model over shards of safetensor file you can pass shard=True and max_shard_size, the name scheme is same as what hugging face uses so you need not worry about that.

sx.save_model(
    model,
    "path/to/save",
    shard=True,
    max_shard_size=2 * 1024 * 1024
)

Push to Hugging Face Hub

With Saferax you can push your model directly to HF hub, just add the repo_id & commit_message and saferax will take care of the rest.

sx.save_model(
    model,
    "path/to/save",
    push_to_hub=True,
    repo_id="your-username/your-model",
    commit_message="Update model weights"
)

Loading Models

You can easily use Saferax to load models from Hugging Face Hub into Equinox. It takes care of downloading, saving, and converting the model files for you.

loaded_model = sx.load_model(
    model,
    "your-username/your-model",
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saferax-0.0.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saferax-0.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file saferax-0.0.1.tar.gz.

File metadata

  • Download URL: saferax-0.0.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for saferax-0.0.1.tar.gz
Algorithm Hash digest
SHA256 de20a659033609b9efd7dc4893a36443b28869494dde6d6e57d606aae9427a4c
MD5 b412fbfce25054560c5c5444ff5361e3
BLAKE2b-256 f293761310b969022fe684925584c9a7080af965ee6526c89e220865ce4c13af

See more details on using hashes here.

File details

Details for the file saferax-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: saferax-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for saferax-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f56d044898f93b8d31e5d51d6eca264ee76bb69d82b3e35e2b6d757b9774a0d3
MD5 520ff22fd3a6a7f89d4c6a5caa13dcc2
BLAKE2b-256 d4a2d085ba584b6af14b86e51b6c7027f5d22d2ccc3ba026ce574ea9675f4b14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page