hf-audiolm-qwen: `generate_until` hardcodes `.to("cuda")` and aborts on non-CUDA accelerators
Describe the bug
HFAUDIOLMQWEN.generate_until (lm_eval/models/hf_audiolm.py) moves the encoded batch to CUDA
unconditionally:
inputs["input_ids"] = inputs["input_ids"].to("cuda")
inputs.input_ids = inputs.input_ids.to("cuda")On any accelerator that is not CUDA (Ascend NPU via torch_npu, XPU, MPS, or a CPU-only build)
this aborts before generation starts, so the hf-audiolm-qwen backend can never generate -- even
though the rest of the class threads tensors through self.device / self._model.device.
Found while running the audio models on an Ascend 910B4 (torch 2.15.0.dev + torch_npu); it is
not NPU-specific, any non-CUDA backend hits it.
Reproduction
obj = HFAUDIOLMQWEN.__new__(HFAUDIOLMQWEN) # minimal instance, _device = torch.device("npu:0")
obj.generate_until([Instance("generate_until", {}, ("transcribe this audio", {"max_gen_toks": 4},
{"audio": [{"array": [0.0, 0.1, 0.2]}]}), 0)], disable_tqdm=True) File "lm_eval/models/hf_audiolm.py", line 260, in generate_until
inputs["input_ids"] = inputs["input_ids"].to("cuda")
File "torch/cuda/__init__.py", line 596, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabledExpected behaviour
The batch should follow the device the model was loaded on (self.device), as every other
tensor move in this class already does.
Proposed fix
- inputs["input_ids"] = inputs["input_ids"].to("cuda")
- inputs.input_ids = inputs.input_ids.to("cuda")
+ inputs["input_ids"] = inputs["input_ids"].to(self.device)(The second assignment was a duplicate of the first -- inputs.input_ids = ... writes the same
BatchEncoding entry.)
With that change on the 910B4 the same call reaches the model with input_ids on npu:0 and
returns normally. PR to follow.
Note: on current main the module cannot even be imported because of the separate
MODEL_MAPPING name regression (#4243 / #4244); the run above applies that one-line fix as a
precondition. The two are independent.
Source: EleutherAI/lm-evaluation-harness