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

Uploaded Python 3

File details

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

File metadata

  • Download URL: saferax-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 edc403193e86f41bf00052e5665ed79f29400ad179df025f6693cadbbc2a6ba8
MD5 b8e905432fbf473f69e81725da27c169
BLAKE2b-256 0963d98fc5011de1a4d6d8eb36af63922f4a35918c63f05b3cced35751c93607

See more details on using hashes here.

File details

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

File metadata

  • Download URL: saferax-0.0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce1b5532ee4577b35d9966ee7c83310e488674796cfa4ceff21bdc9ff1defb33
MD5 9fe3444e2ee68bbbc6bf387308085a67
BLAKE2b-256 728d0ad2a8e972d144bef4b979eefdc98c74799d3df735c8406565626183a252

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