guidellm.data.deserializers.trace_common
Trace file deserializer that generates synthetic prompts per row.
Reads a trace file (consisting of at least the columns timestamp, input_length, output_length) and yields one row per line with a synthetic prompt matching the requested input_length for replay benchmarks.
TraceDataArgs
Bases: DataArgs
Abstract class meant to be inherited by a trace format. For testing, use trace_minimal.MinimalTraceFormatArgs instead.
Source code in src/guidellm/data/deserializers/trace_common.py
TraceDataset
Bases: IterableDataset
Source code in src/guidellm/data/deserializers/trace_common.py
set_epoch(epoch)
TraceDatasetDeserializer
Bases: DatasetDeserializer
Dataset deserializer for all trace formats.
Source code in src/guidellm/data/deserializers/trace_common.py
TraceExamplesIterable
Bases: _BaseExamplesIterable
Custom examples iterable for synthetic prompt generation. Used to avoid pre-generating a prompt for every row in the dataset on load.
Source code in src/guidellm/data/deserializers/trace_common.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
load_state_dict(state_dict)
shard_data_sources(num_shards, index, contiguous=True)
Returns self as sharding is not implemented yet.
Source code in src/guidellm/data/deserializers/trace_common.py
shuffle_data_sources(generator)
Returns self as sharding is not implemented yet.
TraceFormatBase
Bases: Protocol
Source code in src/guidellm/data/deserializers/trace_common.py
create_prompt(config, row, processor, faker)
Called within trace_common.TraceExamplesIterable on each iteration. Returns a generated synthetic prompt.
Source code in src/guidellm/data/deserializers/trace_common.py
validate_row(config, row)
Called within trace_common.TraceExamplesIterable on initialization, immediately after doing its own checks on the row.
decode_prompt(processor, token_ids)
Decode token ids into a prompt string.
Source code in src/guidellm/data/deserializers/trace_common.py
generate_token_ids(token_count, processor, faker, margin_of_safety=8)
Generate token_count synthetic token ids for trace prompt construction.
Ideally, margin_of_safety should be set to slighty more than the average number of characters used by tokenizers to form one token.
Source code in src/guidellm/data/deserializers/trace_common.py
load_trace_rows(path, timestamp_column_name, required_columns, **data_kwargs)
Load trace file rows as a HuggingFace Dataset.
Every column in required_columns must exist in the dataset; otherwise KeyError is raised with a descriptive message. Rows are sorted by column timestamp_column_name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | Path | str | Path to the trace file. | required |
timestamp_column_name | str | Name of the timestamp column used to sort trace rows. | required |
required_columns | Features | List of column/fields that each row must have. Must contain the timestamp column. | required |
data_kwargs | Any | Additional keyword arguments forwarded to load_dataset. | {} |
Returns:
| Type | Description |
|---|---|
Dataset | HuggingFace Dataset (iterable as dicts, column-accessible). |
Raises:
| Type | Description |
|---|---|
DataNotSupportedError | For any of the following reasons: - The dataset is empty or has no valid rows - A required column contains a NoneType - A required column failed during cast to feature type |
KeyError | If a required column is missing in the dataset. |
ValueError | If the file format is not .jsonl, .json, .csv or .parquet. |