#1915·mlx-lm

FalconH1: default cache is [(None, None) * n] instead of [(None, None)] * n, so only layer 0 runs without a cache (breaks all fine-tuning)

Author: bones-heuremenCreated Sep 23, 2026Updated Sep 23, 2026

Summary

In mlx_lm/models/falcon_h1.py, FalconH1Model.__call__ builds the default cache with the multiplication inside the list:

python
if cache is None:
    cache = [(None, None) * len(self.layers)]

That's a list with one element (a single tuple of 2 * len(layers) Nones), not one (None, None) per layer. The layer loop zips layers with this list, so with no cache passed only layer 0 runs and the rest are silently skipped.

The model is always called without a cache during training, so every mlx_lm lora (and full fine-tune) of a Falcon-H1 model trains against a 1-layer network. The run exits cleanly with no error. Generation isn't affected because it always passes a real cache, so the model looks healthy in chat.

Fix

python
if cache is None:
    cache = [(None, None)] * len(self.layers)

Repro

python
import mlx.core as mx, mlx.nn as nn
from mlx_lm import load
from mlx_lm.models.cache import make_prompt_cache

model, tok = load("tiiuae/Falcon-H1-1.5B-Deep-Instruct")  # any Falcon-H1
ids = mx.array([tok.encode("The night watchman walked the halls and listened to the house settle, counting doors he had checked a thousand times.")])
x, y = ids[:, :-1], ids[:, 1:]
ce = lambda logits: nn.losses.cross_entropy(logits, y).mean().item()
print("no cache  :", ce(model(x)))
print("with cache:", ce(model(x, cache=make_prompt_cache(model))))

Falcon-H1-1.5B-Deep-Instruct (66 blocks, 8-bit MLX conversion), same tokens:

no cache (training path) with cache
current main / 0.31.3 35.500 4.219
with the fix 4.219 4.219

How it showed up

A 1,300-iteration LoRA on Falcon-H1-1.5B-Deep-Instruct (adapters on the last 16 blocks) finished with no NaNs, but loss stayed flat around 34 the whole run and all 144 lora_b tensors were exactly 0.0. No gradient ever reached the adapted blocks, because they never executed.

Environment

  • mlx-lm 0.31.3 (the bug is also present on main as of 2026-09-23), mlx 0.32.0
  • macOS 26.6.2, Apple M5 Max

Happy to open a PR with the one-line fix if that's useful.