phate334 commited on
Commit
7c11711
1 Parent(s): 61b2179

[add] display result in tables.

Browse files
Files changed (6) hide show
  1. .gitignore +3 -0
  2. .vscode/settings.json +11 -0
  3. app.py +63 -6
  4. devices.json +15 -0
  5. pyproject.toml +4 -0
  6. uv.lock +2 -0
.gitignore CHANGED
@@ -160,3 +160,6 @@ cython_debug/
160
  # and can be added to the global gitignore or merged into this file. For a more nuclear
161
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
  #.idea/
 
 
 
 
160
  # and can be added to the global gitignore or merged into this file. For a more nuclear
161
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
  #.idea/
163
+
164
+ # Custom
165
+ gguf-parser-*
.vscode/settings.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "[python]": {
3
+ "editor.defaultFormatter": "ms-python.black-formatter",
4
+ "editor.formatOnSave": true,
5
+ "editor.codeActionsOnSave": {
6
+ "source.organizeImports": true
7
+ },
8
+ },
9
+ "isort.args":["--profile", "black"],
10
+
11
+ }
app.py CHANGED
@@ -1,21 +1,78 @@
 
1
  import os
2
  from pathlib import Path
3
 
4
  import gradio as gr
 
5
 
6
  GGUF_PARSER_VERSION = os.getenv("GGUF_PARSER_VERSION", "v0.12.0")
7
  gguf_parser = Path("gguf-parser-linux-amd64")
 
8
 
9
- def greet(tmp):
10
- # Run the gguf-parser-go binary
11
- gguf_parser_output = os.popen(f"./{gguf_parser} --version").read()
12
- return f"{gguf_parser_output}"
13
 
14
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  if __name__ == "__main__":
17
  if not gguf_parser.exists():
18
- gguf_parser_url = f"https://github.com/gpustack/gguf-parser-go/releases/download/{GGUF_PARSER_VERSION}/gguf-parser-linux-amd64"
19
  os.system(f"wget {gguf_parser_url}")
20
  os.system(f"chmod +x {gguf_parser}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  iface.launch()
 
1
+ import json
2
  import os
3
  from pathlib import Path
4
 
5
  import gradio as gr
6
+ import pandas as pd
7
 
8
  GGUF_PARSER_VERSION = os.getenv("GGUF_PARSER_VERSION", "v0.12.0")
9
  gguf_parser = Path("gguf-parser-linux-amd64")
10
+ gguf_parser_url = f"https://github.com/gpustack/gguf-parser-go/releases/download/{GGUF_PARSER_VERSION}/{gguf_parser}"
11
 
 
 
 
 
12
 
13
+ def process_url(url):
14
+ try:
15
+ res = os.popen(f"./{gguf_parser} -url {url} --json").read()
16
+ data = json.loads(res)
17
+
18
+ architecture_df = pd.DataFrame([data["architecture"]])
19
+
20
+ estimate_df = pd.DataFrame(
21
+ [
22
+ {
23
+ # "maximumTokensPerSecond": data["estimate"]["items"][0][
24
+ # "maximumTokensPerSecond"
25
+ # ],
26
+ "offloadLayers": data["estimate"]["items"][0]["offloadLayers"],
27
+ "fullOffloaded": data["estimate"]["items"][0]["fullOffloaded"],
28
+ "contextSize": data["estimate"]["contextSize"],
29
+ "flashAttention": data["estimate"]["flashAttention"],
30
+ "distributable": data["estimate"]["distributable"],
31
+ }
32
+ ]
33
+ )
34
+
35
+ metadata_df = pd.DataFrame([data["metadata"]])
36
+
37
+ tokenizer_df = pd.DataFrame([data["tokenizer"]])
38
+
39
+ return architecture_df, estimate_df, metadata_df, tokenizer_df
40
+ except Exception as e:
41
+ return e
42
+
43
 
44
  if __name__ == "__main__":
45
  if not gguf_parser.exists():
 
46
  os.system(f"wget {gguf_parser_url}")
47
  os.system(f"chmod +x {gguf_parser}")
48
+
49
+ with open("devices.json", "r", encoding="utf-8") as f:
50
+ device_list = json.load(f)
51
+
52
+ with gr.Blocks(title="GGUF 分析器") as iface:
53
+ url_input = gr.Textbox(label="輸入 GGUF URL")
54
+ submit_btn = gr.Button("送出")
55
+
56
+ gr.Markdown("### 模型架構")
57
+ architecture_table = gr.DataFrame()
58
+
59
+ gr.Markdown("### 效能評估")
60
+ estimate_table = gr.DataFrame()
61
+
62
+ gr.Markdown("### 中繼資料")
63
+ metadata_table = gr.DataFrame()
64
+
65
+ gr.Markdown("### 分詞器")
66
+ tokenizer_table = gr.DataFrame()
67
+
68
+ submit_btn.click(
69
+ fn=process_url,
70
+ inputs=url_input,
71
+ outputs=[
72
+ architecture_table,
73
+ estimate_table,
74
+ metadata_table,
75
+ tokenizer_table,
76
+ ],
77
+ )
78
  iface.launch()
devices.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {"model": "V100", "memory-size": 32, "memory-bandwidth": 900, "FLOPS": "112.224TFLOPS"},
3
+ {"model": "T4", "memory-size": 16, "memory-bandwidth": 320, "FLOPS": "64.8TFLOPS"},
4
+ {"model": "A2", "memory-size": 16, "memory-bandwidth": 200, "FLOPS": "18.124TFLOPS"},
5
+ {"model": "A10", "memory-size": 24, "memory-bandwidth": 600, "FLOPS": "124.96TFLOPS"},
6
+ {"model": "A16*4", "memory-size": 64, "memory-bandwidth": 800, "FLOPS": "73.728TFLOPS"},
7
+ {"model": "A30", "memory-size": 24, "memory-bandwidth": 933.1, "FLOPS": "165.12TFLOPS"},
8
+ {"model": "A40", "memory-size": 48, "memory-bandwidth": 695.8, "FLOPS": "149.68TFLOPS"},
9
+ {"model": "A100-40GB", "memory-size": 40, "memory-bandwidth": 1555, "FLOPS": "312.0TFLOPS"},
10
+ {"model": "A100-80GB", "memory-size": 80, "memory-bandwidth": 1555, "FLOPS": "312.0TFLOPS"},
11
+ {"model": "H100-PCIE", "memory-size": 80, "memory-bandwidth": 2039, "FLOPS": "756.449TFLOPS"},
12
+ {"model": "H100-SXM", "memory-size": 80, "memory-bandwidth": 3352, "FLOPS": "989.43TFLOPS"},
13
+ {"model": "L40", "memory-size": 48, "memory-bandwidth": 864, "FLOPS": "362.066TFLOPS"},
14
+ {"model": "L4", "memory-size": 24, "memory-bandwidth": 300, "FLOPS": "121.0TFLOPS"}
15
+ ]
pyproject.toml CHANGED
@@ -7,4 +7,8 @@ requires-python = ">=3.10"
7
  dependencies = [
8
  "gradio==5.3.0",
9
  "orjson==3.10.10",
 
10
  ]
 
 
 
 
7
  dependencies = [
8
  "gradio==5.3.0",
9
  "orjson==3.10.10",
10
+ "pandas>=2.2.3",
11
  ]
12
+
13
+ [tool.pylint]
14
+ max-line-length = 180
uv.lock CHANGED
@@ -196,12 +196,14 @@ source = { virtual = "." }
196
  dependencies = [
197
  { name = "gradio" },
198
  { name = "orjson" },
 
199
  ]
200
 
201
  [package.metadata]
202
  requires-dist = [
203
  { name = "gradio", specifier = "==5.3.0" },
204
  { name = "orjson", specifier = "==3.10.10" },
 
205
  ]
206
 
207
  [[package]]
 
196
  dependencies = [
197
  { name = "gradio" },
198
  { name = "orjson" },
199
+ { name = "pandas" },
200
  ]
201
 
202
  [package.metadata]
203
  requires-dist = [
204
  { name = "gradio", specifier = "==5.3.0" },
205
  { name = "orjson", specifier = "==3.10.10" },
206
+ { name = "pandas", specifier = ">=2.2.3" },
207
  ]
208
 
209
  [[package]]