IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

TokenHashOverride

TokenHashOverride

class max.pipelines.context.TokenHashOverride(*, token_idx, token_hash, source='media')

source

Bases: object

Content hash to use in place of a token when hashing KV-cache blocks.

The token stream itself is unchanged. The override is applied only while computing block hashes, so content that is represented by placeholder tokens can participate in prefix-cache keys.

Parameters:

  • token_idx (int)
  • token_hash (int)
  • source (str)

source

source: str = 'media'

source

Human-readable label describing where the hash override came from (e.g. “image”, “video”).

token_hash

token_hash: int

source

Hash value to use at token_idx while hashing.

token_idx

token_idx: int

source

Index of the token to replace while hashing.