THUDM / THUDM/slime

Add cache to process inputs

Open
#1,111 2 comments 0 reactions 0 assignees View on GitHub

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:

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.

  1. Add a cache at the data level for processed chat templates.
  2. At the rollout level, reuse the cached result when available.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.