Skip to main content

Loading Safetensor from HF to Equinox

Project description

Python License PyPI version Code style: ruff

Saferax Logo

Saferax: Loading Safetensor from HF to Equinox

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.2.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.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: saferax-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 549d833e947f6ab6e18cb19aea6ea0d4aa87a7907c9efb367dc7a3598383594f
MD5 e10c9ce88dfb4d9981cc2eeb4ada6384
BLAKE2b-256 dbe1d0e9dcae69cbe11b2e983eeab4a140e9d4fa964d11b7a54f878f6cc374fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: saferax-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e71b1177287b3cc388a5f7a58600bcc95178ae2f2705570b7a202f24403e00da
MD5 a3823956d7b7e0d1b5032cbd4b8a1f09
BLAKE2b-256 92d26d99322c01241ae2b11e95db6c7463d1b7f9dc41f673c8a015568d545c66

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