guidellm 0.4.0a18__py3-none-any.whl → 0.4.0a155__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of guidellm might be problematic. Click here for more details.
- guidellm/__init__.py +5 -2
- guidellm/__main__.py +451 -252
- guidellm/backends/__init__.py +33 -0
- guidellm/backends/backend.py +110 -0
- guidellm/backends/openai.py +355 -0
- guidellm/backends/response_handlers.py +455 -0
- guidellm/benchmark/__init__.py +53 -39
- guidellm/benchmark/benchmarker.py +148 -317
- guidellm/benchmark/entrypoints.py +466 -128
- guidellm/benchmark/output.py +517 -771
- guidellm/benchmark/profile.py +580 -280
- guidellm/benchmark/progress.py +568 -549
- guidellm/benchmark/scenarios/__init__.py +40 -0
- guidellm/benchmark/scenarios/chat.json +6 -0
- guidellm/benchmark/scenarios/rag.json +6 -0
- guidellm/benchmark/schemas.py +2085 -0
- guidellm/data/__init__.py +28 -4
- guidellm/data/collators.py +16 -0
- guidellm/data/deserializers/__init__.py +53 -0
- guidellm/data/deserializers/deserializer.py +109 -0
- guidellm/data/deserializers/file.py +222 -0
- guidellm/data/deserializers/huggingface.py +94 -0
- guidellm/data/deserializers/memory.py +192 -0
- guidellm/data/deserializers/synthetic.py +346 -0
- guidellm/data/loaders.py +145 -0
- guidellm/data/preprocessors/__init__.py +25 -0
- guidellm/data/preprocessors/formatters.py +412 -0
- guidellm/data/preprocessors/mappers.py +198 -0
- guidellm/data/preprocessors/preprocessor.py +29 -0
- guidellm/data/processor.py +30 -0
- guidellm/data/schemas.py +13 -0
- guidellm/data/utils/__init__.py +10 -0
- guidellm/data/utils/dataset.py +94 -0
- guidellm/data/utils/functions.py +18 -0
- guidellm/extras/__init__.py +4 -0
- guidellm/extras/audio.py +215 -0
- guidellm/extras/vision.py +242 -0
- guidellm/logger.py +2 -2
- guidellm/mock_server/__init__.py +8 -0
- guidellm/mock_server/config.py +84 -0
- guidellm/mock_server/handlers/__init__.py +17 -0
- guidellm/mock_server/handlers/chat_completions.py +280 -0
- guidellm/mock_server/handlers/completions.py +280 -0
- guidellm/mock_server/handlers/tokenizer.py +142 -0
- guidellm/mock_server/models.py +510 -0
- guidellm/mock_server/server.py +168 -0
- guidellm/mock_server/utils.py +302 -0
- guidellm/preprocess/dataset.py +23 -26
- guidellm/presentation/builder.py +2 -2
- guidellm/presentation/data_models.py +25 -21
- guidellm/presentation/injector.py +2 -3
- guidellm/scheduler/__init__.py +65 -26
- guidellm/scheduler/constraints.py +1035 -0
- guidellm/scheduler/environments.py +252 -0
- guidellm/scheduler/scheduler.py +140 -368
- guidellm/scheduler/schemas.py +272 -0
- guidellm/scheduler/strategies.py +519 -0
- guidellm/scheduler/worker.py +391 -420
- guidellm/scheduler/worker_group.py +707 -0
- guidellm/schemas/__init__.py +31 -0
- guidellm/schemas/info.py +159 -0
- guidellm/schemas/request.py +216 -0
- guidellm/schemas/response.py +119 -0
- guidellm/schemas/stats.py +228 -0
- guidellm/{config.py → settings.py} +32 -21
- guidellm/utils/__init__.py +95 -8
- guidellm/utils/auto_importer.py +98 -0
- guidellm/utils/cli.py +46 -2
- guidellm/utils/console.py +183 -0
- guidellm/utils/encoding.py +778 -0
- guidellm/utils/functions.py +134 -0
- guidellm/utils/hf_datasets.py +1 -2
- guidellm/utils/hf_transformers.py +4 -4
- guidellm/utils/imports.py +9 -0
- guidellm/utils/messaging.py +1118 -0
- guidellm/utils/mixins.py +115 -0
- guidellm/utils/pydantic_utils.py +411 -0
- guidellm/utils/random.py +3 -4
- guidellm/utils/registry.py +220 -0
- guidellm/utils/singleton.py +133 -0
- guidellm/{objects → utils}/statistics.py +341 -247
- guidellm/utils/synchronous.py +159 -0
- guidellm/utils/text.py +163 -50
- guidellm/utils/typing.py +41 -0
- guidellm/version.py +1 -1
- {guidellm-0.4.0a18.dist-info → guidellm-0.4.0a155.dist-info}/METADATA +33 -10
- guidellm-0.4.0a155.dist-info/RECORD +96 -0
- guidellm/backend/__init__.py +0 -23
- guidellm/backend/backend.py +0 -259
- guidellm/backend/openai.py +0 -705
- guidellm/backend/response.py +0 -136
- guidellm/benchmark/aggregator.py +0 -760
- guidellm/benchmark/benchmark.py +0 -837
- guidellm/benchmark/scenario.py +0 -104
- guidellm/data/prideandprejudice.txt.gz +0 -0
- guidellm/dataset/__init__.py +0 -22
- guidellm/dataset/creator.py +0 -213
- guidellm/dataset/entrypoints.py +0 -42
- guidellm/dataset/file.py +0 -92
- guidellm/dataset/hf_datasets.py +0 -62
- guidellm/dataset/in_memory.py +0 -132
- guidellm/dataset/synthetic.py +0 -287
- guidellm/objects/__init__.py +0 -18
- guidellm/objects/pydantic.py +0 -89
- guidellm/request/__init__.py +0 -18
- guidellm/request/loader.py +0 -284
- guidellm/request/request.py +0 -79
- guidellm/request/types.py +0 -10
- guidellm/scheduler/queues.py +0 -25
- guidellm/scheduler/result.py +0 -155
- guidellm/scheduler/strategy.py +0 -495
- guidellm-0.4.0a18.dist-info/RECORD +0 -62
- {guidellm-0.4.0a18.dist-info → guidellm-0.4.0a155.dist-info}/WHEEL +0 -0
- {guidellm-0.4.0a18.dist-info → guidellm-0.4.0a155.dist-info}/entry_points.txt +0 -0
- {guidellm-0.4.0a18.dist-info → guidellm-0.4.0a155.dist-info}/licenses/LICENSE +0 -0
- {guidellm-0.4.0a18.dist-info → guidellm-0.4.0a155.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utility functions for safe operations and value handling.
|
|
3
|
+
|
|
4
|
+
Provides defensive programming utilities for common operations that may encounter
|
|
5
|
+
None values, invalid inputs, or edge cases. Includes safe arithmetic operations,
|
|
6
|
+
attribute access, and timestamp formatting.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"all_defined",
|
|
16
|
+
"safe_add",
|
|
17
|
+
"safe_divide",
|
|
18
|
+
"safe_format_timestamp",
|
|
19
|
+
"safe_getattr",
|
|
20
|
+
"safe_multiply",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def safe_getattr(obj: Any | None, attr: str, default: Any = None) -> Any:
|
|
25
|
+
"""
|
|
26
|
+
Safely get an attribute from an object with None handling.
|
|
27
|
+
|
|
28
|
+
:param obj: Object to get the attribute from, or None
|
|
29
|
+
:param attr: Name of the attribute to retrieve
|
|
30
|
+
:param default: Value to return if object is None or attribute doesn't exist
|
|
31
|
+
:return: Attribute value or default if not found or object is None
|
|
32
|
+
"""
|
|
33
|
+
if obj is None:
|
|
34
|
+
return default
|
|
35
|
+
|
|
36
|
+
return getattr(obj, attr, default)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def all_defined(*values: Any | None) -> bool:
|
|
40
|
+
"""
|
|
41
|
+
Check if all provided values are defined (not None).
|
|
42
|
+
|
|
43
|
+
:param values: Variable number of values to check for None
|
|
44
|
+
:return: True if all values are not None, False otherwise
|
|
45
|
+
"""
|
|
46
|
+
return all(value is not None for value in values)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def safe_divide(
|
|
50
|
+
numerator: int | float | None,
|
|
51
|
+
denominator: int | float | None,
|
|
52
|
+
num_default: float = 0.0,
|
|
53
|
+
den_default: float = 1.0,
|
|
54
|
+
) -> float:
|
|
55
|
+
"""
|
|
56
|
+
Safely divide two numbers with None handling and zero protection.
|
|
57
|
+
|
|
58
|
+
:param numerator: Number to divide, or None to use num_default
|
|
59
|
+
:param denominator: Number to divide by, or None to use den_default
|
|
60
|
+
:param num_default: Default value for numerator if None
|
|
61
|
+
:param den_default: Default value for denominator if None
|
|
62
|
+
:return: Division result with protection against division by zero
|
|
63
|
+
"""
|
|
64
|
+
numerator = numerator if numerator is not None else num_default
|
|
65
|
+
denominator = denominator if denominator is not None else den_default
|
|
66
|
+
|
|
67
|
+
return numerator / (denominator or 1e-10)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def safe_multiply(*values: int | float | None, default: float = 1.0) -> float:
|
|
71
|
+
"""
|
|
72
|
+
Safely multiply multiple numbers with None handling.
|
|
73
|
+
|
|
74
|
+
:param values: Variable number of values to multiply, None values treated as 1.0
|
|
75
|
+
:param default: Starting value for multiplication
|
|
76
|
+
:return: Product of all non-None values multiplied by default
|
|
77
|
+
"""
|
|
78
|
+
result = default
|
|
79
|
+
for val in values:
|
|
80
|
+
result *= val if val is not None else 1.0
|
|
81
|
+
return result
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def safe_add(
|
|
85
|
+
*values: int | float | None, signs: list[int] | None = None, default: float = 0.0
|
|
86
|
+
) -> float:
|
|
87
|
+
"""
|
|
88
|
+
Safely add multiple numbers with None handling and optional signs.
|
|
89
|
+
|
|
90
|
+
:param values: Variable number of values to add, None values use default
|
|
91
|
+
:param signs: Optional list of 1 (add) or -1 (subtract) for each value.
|
|
92
|
+
If None, all values are added. Must match length of values.
|
|
93
|
+
:param default: Value to substitute for None values
|
|
94
|
+
:return: Result of adding all values safely (default used when value is None)
|
|
95
|
+
"""
|
|
96
|
+
if not values:
|
|
97
|
+
return default
|
|
98
|
+
|
|
99
|
+
values_list = list(values)
|
|
100
|
+
|
|
101
|
+
if signs is None:
|
|
102
|
+
signs = [1] * len(values_list)
|
|
103
|
+
|
|
104
|
+
if len(signs) != len(values_list):
|
|
105
|
+
raise ValueError("Length of signs must match length of values")
|
|
106
|
+
|
|
107
|
+
result = values_list[0] if values_list[0] is not None else default
|
|
108
|
+
|
|
109
|
+
for ind in range(1, len(values_list)):
|
|
110
|
+
value = values_list[ind]
|
|
111
|
+
checked_value = value if value is not None else default
|
|
112
|
+
result += signs[ind] * checked_value
|
|
113
|
+
|
|
114
|
+
return result
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def safe_format_timestamp(
|
|
118
|
+
timestamp: float | None, format_: str = "%H:%M:%S", default: str = "N/A"
|
|
119
|
+
) -> str:
|
|
120
|
+
"""
|
|
121
|
+
Safely format a timestamp with error handling and validation.
|
|
122
|
+
|
|
123
|
+
:param timestamp: Unix timestamp to format, or None
|
|
124
|
+
:param format_: Strftime format string for timestamp formatting
|
|
125
|
+
:param default: Value to return if timestamp is invalid or None
|
|
126
|
+
:return: Formatted timestamp string or default value
|
|
127
|
+
"""
|
|
128
|
+
if timestamp is None or timestamp < 0 or timestamp > 2**31:
|
|
129
|
+
return default
|
|
130
|
+
|
|
131
|
+
try:
|
|
132
|
+
return datetime.fromtimestamp(timestamp).strftime(format_)
|
|
133
|
+
except (ValueError, OverflowError, OSError):
|
|
134
|
+
return default
|
guidellm/utils/hf_datasets.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Union
|
|
3
2
|
|
|
4
3
|
from datasets import Dataset
|
|
5
4
|
|
|
@@ -11,7 +10,7 @@ SUPPORTED_TYPES = {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
def save_dataset_to_file(dataset: Dataset, output_path:
|
|
13
|
+
def save_dataset_to_file(dataset: Dataset, output_path: str | Path) -> None:
|
|
15
14
|
"""
|
|
16
15
|
Saves a HuggingFace Dataset to file in a supported format.
|
|
17
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
from transformers import AutoTokenizer, PreTrainedTokenizerBase # type: ignore[import]
|
|
5
5
|
|
|
@@ -9,15 +9,15 @@ __all__ = [
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def check_load_processor(
|
|
12
|
-
processor:
|
|
13
|
-
processor_args:
|
|
12
|
+
processor: str | Path | PreTrainedTokenizerBase | None,
|
|
13
|
+
processor_args: dict[str, Any] | None,
|
|
14
14
|
error_msg: str,
|
|
15
15
|
) -> PreTrainedTokenizerBase:
|
|
16
16
|
if processor is None:
|
|
17
17
|
raise ValueError(f"Processor/Tokenizer is required for {error_msg}.")
|
|
18
18
|
|
|
19
19
|
try:
|
|
20
|
-
if isinstance(processor,
|
|
20
|
+
if isinstance(processor, str | Path):
|
|
21
21
|
loaded = AutoTokenizer.from_pretrained(
|
|
22
22
|
processor,
|
|
23
23
|
**(processor_args or {}),
|