Elffuss BraidHub

kikocis/llama-stack public

7e11e7246f77 · 1.9 KiBRawPermalink
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the terms described in the LICENSE file in
5# the root directory of this source tree.
6
7import argparse
8
9from llama_models.sku_list import all_registered_models
10
11from llama_toolchain.cli.subcommand import Subcommand
12from llama_toolchain.cli.table import print_table
13
14
15class ModelList(Subcommand):
16 """List available llama models"""
17
18 def __init__(self, subparsers: argparse._SubParsersAction):
19 super().__init__()
20 self.parser = subparsers.add_parser(
21 "list",
22 prog="llama model list",
23 description="Show available llama models",
24 formatter_class=argparse.RawTextHelpFormatter,
25 )
26 self._add_arguments()
27 self.parser.set_defaults(func=self._run_model_list_cmd)
28
29 def _add_arguments(self):
30 self.parser.add_argument(
31 "--show-all",
32 action="store_true",
33 help="Show all models (not just defaults)",
34 )
35
36 def _run_model_list_cmd(self, args: argparse.Namespace) -> None:
37 headers = [
38 "Model Descriptor",
39 "HuggingFace Repo",
40 "Context Length",
41 "Hardware Requirements",
42 ]
43
44 rows = []
45 for model in all_registered_models():
46 if not args.show_all and not model.is_featured:
47 continue
48
49 req = model.hardware_requirements
50
51 descriptor = model.descriptor()
52 rows.append(
53 [
54 descriptor,
55 model.huggingface_repo,
56 f"{model.max_seq_length // 1024}K",
57 f"{req.gpu_count} GPU{'s' if req.gpu_count > 1 else ''}, each >= {req.memory_gb_per_gpu}GB VRAM",
58 ]
59 )
60 print_table(
61 rows,
62 headers,
63 separate_rows=True,
64 )