Implementation of LlamaDiskCache lacks capacity setting.

未关闭 适合新手
#1,402 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
80/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

该 issue 位于 llama-cpp-python 代码库的 LlamaDiskCache 类中。查找包含此类的文件,该文件可能位于 cache 模块中。修复方法是将 capacity_bytes 参数作为 size_limit 传递给 diskcache.Cache。完成更改后,运行现有的缓存相关测试,以确保容量设置正常工作。

由索引模型根据 Issue 内容生成。

描述

LlamaDiskCache utilizes diskcache module to hold cache.
While LlamaDiskCache.__init__ can have capacity setting, it's not passed to diskcache.Cache.__init__, which is causing capacity mismatch, and it fails to store data of size greater than 1GB (default capacity of diskcache).

Current implementation:

class LlamaDiskCache(BaseLlamaCache):
    """Cache for a llama.cpp model using disk."""

    def __init__(
        self, cache_dir: str = ".cache/llama_cache", capacity_bytes: int = (2 << 30)
    ):
        super().__init__(capacity_bytes)
        self.cache = diskcache.Cache(cache_dir)

This I guess is required:

class LlamaDiskCache(BaseLlamaCache):
    """Cache for a llama.cpp model using disk."""

    def __init__(
        self, cache_dir: str = ".cache/llama_cache", capacity_bytes: int = (2 << 30)
    ):
        super().__init__(capacity_bytes)
        self.cache = diskcache.Cache(cache_dir, size_limit=capacity_bytes) # Added size_limit configuration.
主要语言
Python
星标
10.6k
派生
1.5k
平均合并
23 分钟
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

abetlen/llama-cpp-python 的其他 Issue

查看 abetlen/llama-cpp-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。