-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into energy_star_pr
- Loading branch information
Showing
15 changed files
with
689 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defaults: | ||
- benchmark | ||
- scenario: inference | ||
- launcher: process | ||
- backend: pytorch | ||
- _base_ | ||
- _self_ | ||
|
||
name: pytorch_vlm | ||
|
||
launcher: | ||
device_isolation: true | ||
device_isolation_action: warn | ||
|
||
backend: | ||
device: cuda | ||
device_ids: 0 | ||
no_weights: true | ||
torch_dtype: float16 | ||
model: Qwen/Qwen2-VL-7B-Instruct | ||
|
||
scenario: | ||
memory: true | ||
latency: true | ||
|
||
warmup_runs: 10 | ||
iterations: 10 | ||
duration: 10 | ||
|
||
input_shapes: | ||
# text | ||
batch_size: 1 | ||
sequence_length: 256 | ||
# image | ||
num_images: 2 | ||
num_channels: 3 | ||
height: 224 | ||
width: 224 | ||
|
||
generate_kwargs: | ||
max_new_tokens: 32 | ||
min_new_tokens: 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import logging | ||
import random | ||
import string | ||
from abc import ABC | ||
from typing import Dict, List, Tuple | ||
|
||
import torch | ||
|
||
LOGGER = logging.getLogger("generators") | ||
|
||
|
||
class BaseGenerator(ABC): | ||
def __init__(self, shapes: Dict[str, int], with_labels: bool): | ||
self.shapes = shapes | ||
self.with_labels = with_labels | ||
|
||
def assert_not_missing_shapes(self, required_shapes: List[str]): | ||
for shape in required_shapes: | ||
assert self.shapes.get(shape, None) is not None, ( | ||
f"{shape} either couldn't be inferred automatically from model artifacts or should be provided by the user. " | ||
f"Please provide it under `scenario.input_shapes.{shape}` or open an issue/PR in optimum-benchmark repository. " | ||
) | ||
|
||
@staticmethod | ||
def generate_constant_integers(value: int, shape: Tuple[int]): | ||
return torch.full(shape, value, dtype=torch.int64) | ||
|
||
@staticmethod | ||
def generate_constant_floats(value: float, shape: Tuple[int]): | ||
return torch.full(shape, value, dtype=torch.float32) | ||
|
||
@staticmethod | ||
def generate_random_integers(min_value: int, max_value: int, shape: Tuple[int]): | ||
return torch.randint(min_value, max_value, shape) | ||
|
||
@staticmethod | ||
def generate_random_floats(min_value: float, max_value: float, shape: Tuple[int]): | ||
return torch.rand(shape) * (max_value - min_value) + min_value | ||
|
||
@staticmethod | ||
def generate_ranges(start: int, stop: int, shape: Tuple[int]): | ||
return torch.arange(start, stop).repeat(shape[0], 1) | ||
|
||
@staticmethod | ||
def generate_random_strings(num_seq: int) -> List[str]: | ||
return [ | ||
"".join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(10, 100))) | ||
for _ in range(num_seq) | ||
] | ||
|
||
def __call__(self): | ||
raise NotImplementedError("Generator must implement __call__ method") |
Oops, something went wrong.