{"id":20347481,"url":"https://github.com/meakbiyik/torchcache","last_synced_at":"2025-04-12T00:55:04.141Z","repository":{"id":191419412,"uuid":"683539741","full_name":"meakbiyik/torchcache","owner":"meakbiyik","description":"Cache PyTorch module outputs on-the-fly","archived":false,"fork":false,"pushed_at":"2024-08-25T12:53:48.000Z","size":264,"stargazers_count":40,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T00:54:57.914Z","etag":null,"topics":["cache","cache-storage","caching","caching-library","computer-vision","llm","lvm","mru","natural-language-processing","pytorch","torch"],"latest_commit_sha":null,"homepage":"https://torchcache.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meakbiyik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-26T22:32:22.000Z","updated_at":"2025-03-31T22:48:28.000Z","dependencies_parsed_at":"2023-08-29T21:19:27.189Z","dependency_job_id":"aa105e94-f317-4fd7-955a-6ddfb577d510","html_url":"https://github.com/meakbiyik/torchcache","commit_stats":null,"previous_names":["meakbiyik/torchcache"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meakbiyik%2Ftorchcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meakbiyik%2Ftorchcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meakbiyik%2Ftorchcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meakbiyik%2Ftorchcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meakbiyik","download_url":"https://codeload.github.com/meakbiyik/torchcache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501880,"owners_count":21114683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","cache-storage","caching","caching-library","computer-vision","llm","lvm","mru","natural-language-processing","pytorch","torch"],"created_at":"2024-11-14T22:16:51.686Z","updated_at":"2025-04-12T00:55:04.115Z","avatar_url":"https://github.com/meakbiyik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# torchcache\n\n[![Lint and Test](https://github.com/meakbiyik/torchcache/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/meakbiyik/torchcache/actions/workflows/ci.yaml) [![Codecov](https://codecov.io/gh/meakbiyik/torchcache/graph/badge.svg?token=Oh6mNp0pc8)](https://codecov.io/gh/meakbiyik/torchcache) [![Documentation Status](https://readthedocs.org/projects/torchcache/badge/?version=latest)](https://torchcache.readthedocs.io/en/latest/?badge=latest)\n\nEffortlessly cache PyTorch module outputs on-the-fly with `torchcache`.\n\nParticularly useful for caching and serving the outputs of computationally expensive large, pre-trained PyTorch modules, such as vision transformers. Note that gradients will not flow through the cached outputs.\n\n- [Features](#features)\n- [Installation](#installation)\n- [Basic usage](#basic-usage)\n- [Assumptions](#assumptions)\n- [Contribution](#contribution)\n\n## Features\n\n- Cache PyTorch module outputs either in-memory or persistently to disk.\n- Simple decorator-based interface for easy usage.\n- Uses an MRU (most-recently-used) cache to limit memory/disk usage\n\n## Installation\n\n```bash\npip install torchcache\n```\n\n## Basic usage\n\nQuickly cache the output of your PyTorch module with a single decorator:\n\n```python\nfrom torchcache import torchcache\n\n@torchcache()\nclass MyModule(nn.Module):\n    def __init__(self):\n        super().__init__()\n        self.linear = nn.Linear(10, 10)\n\n    def forward(self, x):\n        # This output will be cached\n        return self.linear(x)\n\ninput_tensor = torch.ones(10, dtype=torch.float32)\n# Output is cached during the first call...\noutput = model(input_tensor)\n# ...and is retrieved from the cache for the next one\noutput_cached = model(input_tensor)\n\n```\n\nSee documentation at [torchcache.readthedocs.io](https://torchcache.readthedocs.io/en/latest/) for more examples.\n\n## Assumptions\n\nTo ensure seamless operation, `torchcache` assumes the following:\n\n- Your module is a subclass of `nn.Module`.\n- The module's forward method accepts any number of positional arguments with shapes `(B, *)`, where `B` is the batch size and `*` represents any number of dimensions. All tensors should be on the same device and have the same dtype.\n- The forward method returns a single tensor of shape `(B, *)`.\n\n## Contribution\n\n1. Ensure you have Python installed.\n2. Install [`poetry`](https://python-poetry.org/docs/#installation).\n3. Run `poetry install`  to set up dependencies.\n4. Run `poetry run pre-commit install` to install pre-commit hooks.\n5. Create a branch, make your changes, and open a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeakbiyik%2Ftorchcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeakbiyik%2Ftorchcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeakbiyik%2Ftorchcache/lists"}