(
ctx: typer.Context, # Typer Context to grab config for --verbose and passing to WandB
hidden_sizes: Annotated[List[int], Option(help="List of hidden sizes", show_default=False)],
num_hidden_layers: Annotated[List[int], Option(help="List of number of hidden layers", show_default=False)],
intermediate_sizes: Annotated[List[int], Option(help="List of intermediate sizes", show_default=False)],
parallel_attn: Annotated[List[bool], Option(is_flag=False, help="List of parallel attention flags", show_default=False)],
sliding_window: Annotated[List[int], Option(help="Sliding window size. -1 to disable.")] = [-1],
global_attn_every_n_layers: Annotated[List[int], Option(help="Use global attention every `n` layers and sliding window for the rest. -1 to disable.")] = [-1],
normalization: Annotated[List[str], Option(help="Normalization type: layernorm or triton_layernorm")] = ["layernorm"],
compile_model: Annotated[List[bool], Option(help="Compile model")] = [True],
masked_prediction: Annotated[List[bool], Option(help="Only pass the masked tokens through the final MLM layers")] = [True],
model_type: Annotated[List[ModelType], Option(help="Model type: MLM or Multiple Choice")] = [ModelType.mlm],
vocab_size: Annotated[List[int], Option(help="Vocabulary size")] = [32768],
num_samples: Annotated[int, Option(help="Number of samples")] = 1000,
seq_length: Annotated[int, Option(help="Sequence length")] = 512,
batch_size: Annotated[Optional[int], Option(help="Batch size (if not provided, will be set based on model size)")] = None,
output_file: Annotated[str, Option(help="Output file name for results")] = "benchmark_results.md",
sleep_time: Annotated[int, Option(help="Time to sleep between each model run")] = 25,
print_model: Annotated[bool, Option(help="Print model")] = False,
num_workers: Annotated[int, Option(help="Number of workers")] = 8,
skip_inference: Annotated[bool, Option(help="Skip inference")] = False,
gpu_idx: Annotated[int, Option(help="GPU index for power measurements")] = 0,
config: Annotated[
Optional[Path],
Option(
callback=conf_callback,
is_eager=True,
help="Relative path to YAML config file for setting options. Passing CLI options will supersede config options.",
case_sensitive=False,
),
] = None,
)
| 259 | # fmt: off |
| 260 | @app.command() |
| 261 | def main( |
| 262 | ctx: typer.Context, # Typer Context to grab config for --verbose and passing to WandB |
| 263 | hidden_sizes: Annotated[List[int], Option(help="List of hidden sizes", show_default=False)], |
| 264 | num_hidden_layers: Annotated[List[int], Option(help="List of number of hidden layers", show_default=False)], |
| 265 | intermediate_sizes: Annotated[List[int], Option(help="List of intermediate sizes", show_default=False)], |
| 266 | parallel_attn: Annotated[List[bool], Option(is_flag=False, help="List of parallel attention flags", show_default=False)], |
| 267 | sliding_window: Annotated[List[int], Option(help="Sliding window size. -1 to disable.")] = [-1], |
| 268 | global_attn_every_n_layers: Annotated[List[int], Option(help="Use global attention every `n` layers and sliding window for the rest. -1 to disable.")] = [-1], |
| 269 | normalization: Annotated[List[str], Option(help="Normalization type: layernorm or triton_layernorm")] = ["layernorm"], |
| 270 | compile_model: Annotated[List[bool], Option(help="Compile model")] = [True], |
| 271 | masked_prediction: Annotated[List[bool], Option(help="Only pass the masked tokens through the final MLM layers")] = [True], |
| 272 | model_type: Annotated[List[ModelType], Option(help="Model type: MLM or Multiple Choice")] = [ModelType.mlm], |
| 273 | vocab_size: Annotated[List[int], Option(help="Vocabulary size")] = [32768], |
| 274 | num_samples: Annotated[int, Option(help="Number of samples")] = 1000, |
| 275 | seq_length: Annotated[int, Option(help="Sequence length")] = 512, |
| 276 | batch_size: Annotated[Optional[int], Option(help="Batch size (if not provided, will be set based on model size)")] = None, |
| 277 | output_file: Annotated[str, Option(help="Output file name for results")] = "benchmark_results.md", |
| 278 | sleep_time: Annotated[int, Option(help="Time to sleep between each model run")] = 25, |
| 279 | print_model: Annotated[bool, Option(help="Print model")] = False, |
| 280 | num_workers: Annotated[int, Option(help="Number of workers")] = 8, |
| 281 | skip_inference: Annotated[bool, Option(help="Skip inference")] = False, |
| 282 | gpu_idx: Annotated[int, Option(help="GPU index for power measurements")] = 0, |
| 283 | config: Annotated[ |
| 284 | Optional[Path], |
| 285 | Option( |
| 286 | callback=conf_callback, |
| 287 | is_eager=True, |
| 288 | help="Relative path to YAML config file for setting options. Passing CLI options will supersede config options.", |
| 289 | case_sensitive=False, |
| 290 | ), |
| 291 | ] = None, |
| 292 | ): |
| 293 | # fmt: on |
| 294 | pynvml.nvmlInit() |
| 295 | device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
| 296 | |
| 297 | # Determine the maximum length of the lists |
| 298 | max_length = max( |
| 299 | len(hidden_sizes), |
| 300 | len(num_hidden_layers), |
| 301 | len(intermediate_sizes), |
| 302 | len(parallel_attn), |
| 303 | len(vocab_size), |
| 304 | len(model_type), |
| 305 | len(sliding_window), |
| 306 | len(global_attn_every_n_layers), |
| 307 | len(normalization), |
| 308 | len(compile_model), |
| 309 | len(masked_prediction), |
| 310 | ) |
| 311 | |
| 312 | # Tile lists to match the maximum length |
| 313 | hidden_sizes = tile_list_to_length(hidden_sizes, max_length) |
| 314 | num_hidden_layers = tile_list_to_length(num_hidden_layers, max_length) |
| 315 | intermediate_sizes = tile_list_to_length(intermediate_sizes, max_length) |
| 316 | parallel_attn = tile_list_to_length(parallel_attn, max_length) |
| 317 | vocab_size = tile_list_to_length(vocab_size, max_length) |
| 318 | model_type = tile_list_to_length(model_type, max_length) |
nothing calls this directly
no test coverage detected