allocate_blocks_cache

Applicable Products

Product

Supported (√/x)

Ascend 950PR/Ascend 950DT

x

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

x

Atlas inference products

x

Atlas training products

x

Note: For Atlas A2 training products/Atlas A2 inference products, only the Atlas 800I A2 inference server and A200I A2 Box heterogeneous subrack are supported.

Function Description

In the PagedAttention scenario, allocates the cache with multiple blocks. After the cache is successfully allocated, the memory can be released through deallocate_blocks_cache.

Prototype

1
allocate_blocks_cache(cache_desc: CacheDesc, blocks_cache_key: Optional[BlocksCacheKey] = None)

Parameters

Parameter

Data Type

Value Description

cache_desc

CacheDesc

Cache description.

blocks_cache_key

Optional[BlocksCacheKey]

Indexes a blocks cache.

Example

1
2
3
4
from llm_datadist import *
...
blocks_cache_key = BlocksCacheKey(1, 0)
blocks_cache = cache_manager.allocate_blocks_cache(cache_desc, blocks_cache_key)

Returns

In normal cases, the cache is returned.

If the input data type is incorrect, the TypeError or ValueError exception is reported.

If the execution time exceeds the value of sync_kv_timeout, LLMException is thrown.

Constraints

The memory pool must be configured before this API call.