File size: 3,726 Bytes
4d423a9
 
 
 
 
 
f43498c
4d423a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f43498c
4d423a9
 
 
10c3b6b
 
049539c
10c3b6b
 
 
 
 
efb091c
 
 
 
0bb64a4
efb091c
10c3b6b
4d423a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449a109
 
 
 
 
4d423a9
 
 
 
 
449a109
 
 
 
 
f6dcb7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d423a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import gradio as gr


def get_process_config():
    return {
        "process.numactl": gr.Checkbox(
            value=True,
            label="process.numactl",
            info="Runs the model with numactl",
        ),
        "process.numactl_kwargs": gr.Textbox(
            label="process.numactl_kwargs",
            value="{'cpunodebind': 0, 'membind': 0}",
            info="Additional python dict of kwargs to pass to numactl",
        ),
    }


def get_inference_config():
    return {
        "inference.warmup_runs": gr.Slider(
            step=1,
            value=10,
            minimum=0,
            maximum=10,
            label="inference.warmup_runs",
            info="Number of warmup runs",
        ),
        "inference.duration": gr.Slider(
            step=1,
            value=10,
            minimum=0,
            maximum=10,
            label="inference.duration",
            info="Minimum duration of the benchmark in seconds",
        ),
        "inference.iterations": gr.Slider(
            step=1,
            value=10,
            minimum=0,
            maximum=10,
            label="inference.iterations",
            info="Minimum number of iterations of the benchmark",
        ),
        "inference.latency": gr.Checkbox(
            value=True,
            label="inference.latency",
            info="Measures the latency of the model",
        ),
        "inference.memory": gr.Checkbox(
            value=True,
            label="inference.memory",
            info="Measures the peak memory consumption",
        ),
        "inference.input_shapes": gr.Textbox(
            label="inference.input_shapes",
            value="{'batch_size': 2, 'sequence_length': 16}",
            info="Input shapes to use for the benchmark",
        ),
        "inference.generate_kwargs": gr.Textbox(
            label="inference.generate_kwargs",
            value="{'max_new_tokens': 32, 'min_new_tokens': 32}",
            info="Additional python dict of kwargs to pass to the generate method",
        ),
        "inference.call_kwargs": gr.Textbox(
            label="inference.call_kwargs",
            value="{'num_inference_steps': 5}",
            info="Additional python dict of kwargs to pass to the __call__ method",
        ),
    }


def get_pytorch_config():
    return {
        "pytorch.torch_dtype": gr.Dropdown(
            value="float32",
            label="pytorch.torch_dtype",
            choices=["bfloat16", "float16", "float32", "auto"],
            info="The dtype to use for the model",
        ),
    }


def get_openvino_config():
    return {
        "openvino.half": gr.Checkbox(
            value=False,
            label="openvino.half",
            info="Converts model to half precision",
        ),
        "openvino.reshape": gr.Checkbox(
            value=False,
            label="openvino.reshape",
            info="Reshapes the model to the input shape",
        ),
        "openvino.reshape_kwargs": gr.Textbox(
            label="openvino.reshape_kwargs",
            value="{'batch_size': 2, 'sequence_length': 16}",
            info="Additional python dict of kwargs to pass to the reshape function",
        ),
        "openvino.compile": gr.Checkbox(
            value=False,
            label="openvino.compile",
            info="Compiles model for the current device",
        ),
        "openvino.load_in_8bit": gr.Checkbox(
            value=False,
            label="openvino.load_in_8bit",
            info="Loads model in 8 bits precision",
        ),
        "openvino.load_in_4bit": gr.Checkbox(
            value=False,
            label="openvino.load_in_4bit",
            info="Loads model in 4 bits precision",
        ),
    }