Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit f4f22cc

Browse files
authored
Merge branch 'release/1.7' into cherry-pick-sparsezoo-legacy-analyze-name-change
2 parents d1afb3a + 7e7715a commit f4f22cc

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

src/deepsparse/benchmark/benchmark_pipeline.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ def _clear_measurements():
346346
"Generated no batch timings, try extending benchmark time with '--time'"
347347
)
348348

349+
if SupportedTasks.is_text_generation(task) or SupportedTasks.is_code_generation(
350+
task
351+
):
352+
kwargs.pop("middleware_manager")
353+
349354
return batch_times, total_run_time, num_streams
350355

351356

src/deepsparse/evaluation/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
##########
5959
Example command for evaluating a quantized MPT model from SparseZoo using the Deepsparse Engine.
6060
The evaluation will be run using `lm-evaluation-harness` on `hellaswag` and `gsm8k` datasets:
61-
deepsparse.eval zoo:mpt-7b-mpt_pretrain-base_quantized \
61+
deepsparse.evaluate zoo:mpt-7b-mpt_pretrain-base_quantized \
6262
--dataset hellaswag \
6363
--dataset gsm8k \
6464
--integration lm-evaluation-harness \
@@ -173,6 +173,14 @@ def main(
173173
metrics,
174174
integration_args,
175175
):
176+
"""
177+
Evaluate MODEL_PATH on the various evaluation integrations
178+
179+
- MODEL_PATH can be path to an ONNX model, local directory
180+
containing ONNX model (including all the auxiliary files)
181+
or a SparseZoo stub
182+
183+
"""
176184
# join datasets to a list if multiple datasets are passed
177185
datasets = list(dataset) if not isinstance(dataset, str) else dataset
178186
# format kwargs to a dict

src/deepsparse/evaluation/integrations/lm_evaluation_harness.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
from deepsparse import Pipeline
2626
from deepsparse.evaluation.registry import EvaluationRegistry
2727
from deepsparse.evaluation.results import Dataset, Evaluation, Metric, Result
28-
from deepsparse.evaluation.utils import LM_EVALUATION_HARNESS
28+
from deepsparse.evaluation.utils import (
29+
LM_EVALUATION_HARNESS,
30+
LM_EVALUATION_HARNESS_ALIASES,
31+
)
2932
from deepsparse.utils.data import numpy_log_softmax
3033
from lm_eval import evaluator, tasks, utils
3134
from lm_eval.api.instance import Instance
@@ -39,7 +42,9 @@
3942
__all__ = ["integration_eval"]
4043

4144

42-
@EvaluationRegistry.register(name=LM_EVALUATION_HARNESS, alias="lm-eval-harness")
45+
@EvaluationRegistry.register(
46+
name=LM_EVALUATION_HARNESS, alias=LM_EVALUATION_HARNESS_ALIASES
47+
)
4348
def integration_eval(
4449
pipeline: Pipeline,
4550
datasets: Union[List[str], str],
@@ -150,6 +155,10 @@ def max_length(self) -> int:
150155
def max_gen_toks(self) -> int:
151156
return self._max_gen_toks
152157

158+
@property
159+
def model(self) -> Pipeline:
160+
return self.pipeline
161+
153162
def loglikelihood(self, requests) -> List[Tuple[float, bool]]:
154163
"""
155164
Copied directly from

src/deepsparse/evaluation/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from deepsparse import Pipeline
2020
from deepsparse.operators.engine_operator import DEEPSPARSE_ENGINE
21+
from sparsezoo.utils.registry import standardize_lookup_name
2122

2223

2324
__all__ = [
@@ -29,20 +30,27 @@
2930
_LOGGER = logging.getLogger(__name__)
3031

3132
LM_EVALUATION_HARNESS = "lm-evaluation-harness"
33+
LM_EVALUATION_HARNESS_ALIASES = ["lm-eval-harness", "lm-eval"]
3234
PERPLEXITY = "perplexity"
3335

3436

3537
def potentially_check_dependency_import(integration_name: str) -> bool:
3638
"""
3739
Check if the `integration_name` requires importing a dependency.
40+
Checking involves comparing the `integration_name` to the known
41+
integrations (e.g. 'lm-evaluation-harness') or their aliases.
3842
If so, check if the dependency is installed and return True if it is.
3943
Otherwise, return False.
4044
41-
:param integration_name: The name of the integration to check
45+
:param integration_name: The name of the integration to check. The name
46+
is standardized using `standardize_lookup_name` before checking.
4247
:return: True if the dependency is installed, False otherwise
4348
"""
49+
integration_name = standardize_lookup_name(integration_name)
4450

45-
if integration_name == LM_EVALUATION_HARNESS:
51+
if integration_name == LM_EVALUATION_HARNESS or any(
52+
integration_name == alias for alias in LM_EVALUATION_HARNESS_ALIASES
53+
):
4654
from deepsparse.evaluation.integrations import try_import_lm_evaluation_harness
4755

4856
try_import_lm_evaluation_harness()

0 commit comments

Comments
 (0)