---
title: "“Llama 3.2 in Keras”"
description: "Keras (via keras_hub) loads Llama 3.2 directly from standard safetensors Hugging Face checkpoints with on-the-fly conversion, so it has worked since day one."
url: "https://swe.quest/articles/llama-3-2-in-keras-c28d5e4494723a08"
canonical: "https://huggingface.co/blog/keras-llama-32"
source: "Hugging Face"
published: "2024-10-21"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["model-training","llms","python","inference"]
---

# “Llama 3.2 in Keras”

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-10-21, 5 min read, How-to. Original: [https://huggingface.co/blog/keras-llama-32](https://huggingface.co/blog/keras-llama-32)

## Summary

Keras (via keras\_hub) loads Llama 3.2 directly from standard safetensors Hugging Face checkpoints with on-the-fly conversion, so it has worked since day one. A tour of the workflow covers the multi-backend switch (JAX, PyTorch, TensorFlow), tokenizer-included generate/fit on raw strings, chat formatting for the Instruct model, preprocessor and backbone access, LoRA fine-tuning, and uploading presets back to the Hub. For larger models like Llama 3.1 8B, Keras's ModelParallel distribution with a device mesh and layout map shards weights across TPU/GPU cores. A custom layout map cut epoch time from 62s to 54s on an 8-core TPU v5e.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)

## Prerequisites

- Python ML basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- LLM tokenization ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- model parallelism concepts ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))

## Keywords

Keras, keras\_hub, Llama 3.2, JAX, XLA, TPU v5e, Hugging Face, LoRA

## Related posts

- [Announcing New Hugging Face and KerasHub integration](https://swe.quest/articles/announcing-new-hugging-face-and-kerashub-integration-4c5abe3fdc47bd7b.md): Hugging Face · 2024-07-10 · Medium · 5 min read · Machine learning, LLMs, Python
  KerasHub can now load Transformers-format checkpoints from the Hugging Face Hub directly, through a shared model save format.
- [How good are LLMs at fixing their mistakes? A chatbot arena experiment with Keras and TPUs](https://swe.quest/articles/how-good-are-llms-at-fixing-their-mistakes-a-chatbot-arena-experiment-with-adf023c40d56214c.md): Hugging Face · 2024-12-05 · Medium · 15 min read · LLMs, Evaluation, Inference & serving, Python
  Small instruction-tuned LLMs were given a calendar-assistant task that translates spoken requests into single-line Python API calls, then corrected in plain English when they made mistakes.
- [Tricks from OpenAI gpt-oss YOU 🫵 can use with transformers](https://swe.quest/articles/tricks-from-openai-gpt-oss-you-can-use-with-transformers-aad70bf42c0bd3ff.md): Hugging Face · 2025-09-11 · Hard · 15 min read · Inference & serving, LLMs, Python, Performance engineering
  Hugging Face upgraded transformers to support OpenAI's gpt-oss models, and most of the new features carry over to other models.
- [Transformers now runs llama.cpp quants](https://swe.quest/articles/transformers-now-runs-llama-cpp-quants-cff2353854049dc6.md): Hugging Face · 2026-09-22 · Medium · 11 min read · Inference & serving, LLMs, Python, Performance engineering
  Hugging Face transformers can now load GGUF (llama.cpp) quantized checkpoints via \`from\_pretrained(..., gguf\_file=...)\` and serve them through \`transformers serve\` with an OpenAI-compatible API.
- [Native-speed vLLM transformers modeling backend](https://swe.quest/articles/native-speed-vllm-transformers-modeling-backend-cb3f698fe9046ce3.md): Hugging Face · 2026-07-08 · Hard · 5 min read · Inference & serving, LLMs, Performance engineering, Python
  The transformers modeling backend in vLLM now matches or beats vLLM's hand-written native implementations in throughput.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
