You might want to try caching to a file with mlx.
https://github.com/ml-explore/mlx-examples/pull/956
edit: here's a quick example for qwen2.5-1M from a mlx dev
https://github.com/ml-explore/mlx-examples/pull/956
edit: here's a quick example for qwen2.5-1M from a mlx dev