Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/guidellm/benchmark/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import uuid
from abc import ABC
from collections.abc import AsyncIterator, Iterable
from typing import Generic
from typing import Any, Generic

from guidellm.benchmark.profile import Profile
from guidellm.benchmark.progress import BenchmarkerProgress
Expand Down
3 changes: 2 additions & 1 deletion src/guidellm/data/deserializers/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ def _deserialize_with_registered_deserializers(

if len(errors) > 0:
err_msgs = ""

def sort_key(item):
return (isinstance(item[1], DataNotSupportedError), item[0])

for key, err in sorted(errors.items(), key=sort_key):
err_msgs += f"\n - Deserializer '{key}': ({type(err).__name__}) {err}"
raise ValueError(
Expand Down Expand Up @@ -141,4 +143,3 @@ def _deserialize_with_specified_deserializer(
random_seed=random_seed,
**data_kwargs,
)

1 change: 0 additions & 1 deletion src/guidellm/data/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
__all__ = ["DataLoader", "DatasetsIterator"]



class DatasetsIterator(TorchIterableDataset):
def __init__(
self,
Expand Down
8 changes: 2 additions & 6 deletions src/guidellm/data/preprocessors/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def __init__(
self.stream: bool = stream
self.max_tokens: int | None = max_tokens or max_completion_tokens

def __call__(
self, columns: dict[str, list[Any]]
) -> GenerationRequest:
def __call__(self, columns: dict[str, list[Any]]) -> GenerationRequest:
"""
:param columns: A dict of GenerativeDatasetColumnType to Any
"""
Expand Down Expand Up @@ -396,9 +394,7 @@ def __call__( # noqa: C901
class GenerativeAudioTranslationRequestFormatter(
GenerativeAudioTranscriptionRequestFormatter
):
def __call__(
self, columns: dict[str, list[Any]]
) -> GenerationRequest:
def __call__(self, columns: dict[str, list[Any]]) -> GenerationRequest:
result = super().__call__(columns)
result.request_type = "audio_translations"
return result
4 changes: 1 addition & 3 deletions src/guidellm/data/preprocessors/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ def __init__(
dict[GenerativeDatasetColumnType, list[tuple[int, str]]] | None
)

def __call__(
self, row: dict[str, Any]
) -> dict[str, list[Any]]:
def __call__(self, row: dict[str, Any]) -> dict[str, list[Any]]:
if self.datasets_column_mappings is None:
raise ValueError("DefaultGenerativeColumnMapper not setup with data.")

Expand Down
3 changes: 1 addition & 2 deletions src/guidellm/data/preprocessors/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

@runtime_checkable
class DatasetPreprocessor(Protocol):
def __call__(self, item: dict[str, Any]) -> (
GenerationRequest | dict[str, Any]): ...
def __call__(self, item: dict[str, Any]) -> GenerationRequest | dict[str, Any]: ...


@runtime_checkable
Expand Down
2 changes: 1 addition & 1 deletion src/guidellm/preprocess/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def process_dataset(
prompt_tokens: str | Path,
output_tokens: str | Path,
processor_args: dict[str, Any] | None = None,
data_args: dict[str, Any] | None = None,
data_args: dict[str, Any] | None = None, # noqa: ARG001
short_prompt_strategy: ShortPromptStrategy = ShortPromptStrategy.IGNORE,
pad_char: str | None = None,
concat_delimiter: str | None = None,
Expand Down
18 changes: 12 additions & 6 deletions src/guidellm/scheduler/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,10 @@ def init_processes_start(self, start_time: float):
if self._processes_lock is None:
raise RuntimeError("_processes_lock is None in init_processes_start")
if self._offset is None:
raise RuntimeError("_offset is None in init_processes_start; was "
"init_processes_timings not called?")
raise RuntimeError(
"_offset is None in init_processes_start; was "
"init_processes_timings not called?"
)
with self._processes_lock:
self._offset.value = start_time

Expand All @@ -527,11 +529,15 @@ async def next_request_time(self, offset: int) -> float:
next_delay = self._random.expovariate(self.rate)

if self._processes_lock is None:
raise RuntimeError("_processes_lock is None in next_request_time; was "
"init_processes_timings not called?")
raise RuntimeError(
"_processes_lock is None in next_request_time; was "
"init_processes_timings not called?"
)
if self._offset is None:
raise RuntimeError("_offset is None in next_request_time; was "
"init_processes_timings not called?")
raise RuntimeError(
"_offset is None in next_request_time; was "
"init_processes_timings not called?"
)
with self._processes_lock:
self._offset.value += next_delay

Expand Down
6 changes: 1 addition & 5 deletions src/guidellm/scheduler/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ async def _process_next_request(self, target_start: float):
async for resp, info in self.backend.resolve( # type: ignore[attr-defined]
request, request_info, None
):

response = resp
request_info = info
if request_info is None:
Expand Down Expand Up @@ -407,10 +406,7 @@ async def _dequeue_next_request(
return request, request_info

async def _schedule_request(
self,
request: RequestT,
request_info: RequestInfo,
target_start: float
self, request: RequestT, request_info: RequestInfo, target_start: float
):
current_time = time.time()
request_info.timings.scheduled_at = current_time
Expand Down
1 change: 1 addition & 0 deletions src/guidellm/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def parse_list_floats(ctx, param, value): # noqa: ARG001
f"of floats/ints. Error: {e}"
) from e


def parse_json(ctx, param, value): # noqa: ARG001
if value is None or value == [None]:
return None
Expand Down
1 change: 0 additions & 1 deletion tests/unit/benchmark/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def test_file_yaml():
mock_path.unlink()


@pytest.mark.xfail(reason="old and broken", run=False)
@pytest.mark.asyncio
async def test_file_csv():
args = BenchmarkGenerativeTextArgs(target="http://localhost:8000", data=["test"])
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/mock_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ def mock_generative_benchmark() -> GenerativeBenchmark:
benchmarker=BenchmarkerDict(
profile=SynchronousProfile.create("synchronous", rate=None),
requests={
"attributes": {
"data": "prompt_tokens=256,output_tokens=128",
},
"data": "prompt_tokens=256,output_tokens=128",
},
backend={},
environment={},
Expand Down
Loading