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

compatible with L40

Browse files
Files changed (1) hide show
  1. vllm_hacked/v1/sample/sampler.py +3 -5
vllm_hacked/v1/sample/sampler.py CHANGED
@@ -223,18 +223,16 @@ class Sampler(nn.Module):
223
 
224
  assert sampling_metadata.temperature is not None
225
 
 
226
  # Apply temperature.
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)
 
223
 
224
  assert sampling_metadata.temperature is not None
225
 
226
+ print("logits.shape:", logits.shape)
227
  # Apply temperature.
228
  logits = self.apply_temperature(logits, sampling_metadata.temperature,
229
  sampling_metadata.all_random)
230
 
 
 
231
  if logits.dim() == 1:
232
  logits = logits.unsqueeze(0)
 
233
  if logits.size(0) != sampling_metadata.top_k.size(0):
234
+ target_batch = sampling_metadata.top_k.size(0)
235
+ logits = logits.expand(target_batch, -1).contiguous()
236
 
237
  # Apply logits processors that only apply to random sampling
238
  # (argmax invariant)