Add cache to process inputs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.5k
- Forks
- 1.3k
- Avg merge
- 5h 36m
- Merged PRs (30d)
- 22
Description
We currently apply apply-chat-template and process inputs in two places:
-
Data level
https://github.com/THUDM/slime/blob/ac5328b0108e0c517e70b9369c33b237266a7e07/slime/utils/data.py#L58 -
Rollout level
https://github.com/THUDM/slime/blob/ac5328b0108e0c517e70b9369c33b237266a7e07/slime/rollout/sglang_rollout.py#L99
This causes duplicated computation and unnecessary overhead.
Why Two Stages Are Necessary
We cannot merge these into a single stage(right now, open to optimize):
- Data level: required to check context length early (with tokenization).
- Rollout level: performs tokenization and handles multimodal inputs.
Proposed Solution
Introduce caching to avoid duplicate work.
- Add a cache at the data level for processed chat templates.
- At the rollout level, reuse the cached result when available.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the processing paths at slime/utils/data.py:58 and slime/rollout/sglang_rollout.py:99, then trace how processed chat templates and multimodal inputs move between them. Confirm the cache can be reused at rollout without losing early context-length checks or multimodal handling; done means duplicated processing is avoided while both stages retain their required behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 66/100