OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Kfac Jax

Kfac Jax is a Python library built on JAX that provides the K-FAC optimizer for second-order neural-network optimization and scalable curvature approximations.

Independent OpenViST project profile, based on linked sources.

Kfac Jax — JAX-based neural-network optimization experiments
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Kfac Jax when building or researching JAX-based neural-network training and you want the documented K-FAC optimizer and curvature-estimation approach.

Who it is for

  • Researchers exploring curvature-aware optimization in machine learning.
  • Developers training neural networks with JAX who want to integrate K-FAC.

Documented uses

  • Add K-FAC second-order optimization to JAX training code.
  • Compute approximate curvature information for neural-network optimization.
  • Use K-FAC within a Haiku model training loop.
Before you choose

Requirements & limits

The project is open source under the Apache-2.0 license. The repository documents pip installation from PyPI or GitHub.

  • JAX must be installed first, including relevant accelerator support where needed.
  • The optimizer requires loss registration for curvature estimation and assumes the loss is averaged across minibatch examples.
  • The optimizer handles staging internally; direct jit or pmap wrapping of its step and value-and-gradient function is discouraged or incorrect according to the quickstart.
  • The quickstart uses Haiku, while its dataset iterator is only a placeholder for a real data pipeline.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install KFAC-JAX for a JAX environment

Prepare the library and its documented examples dependencies for use in JAX-based development.

Before you start

  • Python environment with JAX installed and relevant accelerator support configured.
  • pip.

Steps

  1. Install JAX by following the JAX installation instructions for the relevant accelerator support.

  2. Install KFAC-JAX with the command below or from the repository with the command below.

    Documented command
    pip install -U kfac-jax
    Documented command
    pip install git+https://github.com/google-deepmind/kfac-jax
  3. If using the project examples, install their additional dependencies with the command below.

    Documented command
    pip install kfac-jax[examples]

Expected outcome

KFAC-JAX and, if selected, its example dependencies are installed in the Python environment.

Guide limitations

  • This covers installation only; it does not verify the environment or run a model.
  • The repository states that JAX brings a C++ dependency.
Source-based practical guide

Add the K-FAC optimizer to a Haiku training loop

Follow the repository quickstart pattern for initializing and stepping a K-FAC optimizer on a JAX model.

Before you start

  • JAX and KFAC-JAX installed.
  • A Haiku model, a loss function, and a minibatch data pipeline.

Steps

  1. Register the model’s supported loss with the corresponding KFAC-JAX loss-registration function; the quickstart uses softmax cross-entropy.

  2. Provide the loss and its gradients to kfac_jax.Optimizer, setting its auxiliary-output, state and RNG options to match the loss function.

  3. Initialize the optimizer with model parameters, a JAX random key and a batch.

  4. In the training loop, call optimizer.step with the parameters, optimizer state, key and batch.

Expected outcome

The documented integration pattern supplies K-FAC optimizer steps and statistics within a JAX training loop.

Guide limitations

  • The optimizer requires a recognized registered loss to estimate curvature and expects the loss to be averaged over minibatch examples.
  • Do not apply jax.jit or jax.pmap directly to Optimizer.step or the supplied value-and-gradient function; the optimizer stages its step internally.
  • The example demonstrates Haiku; it uses a dummy dataset iterator that must be replaced with the user's data pipeline.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
20 November 2026
Original website title
google-deepmind/kfac-jax · Official homepage title · retained in its source language