Skip to content

Commit 9104793

Browse files
fix llamacpp and windows libuv (#298)
1 parent 7f5d486 commit 9104793

File tree

6 files changed

+13
-20
lines changed

6 files changed

+13
-20
lines changed

optimum_benchmark/backends/base.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,11 @@ def __init__(self, config: BackendConfigT):
7070

7171
elif self.config.library == "llama_cpp":
7272
self.logger.info("\t+ Benchmarking a LlamaCpp model")
73-
# TOD: need a custom method to extract shapes from gguf
74-
self.model_shapes = extract_transformers_shapes_from_artifacts(
75-
self.pretrained_config, self.pretrained_processor
76-
)
7773
self.pretrained_processor = None
78-
self.generation_config = None
7974
self.pretrained_config = None
75+
self.generation_config = None
8076
self.automodel_loader = None
77+
self.model_shapes = {}
8178

8279
else:
8380
self.logger.info("\t+ Benchmarking a Transformers model")

optimum_benchmark/backends/llama_cpp/backend.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,10 @@ def llama_cpp_kwargs(self) -> Dict[str, Any]:
4141
"echo": False,
4242
}
4343

44-
def prepare_input_shapes(self, input_shapes: Dict[str, Any]) -> Dict[str, Any]:
45-
if self.config.task == "text-generation":
46-
if input_shapes["batch_size"] != 1:
47-
raise ValueError("Batch size must be 1 for LlamaCpp text generation")
48-
49-
return input_shapes
50-
5144
def prepare_inputs(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
5245
if self.config.task == "text-generation":
46+
if inputs["input_ids"].shape[0] != 1:
47+
raise ValueError("Batch size must be 1 for LlamaCpp text generation")
5348
return {"tokens": inputs["input_ids"].squeeze(0).tolist()}
5449

5550
elif self.config.task == "feature-extraction":

optimum_benchmark/backends/pytorch/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .config import PyTorchConfig
2626

2727
if is_deepspeed_available():
28-
import deepspeed
28+
import deepspeed # type: ignore
2929

3030
if is_torch_distributed_available():
3131
import torch.distributed

optimum_benchmark/launchers/torchrun/launcher.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import sys
32
import traceback
43
from contextlib import ExitStack
54
from logging import Logger
@@ -155,10 +154,6 @@ def entrypoint(worker: Callable[..., BenchmarkReport], worker_args: List[Any], l
155154
else:
156155
setup_logging(level="ERROR", to_file=log_to_file, prefix=f"RANK-PROCESS-{rank}")
157156

158-
if sys.platform == "win32":
159-
logger.info("\t+ Disabline libuv on Windows")
160-
os.environ["USE_LIBUV"] = "0"
161-
162157
if torch.cuda.is_available():
163158
logger.info(f"\t+ Setting torch.distributed cuda device to {rank}")
164159
device = torch.device("cuda", rank)

tests/configs/_gguf_.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ hydra:
22
mode: MULTIRUN
33
sweeper:
44
params:
5+
backend.model: ggml-org/models
56
backend.task: text-generation,feature-extraction
6-
backend.model: QuantFactory/gpt2-GGUF
7-
backend.filename: gpt2.Q4_0.gguf
7+
backend.filename: tinyllamas/stories15M-q8_0.gguf

tests/test_cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def test_cli_configs(config_name):
5353

5454
@pytest.mark.parametrize("launcher", ["inline", "process", "torchrun"])
5555
def test_cli_exit_code_0(launcher):
56+
if launcher == "torchrun" and sys.platform == "win32":
57+
pytest.skip("torchrun is not supported on Windows")
58+
5659
args_0 = [
5760
"optimum-benchmark",
5861
"--config-dir",
@@ -73,6 +76,9 @@ def test_cli_exit_code_0(launcher):
7376

7477
@pytest.mark.parametrize("launcher", ["inline", "process", "torchrun"])
7578
def test_cli_exit_code_1(launcher):
79+
if launcher == "torchrun" and sys.platform == "win32":
80+
pytest.skip("torchrun is not supported on Windows")
81+
7682
args_1 = [
7783
"optimum-benchmark",
7884
"--config-dir",

0 commit comments

Comments
 (0)