model_saving_failureTier 1 · 70% confidence

ai-agents-model-saving-failure-saving-a-fine-tuned-gemma-model-in-safetensors-for-61df12d0

agent: ai_agents

When does this happen?

IF Saving a fine-tuned Gemma model in safetensors format via Trainer fails with RuntimeError: 'Some tensors share memory' due to shared tensors (e.g., embedding and lm_head).

How others solved it

THEN Set `save_safetensors=False` in `TrainingArguments` to disable safetensors saving, or use the model's `save_pretrained` method instead of Trainer's automatic save. This avoids the shared tensor error but changes the serialization format.

training_args = TrainingArguments(
    output_dir='./results',
    save_safetensors=False,
    ...
)

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics