guidellm 0.3.1__py3-none-any.whl → 0.6.0a5__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.
Files changed (141) hide show
  1. guidellm/__init__.py +5 -2
  2. guidellm/__main__.py +524 -255
  3. guidellm/backends/__init__.py +33 -0
  4. guidellm/backends/backend.py +109 -0
  5. guidellm/backends/openai.py +340 -0
  6. guidellm/backends/response_handlers.py +428 -0
  7. guidellm/benchmark/__init__.py +69 -39
  8. guidellm/benchmark/benchmarker.py +160 -316
  9. guidellm/benchmark/entrypoints.py +560 -127
  10. guidellm/benchmark/outputs/__init__.py +24 -0
  11. guidellm/benchmark/outputs/console.py +633 -0
  12. guidellm/benchmark/outputs/csv.py +721 -0
  13. guidellm/benchmark/outputs/html.py +473 -0
  14. guidellm/benchmark/outputs/output.py +169 -0
  15. guidellm/benchmark/outputs/serialized.py +69 -0
  16. guidellm/benchmark/profiles.py +718 -0
  17. guidellm/benchmark/progress.py +553 -556
  18. guidellm/benchmark/scenarios/__init__.py +40 -0
  19. guidellm/benchmark/scenarios/chat.json +6 -0
  20. guidellm/benchmark/scenarios/rag.json +6 -0
  21. guidellm/benchmark/schemas/__init__.py +66 -0
  22. guidellm/benchmark/schemas/base.py +402 -0
  23. guidellm/benchmark/schemas/generative/__init__.py +55 -0
  24. guidellm/benchmark/schemas/generative/accumulator.py +841 -0
  25. guidellm/benchmark/schemas/generative/benchmark.py +163 -0
  26. guidellm/benchmark/schemas/generative/entrypoints.py +381 -0
  27. guidellm/benchmark/schemas/generative/metrics.py +927 -0
  28. guidellm/benchmark/schemas/generative/report.py +158 -0
  29. guidellm/data/__init__.py +34 -4
  30. guidellm/data/builders.py +541 -0
  31. guidellm/data/collators.py +16 -0
  32. guidellm/data/config.py +120 -0
  33. guidellm/data/deserializers/__init__.py +49 -0
  34. guidellm/data/deserializers/deserializer.py +141 -0
  35. guidellm/data/deserializers/file.py +223 -0
  36. guidellm/data/deserializers/huggingface.py +94 -0
  37. guidellm/data/deserializers/memory.py +194 -0
  38. guidellm/data/deserializers/synthetic.py +246 -0
  39. guidellm/data/entrypoints.py +52 -0
  40. guidellm/data/loaders.py +190 -0
  41. guidellm/data/preprocessors/__init__.py +27 -0
  42. guidellm/data/preprocessors/formatters.py +410 -0
  43. guidellm/data/preprocessors/mappers.py +196 -0
  44. guidellm/data/preprocessors/preprocessor.py +30 -0
  45. guidellm/data/processor.py +29 -0
  46. guidellm/data/schemas.py +175 -0
  47. guidellm/data/utils/__init__.py +6 -0
  48. guidellm/data/utils/dataset.py +94 -0
  49. guidellm/extras/__init__.py +4 -0
  50. guidellm/extras/audio.py +220 -0
  51. guidellm/extras/vision.py +242 -0
  52. guidellm/logger.py +2 -2
  53. guidellm/mock_server/__init__.py +8 -0
  54. guidellm/mock_server/config.py +84 -0
  55. guidellm/mock_server/handlers/__init__.py +17 -0
  56. guidellm/mock_server/handlers/chat_completions.py +280 -0
  57. guidellm/mock_server/handlers/completions.py +280 -0
  58. guidellm/mock_server/handlers/tokenizer.py +142 -0
  59. guidellm/mock_server/models.py +510 -0
  60. guidellm/mock_server/server.py +238 -0
  61. guidellm/mock_server/utils.py +302 -0
  62. guidellm/scheduler/__init__.py +69 -26
  63. guidellm/scheduler/constraints/__init__.py +49 -0
  64. guidellm/scheduler/constraints/constraint.py +325 -0
  65. guidellm/scheduler/constraints/error.py +411 -0
  66. guidellm/scheduler/constraints/factory.py +182 -0
  67. guidellm/scheduler/constraints/request.py +312 -0
  68. guidellm/scheduler/constraints/saturation.py +722 -0
  69. guidellm/scheduler/environments.py +252 -0
  70. guidellm/scheduler/scheduler.py +137 -368
  71. guidellm/scheduler/schemas.py +358 -0
  72. guidellm/scheduler/strategies.py +617 -0
  73. guidellm/scheduler/worker.py +413 -419
  74. guidellm/scheduler/worker_group.py +712 -0
  75. guidellm/schemas/__init__.py +65 -0
  76. guidellm/schemas/base.py +417 -0
  77. guidellm/schemas/info.py +188 -0
  78. guidellm/schemas/request.py +235 -0
  79. guidellm/schemas/request_stats.py +349 -0
  80. guidellm/schemas/response.py +124 -0
  81. guidellm/schemas/statistics.py +1018 -0
  82. guidellm/{config.py → settings.py} +31 -24
  83. guidellm/utils/__init__.py +71 -8
  84. guidellm/utils/auto_importer.py +98 -0
  85. guidellm/utils/cli.py +132 -5
  86. guidellm/utils/console.py +566 -0
  87. guidellm/utils/encoding.py +778 -0
  88. guidellm/utils/functions.py +159 -0
  89. guidellm/utils/hf_datasets.py +1 -2
  90. guidellm/utils/hf_transformers.py +4 -4
  91. guidellm/utils/imports.py +9 -0
  92. guidellm/utils/messaging.py +1118 -0
  93. guidellm/utils/mixins.py +115 -0
  94. guidellm/utils/random.py +3 -4
  95. guidellm/utils/registry.py +220 -0
  96. guidellm/utils/singleton.py +133 -0
  97. guidellm/utils/synchronous.py +159 -0
  98. guidellm/utils/text.py +163 -50
  99. guidellm/utils/typing.py +41 -0
  100. guidellm/version.py +2 -2
  101. guidellm-0.6.0a5.dist-info/METADATA +364 -0
  102. guidellm-0.6.0a5.dist-info/RECORD +109 -0
  103. guidellm/backend/__init__.py +0 -23
  104. guidellm/backend/backend.py +0 -259
  105. guidellm/backend/openai.py +0 -708
  106. guidellm/backend/response.py +0 -136
  107. guidellm/benchmark/aggregator.py +0 -760
  108. guidellm/benchmark/benchmark.py +0 -837
  109. guidellm/benchmark/output.py +0 -997
  110. guidellm/benchmark/profile.py +0 -409
  111. guidellm/benchmark/scenario.py +0 -104
  112. guidellm/data/prideandprejudice.txt.gz +0 -0
  113. guidellm/dataset/__init__.py +0 -22
  114. guidellm/dataset/creator.py +0 -213
  115. guidellm/dataset/entrypoints.py +0 -42
  116. guidellm/dataset/file.py +0 -92
  117. guidellm/dataset/hf_datasets.py +0 -62
  118. guidellm/dataset/in_memory.py +0 -132
  119. guidellm/dataset/synthetic.py +0 -287
  120. guidellm/objects/__init__.py +0 -18
  121. guidellm/objects/pydantic.py +0 -89
  122. guidellm/objects/statistics.py +0 -953
  123. guidellm/preprocess/__init__.py +0 -3
  124. guidellm/preprocess/dataset.py +0 -374
  125. guidellm/presentation/__init__.py +0 -28
  126. guidellm/presentation/builder.py +0 -27
  127. guidellm/presentation/data_models.py +0 -232
  128. guidellm/presentation/injector.py +0 -66
  129. guidellm/request/__init__.py +0 -18
  130. guidellm/request/loader.py +0 -284
  131. guidellm/request/request.py +0 -79
  132. guidellm/request/types.py +0 -10
  133. guidellm/scheduler/queues.py +0 -25
  134. guidellm/scheduler/result.py +0 -155
  135. guidellm/scheduler/strategy.py +0 -495
  136. guidellm-0.3.1.dist-info/METADATA +0 -329
  137. guidellm-0.3.1.dist-info/RECORD +0 -62
  138. {guidellm-0.3.1.dist-info → guidellm-0.6.0a5.dist-info}/WHEEL +0 -0
  139. {guidellm-0.3.1.dist-info → guidellm-0.6.0a5.dist-info}/entry_points.txt +0 -0
  140. {guidellm-0.3.1.dist-info → guidellm-0.6.0a5.dist-info}/licenses/LICENSE +0 -0
  141. {guidellm-0.3.1.dist-info → guidellm-0.6.0a5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,159 @@
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_number",
19
+ "safe_format_timestamp",
20
+ "safe_getattr",
21
+ "safe_multiply",
22
+ ]
23
+
24
+
25
+ def safe_getattr(obj: Any | None, attr: str, default: Any = None) -> Any:
26
+ """
27
+ Safely get an attribute from an object with None handling.
28
+
29
+ :param obj: Object to get the attribute from, or None
30
+ :param attr: Name of the attribute to retrieve
31
+ :param default: Value to return if object is None or attribute doesn't exist
32
+ :return: Attribute value or default if not found or object is None
33
+ """
34
+ if obj is None:
35
+ return default
36
+
37
+ return getattr(obj, attr, default)
38
+
39
+
40
+ def all_defined(*values: Any | None) -> bool:
41
+ """
42
+ Check if all provided values are defined (not None).
43
+
44
+ :param values: Variable number of values to check for None
45
+ :return: True if all values are not None, False otherwise
46
+ """
47
+ return all(value is not None for value in values)
48
+
49
+
50
+ def safe_divide(
51
+ numerator: int | float | None,
52
+ denominator: int | float | None,
53
+ num_default: float = 0.0,
54
+ den_default: float = 1.0,
55
+ ) -> float:
56
+ """
57
+ Safely divide two numbers with None handling and zero protection.
58
+
59
+ :param numerator: Number to divide, or None to use num_default
60
+ :param denominator: Number to divide by, or None to use den_default
61
+ :param num_default: Default value for numerator if None
62
+ :param den_default: Default value for denominator if None
63
+ :return: Division result with protection against division by zero
64
+ """
65
+ numerator = numerator if numerator is not None else num_default
66
+ denominator = denominator if denominator is not None else den_default
67
+
68
+ return numerator / (denominator or 1e-10)
69
+
70
+
71
+ def safe_multiply(*values: int | float | None, default: float = 1.0) -> float:
72
+ """
73
+ Safely multiply multiple numbers with None handling.
74
+
75
+ :param values: Variable number of values to multiply, None values treated as 1.0
76
+ :param default: Starting value for multiplication
77
+ :return: Product of all non-None values multiplied by default
78
+ """
79
+ result = default
80
+ for val in values:
81
+ result *= val if val is not None else 1.0
82
+ return result
83
+
84
+
85
+ def safe_add(
86
+ *values: int | float | None, signs: list[int] | None = None, default: float = 0.0
87
+ ) -> float:
88
+ """
89
+ Safely add multiple numbers with None handling and optional signs.
90
+
91
+ :param values: Variable number of values to add, None values use default
92
+ :param signs: Optional list of 1 (add) or -1 (subtract) for each value.
93
+ If None, all values are added. Must match length of values.
94
+ :param default: Value to substitute for None values
95
+ :return: Result of adding all values safely (default used when value is None)
96
+ """
97
+ if not values:
98
+ return default
99
+
100
+ values_list = list(values)
101
+
102
+ if signs is None:
103
+ signs = [1] * len(values_list)
104
+
105
+ if len(signs) != len(values_list):
106
+ raise ValueError("Length of signs must match length of values")
107
+
108
+ result = values_list[0] if values_list[0] is not None else default
109
+
110
+ for ind in range(1, len(values_list)):
111
+ value = values_list[ind]
112
+ checked_value = value if value is not None else default
113
+ result += signs[ind] * checked_value
114
+
115
+ return result
116
+
117
+
118
+ def safe_format_timestamp(
119
+ timestamp: float | int | None, format_: str = "%H:%M:%S", default: str = "N/A"
120
+ ) -> str:
121
+ """
122
+ Safely format a timestamp with error handling and validation.
123
+
124
+ :param timestamp: Unix timestamp to format, or None
125
+ :param format_: Strftime format string for timestamp formatting
126
+ :param default: Value to return if timestamp is invalid or None
127
+ :return: Formatted timestamp string or default value
128
+ """
129
+ if timestamp is None or timestamp < 0 or timestamp > 2**31:
130
+ return default
131
+
132
+ try:
133
+ return datetime.fromtimestamp(timestamp).strftime(format_)
134
+ except (ValueError, OverflowError, OSError):
135
+ return default
136
+
137
+
138
+ def safe_format_number(
139
+ number: int | float | None, precision: int = 1, default: str = "--"
140
+ ) -> str:
141
+ """
142
+ Safely format a number with specified precision and default handling.
143
+
144
+ :param number: Number to format, or None
145
+ :param precision: Number of decimal places for formatting floats
146
+ :param default: Value to return if number is None
147
+ :return: Formatted number string or default value
148
+ """
149
+ if number is None:
150
+ return default
151
+
152
+ if isinstance(number, int):
153
+ return str(number)
154
+
155
+ try:
156
+ format_str = f"{{:.{precision}f}}"
157
+ return format_str.format(number)
158
+ except (ValueError, TypeError):
159
+ return default
@@ -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: Union[str, Path]) -> None:
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, Optional, Union
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: Optional[Union[str, Path, PreTrainedTokenizerBase]],
13
- processor_args: Optional[dict[str, Any]],
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, (str, Path)):
20
+ if isinstance(processor, str | Path):
21
21
  loaded = AutoTokenizer.from_pretrained(
22
22
  processor,
23
23
  **(processor_args or {}),
@@ -0,0 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ try:
4
+ import orjson as json
5
+ except ImportError:
6
+ import json # type: ignore[no-redef] # Done only after a failure.
7
+
8
+
9
+ __all__ = ["json"]