Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ possibly-missing-attribute = "ignore"
missing-argument = "ignore"
unused-type-ignore-comment = "ignore"

[tool.bandit]
exclude_dirs = ["tests", "docs"]


[tool.coverage.run]
source = ["src/pruna"]
Expand Down Expand Up @@ -97,14 +94,14 @@ stable-fast-pruna = { index = "pruna_internal", extra = "stable-fast-extraindex"

[project]
name = "pruna"
version = "0.3.3"
version = "0.3.2"
description = "Smash your AI models"
authors = [
{name = "Pruna AI", email = "hello@pruna.ai"}
]
license = {file = "LICENSE"}
readme = "README.md"
requires-python = ">=3.10,<3.14"
requires-python = ">=3.10,<3.13"
keywords = ["AI", "machine learning", "model optimization", "pruning"]
classifiers = [
"Development Status :: 4 - Beta",
Expand Down Expand Up @@ -157,6 +154,7 @@ dependencies = [
"peft>=0.18.0,<0.19.0",
"trl<=0.21.0",
"termcolor==2.3.0",
"realesrgan",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heavy realesrgan moved from optional to core dependencies

Medium Severity

realesrgan was previously under the optional upscale extra but is now a core dependency in dependencies. This forces all users to install a heavy GPU-oriented package (with native compilation requirements) even if they never use upscaling. The upscale optional extra was simultaneously removed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 21212de. Configure here.

]

[project.optional-dependencies]
Expand All @@ -171,6 +169,10 @@ vllm = [
"vllm>=0.16.0",
"ray",
]
evaluation = [
"outlines>1.2.0,<2.0.0",
"litellm>=1.0.0",
]
stable-fast = [
"xformers>=0.0.30",
"stable-fast-pruna>=1.0.8,<1.0.9",
Expand All @@ -195,18 +197,12 @@ awq = [
"llmcompressor>=0.9",
"torch>=2.9.0"
]
upscale = [
"realesrgan",
]
full = [
"pruna[stable-fast]",
]
vbench = [
"vbench-pruna; sys_platform != 'darwin'",
]
rapidata = [
"rapidata>=3.0.0"
]
dev = [
"wget",
"python-dotenv",
Expand All @@ -233,15 +229,12 @@ dev = [
"types-PyYAML",
"logbar",
"pytest-xdist>=3.8.0",
"pruna[evaluation]",
]
cpu = []
lmharness = [
"lm-eval>=0.4.0"
]
evaluation = [
"pruna[rapidata]",
"pruna[lmharness]"
]

# Intel extension is tightly coupled with the torch version
intel = [
Expand Down
12 changes: 12 additions & 0 deletions src/pruna/evaluation/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
from pruna.evaluation.metrics.metric_rapiddata import RapidataMetric as RapidataMetric
from pruna.evaluation.metrics.metric_sharpness import SharpnessMetric
from pruna.evaluation.metrics.metric_torch import TorchMetricWrapper
from pruna.evaluation.metrics.vlm_base import (
BaseVLM,
LitellmVLM,
StatefulVLMMeanScoresMetric,
TransformersVLM,
get_vlm,
)

__all__ = [
"MetricRegistry",
Expand All @@ -47,4 +54,9 @@
"AestheticLAION",
"LMEvalMetric",
"RapidataMetric",
"BaseVLM",
"LitellmVLM",
"StatefulVLMMeanScoresMetric",
"TransformersVLM",
"get_vlm",
]
27 changes: 18 additions & 9 deletions src/pruna/evaluation/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ def metric_data_processor(
This function determines the order and selection of inputs to be passed to various metrics.

The function supports different input arrangements through the 'call_type' configuration:
- 'x_y': Uses input data (x) and model outputs
- 'gt_y': Uses ground truth (gt) and model outputs
- 'y_x': Uses model outputs and input data (x)
- 'y_gt': Uses model outputs and ground truth (gt)
- 'pairwise_gt_y': Uses cached base model outputs (gt) and smashed model outputs (y).
- 'pairwise_y_gt': Uses smashed model outputs (y) and cached base model outputs (gt).
The evaluation agent is expected to pass the cached base model outputs as gt.

- 'y_gt': Model's output first, then ground truth. Returns [outputs, gt].
- 'gt_y': Ground truth first, then model's output. Returns [gt, outputs].
- 'y_x': Model's output first, then input data. Returns [outputs, x].
Used by CLIPScore, VQA, ImageEditScore, VIEScore.
- 'x_y': Input data first, then model's output. Returns [x, outputs].
- 'x_gt': Input data first, then ground truth. Returns [x, gt].
- 'gt_x': Ground truth first, then input data. Returns [gt, x].
- 'pairwise_y_gt': Base model's output first, then subsequent model's output.
- 'pairwise_gt_y': Subsequent model's output first, then base model's output.
- 'y': Only the output is used; the metric has an internal dataset. Returns [outputs].

Parameters
----------
Expand All @@ -85,7 +89,8 @@ def metric_data_processor(
Raises
------
ValueError
If the specified call_type is not one of: 'x_y', 'gt_y', 'y_x', 'y_gt', 'pairwise'.
If the specified call_type is not one of: 'y_gt', 'gt_y', 'y_x', 'x_y',
'x_gt', 'gt_x', 'pairwise_y_gt', 'pairwise_gt_y', 'y'.

Examples
--------
Expand All @@ -106,11 +111,15 @@ def metric_data_processor(
return [outputs, x]
elif call_type == "y_gt":
return [outputs, gt]
elif call_type == "x_gt":
return [x, gt]
elif call_type == "gt_x":
return [gt, x]
elif call_type == "pairwise_gt_y":
return [gt, outputs]
elif call_type == "pairwise_y_gt":
return [outputs, gt]
elif call_type == "y": # IQA metrics that have an internal dataset
elif call_type == "y":
return [outputs]
else:
raise ValueError(f"Invalid call type: {call_type}")
Expand Down
Loading