push_cache
Applicability
Product |
Supported (√/x) |
|---|---|
Atlas 350 Accelerator Card |
x |
√ |
|
√ |
|
x |
|
x |
|
x |
Note: For
Function Description
Pushes the cache from the local node to the remote cache based on the cache key (CacheKey).
Prototype
1 2 3 4 5 6 7 8 | push_cache(self, dst_cache_key: CacheKeyByIdAndIndex, src_cache: Cache, src_batch_index: int = 0, src_layer_range: range = None, dst_layer_range: range = None, size: int = -1, tensor_num_per_layer = _NUM_TENSORS_PER_LAYER) -> None |
Parameters
Parameter |
Data Type |
Description |
|---|---|---|
dst_cache_key |
Remote cache index. |
|
src_cache |
Local cache. |
|
src_batch_index |
int |
Local batch index. The default value is 0. |
src_layer_range |
Optional[range] |
(Optional) Layer range of the transmission source, which is used for pulling KVs by layer. The default value is None. The step can only be 1. If this parameter is not set, data at all layers is transmitted. Note that this is the index of the layer, not the index of the tensor. That is, one layer corresponds to N contiguous tensors (K/V). If memory allocation is required, the tensors must be arranged in KV order. Other arrangements are not supported. N is the value of tensor_num_per_layer. The default value is 2. |
dst_layer_range |
Optional[range] |
(Optional) Layer range of the transmission source, which is used for pulling KVs by layer. The default value is None. The step can only be 1. If this parameter is not set, data at all layers is transmitted. Note that this is the index of the layer, not the index of the tensor. That is, one layer corresponds to N contiguous tensors (K/V). If memory allocation is required, the tensors must be arranged in KV order. Other arrangements are not supported. N is the value of tensor_num_per_layer. The default value is 2. |
tensor_num_per_layer |
Optional[int] |
(Optional) Number of tensors at each layer. The default value is 2. The value range is [1, total number of tensors in the cache]. When src_layer_range or dst_layer_range uses non-default values, tensor_num_per_layer can either remain at its default value or be set to another value, which must be divisible by the total number of tensors in the cache. |
size |
int |
Size of the data to be transmitted via a tensor. The default value -1 indicates the size of a local KV entry. Other values are not supported at present. |
Example
Click GitCode, select the matching version, and obtain the sample from the examples/python directory.
Returns
In normal cases, no value 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, an LLMException is thrown.
If the layer_range parameter is abnormal, an LLMException is thrown.
Restrictions
- When src_cache is on the host and dst_cache is on the device, only scenarios where both caches are contiguous are supported.
- When enable_remote_cache_accessible is set to True, the cache_key type must be CacheKeyByIdAndIndex.
- In D2H and H2D transmission scenarios, the device memory pool must be configured during host initialization.
- Currently, src_layer_range and dst_layer_range must have the same value.