Instructions to use ModelCloud/Ripple-65B-Preview-tf5-patch with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ModelCloud/Ripple-65B-Preview-tf5-patch with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ModelCloud/Ripple-65B-Preview-tf5-patch", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download README.md from ModelCloud/Ripple-65B-Preview-tf5-patch: direct link, hf CLI and curl.
- Browser
- Download file 4.88 kB
-
https://huggingface.co/ModelCloud/Ripple-65B-Preview-tf5-patch/resolve/main/README.md
- Command line
-
hf download hf://ModelCloud/Ripple-65B-Preview-tf5-patch/README.md
-
curl -L -o README.md https://huggingface.co/ModelCloud/Ripple-65B-Preview-tf5-patch/resolve/main/README.md
license: apache-2.0
library_name: transformers
tags:
- ricursive
- ripple
- transformers
- patch
Ripple-65B-Preview — Transformers 5.x compatibility patch
Drop-in replacement for modeling_ricursive.py from
ricursiveAI/Ripple-65B-Preview.
The upstream custom code was written against the Transformers 4.x cache API.
Under Transformers 5.x, generate() fails on the very first prefill, and even
after that single line is fixed, padded batches decode incorrectly and
generations longer than sliding_window crash.
This repository distributes the fix only. It contains no weights; use it with the original checkpoint.
Apply
Copy the patched file over the upstream one:
cp modeling_ricursive.py /path/to/Ripple-65B-Preview/modeling_ricursive.py
Or apply the unified diff from the root of a checkout of the model repository:
git apply PATCH.diff
Then load as usual:
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
"ricursiveAI/Ripple-65B-Preview",
trust_remote_code=True,
)
What is broken upstream
Spurious axis on prefill.
prepare_inputs_for_generationdoesinput_ids[:, cache_position]wheneverinput_ids.shape[1] != 1. Transformers 5 pre-creates an emptyDynamicCacheand passescache_position=Nonefor the prefill call, so this becomesinput_ids[:, None]:(batch, seq)turns into(batch, 1, seq). The embedding lookup returns 4-D hidden states and the first decoder layer dies onbsz, q_len, _ = hidden_states.shape.Every decode step fully masked.
_update_causal_maskseeds the mask withfinfo.minand only writes the visible diagonal viatriuwhensequence_length != 1. At decodesequence_length == 1, so the whole row stays masked and the model emits a constant token. The function also writes1.0(not0.0) for visible keys, which biases every score, and callspast_key_values.get_max_cache_shape(), which Transformers 5 removed.position_idsignore padding. They are overwritten withcache_positionfor every row, which is only correct when nothing is padded. With left padding, a short row's real tokens sit at higher indices, so a shared position vector shifts its RoPE phases and the row decodes to garbage.Sliding window uses the wrong absolute positions.
_apply_sliding_window_maskbuildsarange(kv_len)and assumes the keys sit at positions0..kv_len-1. Once the hybrid cache evicts from the left they sit at[cp-kv_len+1 .. cp], so the mask excludes progressively more valid keys (e.g. window 16 at position 32 leaves 0 of 16 keys visible).Mask shape crash past the window. Transformers 5 uses a hybrid cache: sliding layers hold at most
sliding_windowkeys while full-attention layers keep growing. The model builds one mask per forward, so the shape no longer matches the sliding layer's key tensor (RuntimeError: expanded size (1024) must match existing size (1025)).position_idsleft on CPU. Transformers derives them from the caller's tensors before the generation hook runs, so a CPU prompt yields CPU positions even after the inputs are moved, and RoPE fails withmat2 is on cpu.Missing
GenerationMixin. Transformers 5 no longer injects it into remote-code classes, sogeneratecan be missing entirely andgeneration_configis never built.
What the patch changes
prepare_inputs_for_generationrebuilds a missingcache_position, slices only when the cache is warm, derives per-rowposition_idsfrom the padding mask, and movesinput_ids/attention_mask/inputs_embeds/position_idsonto the model device._update_causal_masksizes the key axis fromcache_position, emits0.0for visible keys andfinfo.minelsewhere, and never returns an all-masked single-token decode row._apply_sliding_window_masktrims the shared mask to the keys the layer holds, anchors key positions at the first key the cache still holds, and is skipped when the window cannot bind.RicursiveForCausalLMinheritsGenerationMixinexplicitly.
The patch is backward compatible with Transformers 4.x.
Validation
generate()works under Transformers 5.22.1.- Cached and uncached generation are bit-identical, including past
sliding_window(the eviction path). - Left-padded batches decode bit-identically to the same rows generated unpadded.
- The patched implementation is bit-identical to an independently written reference patch across prefill logits, decode, padded and uncached paths.
Files
modeling_ricursive.py patched drop-in replacement
PATCH.diff unified diff against the upstream file