Skip to content

Fixing cache.empty() calls - #4813

Merged
danielhanchen merged 2 commits into
fix/ui-fixfrom
fix/gemma4-mlx
Apr 3, 2026
Merged

danielhanchen merged 2 commits into
fix/ui-fixfrom
fix/gemma4-mlx

Conversation

@Manan17

@Manan17 Manan17 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

This pr fixes the cache.empty() calls which errored earlier due to mismatch mlx verions.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@danielhanchen
danielhanchen merged commit 541c8a6 into fix/ui-fix Apr 3, 2026
@danielhanchen
danielhanchen deleted the fix/gemma4-mlx branch April 3, 2026 04:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ebe4d673e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

queries = self.rope(queries, offset = offset)

if self.is_kv_shared_layer and cache is not None and not cache.empty():
if self.is_kv_shared_layer and cache is not None and len(cache) > 0:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid len(cache) when checking shared KV cache state

In Attention.__call__, this new condition can crash at runtime for the default cache objects used in this file (KVCache/RotatingKVCache) because many mlx-lm cache implementations provide empty()/offset but not __len__; when num_kv_shared_layers > 0, calling len(cache) raises TypeError before attention runs. This means generation fails as soon as execution reaches a KV-shared layer with a standard cache entry.

Useful? React with 👍 / 👎.

danielhanchen pushed a commit that referenced this pull request Apr 17, 2026
* unsloth gemma4 support files

* some fixes

* Fixing cache.empty() calls (#4813)

* Fixing cache.empty() calls

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Manan Shah <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Fix/gemma4 mlx (#4816)

* Fixing cache.empty() calls

* fixing for mlx versions

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Manan Shah <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* removed bidirectional check for 31b (#4839)

Co-authored-by: Manan17 <[email protected]>

* Add Gemma 4 26B MoE support (MLX) (#4844)

* removed bidirectional check for 31b

* Change gemma4_text for moe

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Manan Shah <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(gemma4): cast RoPE offset to int before mx.arange() (#4901)

* fix(gemma4): cast RoPE offset to int before mx.arange()

* fix(gemma4): use zero-based arange + offset to avoid CPU-GPU sync

* qwen3.6 patches for multi-turn chat

* qwen3.6 script

* removing unnecessary scripts

* displaying errors for not installed packages

---------

Co-authored-by: Roland Tannous <[email protected]>
Co-authored-by: Manan Shah <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Manan17 <[email protected]>
Co-authored-by: Théophile Lafargue <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants