Add kolibri 1.1 (#51176)
* Add Kolibri 1.1
Kolibri 1.1 is the successor to Kolibri 1. This commit adds it as a
modular model that is identical to Kolibri 1 for now, together with
the auto mappings, the checkpoint conversion mapping, the docs page
and the common model tests. The following commits add what sets it
apart from Kolibri 1.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Add dense MLP layers to Kolibri 1.1
Layers listed in `mlp_only_layers` have a dense MLP of size
`mlp_only_intermediate_size` instead of a mixture of experts. The
Kolibri 1.1 checkpoints use this for their first two layers.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Share keys and values across Kolibri 1.1 full-attention layers
`kv_source_layers` names, for each layer, the layer whose keys and
values it attends to. A full-attention layer that reads those of an
earlier full-attention layer has no key/value weights of its own.
Checkpoints that still contain these weights load without warnings.
The default matches the Kolibri 1.1 checkpoints: of the 10
full-attention layers, only the 1st, 4th, 5th and 6th compute their
own keys and values.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Add sparse attention to Kolibri 1.1
Full-attention layers attend sparsely. A weight-free indexer scores
keys with the leading query heads against key head 0. Each query
attends to the first sink tokens, the most recent local tokens and
the top-k other keys. These come from a pool of candidate key blocks
that indexer layers select and later layers rescore. Sparse layers
attend to keys and values rounded to NVFP4, as do the routing queries
and keys.
This is a reference implementation: the key selection is applied as
an explicit attention mask and costs time and memory quadratic in the
prompt length. For that reason flash and flex attention, fullgraph
compile, the SDPA flash-dispatch test and the torch.export tests are
disabled.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Inline the default Kolibri 1.1 layouts in the config
The default indexer and K/V source layouts were module globals. They
are only used in `__post_init__` and are now written out there.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Write out the Kolibri 1.1 attention `__init__`
The attention built the key and value projections and the key norm
through its parent and deleted them again in layers that read the
keys and values of another layer. It now has its own `__init__`,
which only creates them in layers that need them, as Gemma 3n does.
`store_kv` becomes `store_full_length_kv`, the name Gemma 3n and
Mistral Large 4 use.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Type the sparse Kolibri 1.1 layers as indexed attention
The sparse layers were listed as `full_attention` in `layer_types`.
For this type `generate` may skip the causal mask when it prepares
the masks for a static cache. The indexers need the mask, so the
model rebuilt it in its forward.
The layers are now `indexed_attention`, whose mask is never skipped,
and the rebuild is gone. `full_attention` entries in a config are
read as `indexed_attention`, as checkpoints list them that way.
The common static cache tests are skipped for this model, as it
cannot be compiled. A test compares cached decoding with a full
forward for the dynamic and the static cache. It replaces the test
of the mask rebuild. Without this change, static cache generation
fails once the rebuild is removed.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Remove the reference key selection from the Kolibri 1.1 tests
The tests carried a second implementation of the key selection and
compared the indexer against it. It restated the indexer rather than
checking it against the training kernels.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Remove redundant Kolibri 1.1 tests
- The left padding test repeated the common tests
`test_left_padding_compatibility` and
`test_*_padding_matches_padding_free_with_position_ids`, which run
with key selection active in the tester's config.
- The key and value rounding test spied on the attention function to
inspect its inputs. The integration tests are the place to check
the rounding against released weights.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Pass the Kolibri 1.1 index pool from layer to layer
Indexers stored their pool of candidate keys in the dict of shared
keys and values, and the model deleted each pool after the last layer
that read it.
A layer only ever reads the pool of the closest preceding indexer.
Decoder layers now return the pool and the model passes it to the
next layer, as Mistral Large 4 does with its top-k indices. The model
drops the pool before an indexer runs, so that two pools never exist
at once. A pool takes one byte per pair of query and key, 0.37 GiB
for a 20000 token prompt.
Logits are bit-identical to before (unpadded, left and right padded
batches, cached decoding, eager and sdpa). On a Kolibri 1.1 checkpoint
with a 20000 token prompt on two GPUs, the loss is unchanged. The peak
memory of the decoder above the weights stays at 5.87 and 5.33 GiB.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Keep Kolibri 1.1 attention heads unsharded under tensor parallelism
Kolibri 1.1 inherited the tensor parallel plan of Kolibri 1, which
shards the query and key heads over the ranks. An indexer scores keys
with the query heads of key head 0. With sharded heads each rank
scored with its own heads and selected different keys, so the logits
differed from a single process run.
The plan now has no attention entries, like Mistral Large 4. It also
covers the dense MLP layers, which the inherited plan left replicated.
Kolibri 1.1 joins the distributed tensor and expert parallel tests.
Expert parallel tests run with the tensor parallel plan too. Before
this change 13 of them failed.
`test_tp_generation_quantized` is skipped, as for ten other models.
It compares greedy tokens of a small random model, quantized to
Float8 once as a whole and once after sharding. Float8 moves the
logits by up to 0.2, while the best two tokens are typically 0.05
apart, so the two runs pick different tokens by chance (43% match,
the test asks for 75%). Without quantization, tensor parallel logits
match a single process to 1e-7. Kolibri 1 fails this test the same
way when it is enabled.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Keep masked tokens out of Kolibri 1.1 sparse layers
The indexer assumed that the keys a query sees are contiguous. A
masked token inside the prompt broke this in three ways:
- With boolean attention masks (sdpa), sink and local tokens were
selected even when masked, so queries attended to them.
- The local tokens were counted from the number of visible keys, not
from the last visible key. Each masked token shifted them by one, so
a query no longer attended to itself.
- The block averages that score the pool included the masked keys.
Sink and local tokens are now counted from the first to the last
visible key. Masked keys in between keep their position, are never
selected and count as zeros in the average of their block.
Logits for contiguous masks are bit-identical to before (unpadded,
left and right padded batches, cached decoding, eager and sdpa).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Reject non-positive Kolibri 1.1 indexer sizes in the config
`index_compression=0` raised a ZeroDivisionError while validating the
config. Non-positive `index_topk` and `index_pool_size`, and a
negative `index_compression`, were accepted and failed in the first
forward with a shape or top-k error.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Default to the dense MLP layers of the released Kolibri 1.1
The default config had no dense MLP layers. The released model has a
dense MLP with an intermediate size of 3584 in its first two layers,
as the model page says. `Kolibri1_1Config()` therefore described an
architecture that was never trained.
`mlp_only_layers` now defaults to the first two layers and
`mlp_only_intermediate_size` to 3584. Pass `mlp_only_layers=[]` for a
model without dense MLP layers. The default config now has the same
architecture fields as the config of a Kolibri 1.1 checkpoint.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Add integration tests for Kolibri 1.1
Kolibri 1.1 had no test on real weights, so nothing showed that the
key selection of the sparse layers works on a trained model.
The new tests follow those of Kolibri 1: logits for a fixed input,
a greedy reply, and recall of a code from the start of a long prompt.
The recall prompt has about 18k tokens, more than the 16384 keys of
an indexer's pool, so the code must survive both the pool selection
and the top-k selection.
The expected values come from an FP8 checkpoint of Kolibri 1.1 and
are the same with the model on one GPU and split over two. The tests
need about 82 GiB of GPU memory. With top-k cut to 1, with random key
scores, or with the code's keys removed from the pool, the recall
test fails.
`Aleph-Alpha/Kolibri-1.1` is not on the Hub yet, so CI cannot run
these tests before the checkpoint is published.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* rename cache
* Stop inheriting the Kolibri 1.1 attention and decoder layer from Kolibri 1
`Kolibri1_1Attention` and `Kolibri1_1DecoderLayer` rewrite both
`__init__` and `forward`, so they took nothing from their Kolibri 1
parents. They also had to skip the parent's `__init__` by calling the
grandparent's directly.
Both now inherit from `nn.Module` and `GradientCheckpointingLayer`.
The `deprecate_kwarg` decorator of `forward`, which the modular
converter copied from the parents, is now written out. The comment
that explained the skipped parent `__init__` is gone with it.
Also sorts the imports and removes two unused ones, which failed the
code quality check.
The generated model file only loses that comment.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Name the Kolibri 1.1 checkpoint in the model card and update its date
The usage example loaded a `<checkpoint>` placeholder. It now loads
`Aleph-Alpha/Kolibri-1.1`, as the docstring example of the model does.
The contribution date moves from 2026-11-11 to 2026-11-23. The
repository consistency check requires it to be within one day of the
day the check runs, so it passes from 2026-11-22 to 2026-11-24.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Rely on Kolibri 1.1 checkpoints that match the model
The model adapted to two properties of exported checkpoints:
- Their configs listed the sparse layers as `full_attention`, the name
Kolibri 1 uses for its full-attention layers. `Kolibri1_1Config`
renamed these entries to `indexed_attention`.
- They kept the key and value projections of layers that read the keys
and values of another layer. `Kolibri1_1Model` ignored these unused
weights when loading.
Checkpoints now list the sparse layers as `indexed_attention` and no
longer contain the unused weights, so both adaptations are removed. A
config that still lists `full_attention` is rejected as an unsupported
layer type, and unused weights are reported as unexpected keys.
`test_invalid_layouts` builds its configs with `indexed_attention` and
checks that `full_attention` is rejected.
`test_shared_kv_checkpoint_weights_are_ignored` is removed with the
ignore list.
A checkpoint exported this way loads with no missing, unexpected or
mismatched keys.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Remove seven custom Kolibri 1.1 tests
Removes the unit tests of the config layouts, the missing key and
value weights of sharing layers, the NVFP4 rounding, the tie-breaking
of the top-k selection, the sparse and dense logits of short and long
sequences, and masked tokens in sparse layers.
`test_cached_decode_matches_full_forward` and the integration tests
stay.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Take Kolibri 1.1 out of the distributed test allowlists
Removes `kolibri1_1` from the model types that the tensor-parallel and
expert-parallel test mixins run for.
The skip of `test_tp_generation_quantized` is removed with it: the
mixin now skips all its tests for Kolibri 1.1.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Declare the Kolibri 1.1 tester values as static overrides
`Kolibri1_1ModelTester` set its small-config values in `__init__`.
Model testers now have to declare them in a literal
`small_config_overrides` dict, so that they can be read without
building a tester. `test_static_defaults_match_built_testers` failed
for the Kolibri 1.1 tester since the merge of `main`.
The 13 values are unchanged. The list of layer types is spelled out to
keep the dict a literal.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* latest modular conversion
* do not apply rope twice
---------
Co-authored-by: Steffen Hirschmann <steffen.hirschmann@aleph-alpha-research.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: Sascha Wirges <sascha.wirges@aleph-alpha-research.com>