root commited on
Commit
0bd0227
·
1 Parent(s): 65158f7

compatible with L40

Browse files
levo_inference.py CHANGED
@@ -47,7 +47,8 @@ class LeVoInference(torch.nn.Module):
47
  tensor_parallel_size=self.cfg.vllm.device_num,
48
  enforce_eager=True,
49
  dtype="bfloat16",
50
- gpu_memory_utilization=self.cfg.vllm.gpu_memory_utilization,
 
51
  tokenizer=None,
52
  skip_tokenizer_init=True,
53
  enable_prompt_embeds=True,
 
47
  tensor_parallel_size=self.cfg.vllm.device_num,
48
  enforce_eager=True,
49
  dtype="bfloat16",
50
+ gpu_memory_utilization=self.cfg.vllm.gpu_memory_utilization,
51
+ max_num_seqs=32,
52
  tokenizer=None,
53
  skip_tokenizer_init=True,
54
  enable_prompt_embeds=True,
vllm_hacked/v1/sample/sampler.py CHANGED
@@ -103,19 +103,6 @@ class Sampler(nn.Module):
103
 
104
  # logits = scores_processed
105
  # # logits = logits_processor_stage1(logits)
106
- print("logits.shape:", logits.shape)
107
- if logits.dim() == 1 or (logits.size(0) != sampling_metadata.top_k.size(0)):
108
- batch_size = sampling_metadata.top_k.size(0)
109
- # 1. 构造假的采样结果 (batch_size,)
110
- sampled = torch.zeros((batch_size,), device=logits.device, dtype=torch.long)
111
- # 2. 构造假的 logprobs (vllm v1 期望 [batch_size, num_logprobs] 或 None)
112
- # 这里给 None 通常是最安全的,除非你的配置强制要求返回 logprobs
113
- processed_logprobs = None
114
- # 3. 返回符合接口要求的 SamplerOutput 对象
115
- return SamplerOutput(
116
- sampled_token_ids=sampled,
117
- logprobs=processed_logprobs
118
- )
119
 
120
  '''单条推理CFG'''
121
  # if logits.shape[0] == 3:
@@ -240,6 +227,15 @@ class Sampler(nn.Module):
240
  logits = self.apply_temperature(logits, sampling_metadata.temperature,
241
  sampling_metadata.all_random)
242
 
 
 
 
 
 
 
 
 
 
243
  # Apply logits processors that only apply to random sampling
244
  # (argmax invariant)
245
  for processor in sampling_metadata.logitsprocs.argmax_invariant:
 
103
 
104
  # logits = scores_processed
105
  # # logits = logits_processor_stage1(logits)
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  '''单条推理CFG'''
108
  # if logits.shape[0] == 3:
 
227
  logits = self.apply_temperature(logits, sampling_metadata.temperature,
228
  sampling_metadata.all_random)
229
 
230
+ # patch
231
+ print("logits.shape:", logits.shape)
232
+ if logits.dim() == 1:
233
+ logits = logits.unsqueeze(0)
234
+ # 如果 batch 对不上(比如 logits 变 [1, 4194560] 这种平铺形状)
235
+ if logits.size(0) != sampling_metadata.top_k.size(0):
236
+ # 强制 reshape 回 [Batch, -1]
237
+ logits = logits.view(sampling_metadata.top_k.size(0), -1)
238
+
239
  # Apply logits processors that only apply to random sampling
240
  # (argmax invariant)
241
  for processor in sampling_metadata.logitsprocs.argmax_invariant: