15 Commits

Author SHA1 Message Date
Chranos
ebdc6fed03 fix: pass lm_head to LogitsProcessor instead of calling forward()
In vLLM v0.6.2, ParallelLMHead.forward() raises RuntimeError since
its weights should be used through LogitsProcessor.linear_method.apply().
Pass lm_head as first arg to LogitsProcessor which handles the
hidden_states -> logits projection internally.
2026-02-06 14:21:14 +08:00
Chranos
b702adf015 testing dynamic register 2026-02-06 14:17:06 +08:00
Chranos
fba02652c8 testing dynamic register 2026-02-06 14:04:04 +08:00
Chranos
5d2f4000cc testing dynamic register 2026-02-06 13:51:02 +08:00
Chranos
f088a6b45d testing dynamic register 2026-02-06 13:39:13 +08:00
Chranos
d31ace279b testing dynamic register 2026-02-05 18:57:04 +08:00
Chranos
ac2082ff36 testing dynamic register 2026-02-05 18:48:11 +08:00
Chranos
2068984bde testing dynamic register 2026-02-05 18:36:03 +08:00
Chranos
df848b4284 testing dynamic register 2026-02-05 18:24:33 +08:00
Chranos
4d0da98b9e testing dynamic register 2026-02-05 18:21:31 +08:00
Chranos
05605419e3 testing dynamic register 2026-02-05 18:08:05 +08:00
Chranos
332e5f71a6 testing dynamic register 2026-02-05 18:02:59 +08:00
Chranos
6e38461af6 testing dynamic register 2026-02-05 17:11:09 +08:00
Chranos
b399840b8d testing dynamic register 2026-02-05 16:30:44 +08:00
808b9b7c97 删除 .DS_Store 2026-02-05 16:20:54 +08:00
2 changed files with 2 additions and 47 deletions

View File

@@ -24,29 +24,8 @@ def vllm__worker__cache_engine__CacheEngine___allocate_kv_cache(
============================= =============================
Modify by vllm_mlu Modify by vllm_mlu
============================= =============================
@brief: add kv_cache_scale for int8 support; @brief: add kv_cache_scale for int8 support
cap num_blocks to avoid exceeding CNNL int32 element limit
''' '''
# CNNL operators have a max supported tensor element count of INT32_MAX.
# If the kv_cache tensor would exceed this limit, reduce num_blocks.
CNNL_MAX_TENSOR_ELEMENTS = 2**31 - 1
total_elements = 1
for dim in kv_cache_shape:
total_elements *= dim
if total_elements > CNNL_MAX_TENSOR_ELEMENTS:
# Calculate the max num_blocks that fits within the limit.
# kv_cache_shape = (2, num_blocks, num_kv_heads, block_size, head_size)
elements_per_block = total_elements // num_blocks
max_num_blocks = CNNL_MAX_TENSOR_ELEMENTS // elements_per_block
logger.warning(
"KV cache tensor elements (%d) exceed CNNL max (%d). "
"Reducing num_blocks from %d to %d.",
total_elements, CNNL_MAX_TENSOR_ELEMENTS,
num_blocks, max_num_blocks)
num_blocks = max_num_blocks
kv_cache_shape = self.attn_backend.get_kv_cache_shape(
num_blocks, self.block_size, self.num_kv_heads, self.head_size)
kv_cache_scales_shape = self.attn_backend.get_kv_cache_scale_shape( kv_cache_scales_shape = self.attn_backend.get_kv_cache_scale_shape(
num_blocks, self.block_size, self.num_kv_heads) num_blocks, self.block_size, self.num_kv_heads)
pin_memory = is_pin_memory_available() if device == "cpu" else False pin_memory = is_pin_memory_available() if device == "cpu" else False

View File

@@ -95,30 +95,6 @@ class MLUWorker_V2(MLUWorker):
num_gpu_blocks = max(num_gpu_blocks, 0) num_gpu_blocks = max(num_gpu_blocks, 0)
num_cpu_blocks = max(num_cpu_blocks, 0) num_cpu_blocks = max(num_cpu_blocks, 0)
# Cap num_gpu_blocks to avoid exceeding CNNL's int32 tensor element
# limit. CNNL operators do not support tensors with more than
# 2^31 - 1 elements. The KV cache shape is typically
# (2, num_blocks, num_kv_heads, block_size, head_size), and when
# num_blocks is very large (e.g. for tiny models with huge free
# memory), the total element count can overflow.
CNNL_MAX_TENSOR_ELEMENTS = 2**31 - 1
block_size = self.cache_config.block_size
num_kv_heads = self.model_config.get_num_kv_heads(
self.parallel_config)
head_size = self.model_config.get_head_size()
# kv_cache_shape = (2, num_blocks, num_kv_heads, block_size, head_size)
elements_per_block = 2 * num_kv_heads * block_size * head_size
if elements_per_block > 0:
max_blocks_by_cnnl = CNNL_MAX_TENSOR_ELEMENTS // elements_per_block
if num_gpu_blocks > max_blocks_by_cnnl:
logger.warning(
"Reducing num_gpu_blocks from %d to %d to stay within "
"CNNL max tensor element limit (%d). "
"elements_per_block=%d",
num_gpu_blocks, max_blocks_by_cnnl,
CNNL_MAX_TENSOR_ELEMENTS, elements_per_block)
num_gpu_blocks = max_blocks_by_cnnl
logger.info( logger.info(
"Memory profiling results: total_gpu_memory=%.2fGiB" "Memory profiling results: total_gpu_memory=%.2fGiB"
" initial_memory_usage=%.2fGiB peak_torch_memory=%.2fGiB" " initial_memory_usage=%.2fGiB peak_torch_memory=%.2fGiB"