> ## Documentation Index
> Fetch the complete documentation index at: https://docs.synapsai.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Convert models to Safetensors

> Convert PyTorch or other weight formats to Safetensors for SynapsAI Cloud deployment

SynapsAI Cloud requires model weights in [Safetensors](https://huggingface.co/docs/safetensors) format. If your Hugging Face repository only contains `.bin` or `.pt` files, convert them before deploying.

<Warning>
  Deployments fail with `NoSafetensorsError` when no `.safetensors` files are found in the repository. See [Troubleshooting](/support/troubleshooting#nosafetensorserror) for the full error message.
</Warning>

## Quick conversion with Transformers

If your model is supported by the `transformers` library, reload and re-save with `safe_serialization=True`:

```bash theme={null}
pip install --upgrade transformers safetensors huggingface_hub
```

```python theme={null}
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "your-org/your-model"

model = AutoModelForCausalLM.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)

# Save locally with safetensors
model.save_pretrained("./converted", safe_serialization=True)
tokenizer.save_pretrained("./converted")
```

Push the converted files to your Hugging Face repository:

```python theme={null}
from huggingface_hub import HfApi

api = HfApi()
api.upload_folder(
    folder_path="./converted",
    repo_id="your-org/your-model",
    repo_type="model",
)
```

## Diffusers models

For diffusion and image models:

```python theme={null}
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("your-org/your-model")
pipe.save_pretrained("./converted", safe_serialization=True)
```

Then upload the folder to the Hub as shown above.

## Verify before deploying

1. Confirm `.safetensors` files appear in the repository file list on Hugging Face.
2. Ensure `config.json`, tokenizer, and processor files are present.
3. Add a `pipeline_tag` to `README.md` (for example, `pipeline_tag: text-generation`).

See [Launch a custom model](/guides/hf-model-setup) for the full repository checklist and [Deploy a model](/guides/deploy-model) to launch.

## CLI alternative

If you cloned the repository with Git:

```bash theme={null}
# After saving with safe_serialization=True into the repo directory
git add *.safetensors
git commit -m "Add safetensors weights"
git push
```

## Remote code not supported

Models that require `trust_remote_code=True` or custom Python modules in the repository are not supported today. Use architectures available in `transformers` or `diffusers`, or contact [support](/support/contacting-support) if you need a custom architecture.
