What Runs Underneath a Keras 3 Model?

Keras 3 is a Python API with selectable numerical backends. TensorFlow, JAX and PyTorch provide different execution stacks beneath it. Choosing the backend determines which framework handles tensor operations and devices; calling model.compile does not establish one universal compiler path. This diagram shows the routing boundary and links to the detailed execution path for each framework.
Backend
Device

Showing the TensorFlow backend on the CPU: 5 stages, 4 steps.

Your Keras code calls Keras Keras 3 API Keras 3 API uses configured backend Backend dispatch Backend dispatch routes to tensorflow TensorFlow backend TensorFlow backend targets CPU CPU TensorFlow backend targets GPU Configured GPU Backend dispatch routes to jax JAX backend JAX backend targets CPU CPU JAX backend targets GPU Configured GPU Backend dispatch routes to torch PyTorch backend PyTorch backend targets CPU CPU PyTorch backend targets GPU Configured GPU Your Keras code programming language Keras 3 API framework component Backend dispatch framework component TensorFlow backend framework component JAX backend framework component PyTorch backend framework component CPU hardware Configured GPU hardware

The selected path, step by step

  1. Your Keras code calls Keras Keras 3 API: Python enters the shared Keras API rather than selecting numerical kernels directly.
  2. Keras 3 API uses configured backend Backend dispatch: The selected backend must already be configured when Keras is imported.
  3. Backend dispatch routes to tensorflow TensorFlow backend: Keras exposes the backend selected for this process.
  4. TensorFlow backend targets CPU CPU: The selected backend handles supported operations on this configured device; internal compiler stages are linked from the text.

Is Keras the same thing as TensorFlow?

No. Keras 3 can use TensorFlow, JAX or PyTorch as a numerical backend, and also documents an OpenVINO inference-only option. The Keras README describes these choices. A tutorial using tf.keras tells you something about that tutorial’s integration; the broader Keras 3 project is not limited to that one stack.

This page separates the Python-facing API from numerical execution. Building layers, configuring a loss and handling model structure belong to the Keras interface. The selected backend determines which tensor implementation and hardware runtime actually carry out the work. Different backend choices therefore lead to different implementation paths even when the Keras model looks similar.

When does KERAS_BACKEND take effect?

The getting-started guide documents KERAS_BACKEND and the Keras configuration file. Configure the backend before importing Keras. This is a process-level choice in the documented startup workflow, not a per-layer switch that can be changed at an arbitrary point in an already imported program.

Use the control above to compare routes conceptually. It does not execute a model or rewrite the local environment. A working installation still needs the selected backend package and its appropriate CPU or GPU dependencies.

What changes with TensorFlow, JAX or PyTorch?

With TensorFlow, operations can follow eager execution, traced graph execution or explicit XLA compilation. With JAX, tracing, XLA lowering and device execution have their own rules. With PyTorch, eager dispatch and torch.compile are distinct paths. The diagram ends at the backend’s device target so it does not incorrectly present one compiler pipeline as common to all three.

The backend dispatch source shows separate imports for those implementations. That is stronger evidence for the routing boundary than inferring execution from the language percentages reported on a repository page.

Does model.compile mean the same thing on every backend?

Treat the high-level compile API as model configuration, and inspect the documented backend settings before drawing conclusions about machine-code compilation. TensorFlow’s tf.function, JAX’s jit and PyTorch’s torch.compile are different mechanisms. Their names are not interchangeable evidence that a particular kernel fusion or compiler was used.

The same caution applies to performance comparisons: keep model, shapes, precision, device configuration and warmup behavior comparable. This page does not rank frameworks or assume that changing a backend preserves every custom operation or execution detail.

Does selecting a GPU remove Python and CPU work?

No. The selected framework manages device placement and its CPU-side orchestration. The Keras device context exposes backend-independent placement controls, but each backend still needs its own working GPU runtime. The implementation explicitly maps PyTorch’s GPU terminology to CUDA. This page’s GPU route covers supported device operations, not every line of Python.

Every stage

Your Keras code

programming language

A Python program constructs layers or invokes Keras tensor operations.

In the atlas: Python

  • Keras 3 is a multi-backend deep learning framework, with support for JAX, TensorFlow, PyTorch, and OpenVINO (for inference-only).
    Keras 3 README Source repository

Keras 3 API

framework component

Keras supplies a high-level API; its configured backend supplies tensor execution.

In the atlas: Keras

  • Keras 3 is a multi-backend deep learning framework, with support for JAX, TensorFlow, PyTorch, and OpenVINO (for inference-only).
    Keras 3 README Source repository

Backend dispatch

framework component

Keras exposes the selected backend implementation instead of running a second independent tensor engine.

CPU

hardware

The selected backend performs the scoped numerical computation on CPU. This diagram summarizes routing rather than its internal kernel graph.

Configured GPU

hardware

The selected backend performs supported computation on a properly configured GPU. Hardware and dependency support depend on that backend.

Every step

FromStepToWhenWhat happensSource
Your Keras codecalls KerasKeras 3 APIany backend · any devicePython enters the shared Keras API rather than selecting numerical kernels directly.Source repository
Keras 3 APIuses configured backendBackend dispatchany backend · any deviceThe selected backend must already be configured when Keras is imported.Project docs
Backend dispatchroutes to tensorflowTensorFlow backendTensorFlow · any deviceKeras exposes the backend selected for this process.Source repository
TensorFlow backendtargets CPUCPUany backend · CPUThe selected backend handles supported operations on this configured device; internal compiler stages are linked from the text.Source repository
TensorFlow backendtargets GPUConfigured GPUany backend · Configured GPUThe selected backend handles supported operations on this configured device; internal compiler stages are linked from the text.Source repository
Backend dispatchroutes to jaxJAX backendJAX · any deviceKeras exposes the backend selected for this process.Source repository
JAX backendtargets CPUCPUany backend · CPUThe selected backend handles supported operations on this configured device; internal compiler stages are linked from the text.Source repository
JAX backendtargets GPUConfigured GPUany backend · Configured GPUThe selected backend handles supported operations on this configured device; internal compiler stages are linked from the text.Source repository
Backend dispatchroutes to torchPyTorch backendPyTorch · any deviceKeras exposes the backend selected for this process.Source repository
PyTorch backendtargets CPUCPUany backend · CPUThe selected backend handles supported operations on this configured device; internal compiler stages are linked from the text.Source repository
PyTorch backendtargets GPUConfigured GPUany backend · Configured GPUThe selected backend handles supported operations on this configured device; internal compiler stages are linked from the text.Source repository

What this does not show

Keras 3 backend routing for compatible tensor operations or models using TensorFlow, JAX or PyTorch on CPU or a supported configured GPU. This is a routing overview, not a complete training loop or a guarantee of identical backend behavior. OpenVINO inference, NumPy fallback, pluggable backends, distributed training, optimizer internals and framework-specific compilation settings are outside the diagram.

How this page is checked

Every stage and step above quotes the source that supports it. The quotes were checked against the Keras 3 README, backend-configuration guide and Python backend-dispatch implementation on 2026-11-11. The data is a versioned JSON file under the same CC BY 4.0 license as the dataset. Found something wrong or out of date? Open an issue with the better source.

See this path in the graph explorer →

What these tools are written in is in the main atlas: Python, Keras, TensorFlow, JAX, PyTorch. More execution paths: How Does a Rust LLM Generate Tokens with Candle, What Actually Happens When You Run JAX Code, How Does llama.cpp Run a Model on Your Hardware, How Does MLC LLM Turn a Compiled Model into Generated Tokens, What Actually Happens When You Run MLX on a Mac, What Actually Runs When You Send Ollama a Prompt, How Does ONNX Runtime Execute a Model Across Hardware, What Actually Happens When You Run a PyTorch Model, What Actually Happens When SGLang Serves a Request, How Does TensorFlow Run Python on a CPU or GPU, What Actually Happens When TensorRT-LLM Runs a Model, What Actually Happens When You Run a Hugging Face Pipeline, What Actually Happens When vLLM Serves a Request, or compare them all.

Explore the full graph →