cathyx commited on
Commit
ff4e38b
·
1 Parent(s): f3af40f

init files

Browse files
Files changed (4) hide show
  1. Dockerfile +19 -0
  2. README.md +5 -9
  3. app.py +104 -0
  4. requirements.txt +4 -0
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvcr.io/nvidia/pytorch:25.09-py3 AS base
2
+
3
+ COPY --chown=user ./requirements.txt requirements.txt
4
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
5
+
6
+ # 创建与 HF Spaces 运行时一致的 uid=1000 用户,避免 getpwuid() 错误
7
+ RUN groupadd -g 1000 user && \
8
+ useradd -m -u 1000 -g user user || true
9
+
10
+ # 复制代码至工作目录
11
+ WORKDIR $HOME/app
12
+ COPY --chown=user . $HOME/app
13
+
14
+ # HF Spaces 默认通过 $PORT 注入端口
15
+ ENV PORT=7860
16
+ EXPOSE 7860
17
+
18
+ # 启动 FastAPI 服务
19
+ CMD ["aiconfigurator", "webapp", "--server_name", "0.0.0.0", "--server_port", "7860"]
README.md CHANGED
@@ -1,14 +1,10 @@
1
  ---
2
- title: Aiconfigurator
3
- emoji: 🌍
4
- colorFrom: yellow
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 6.0.1
8
- app_file: app.py
9
  pinned: false
10
- license: apache-2.0
11
- short_description: Offline optimization of your disaggregated Dynamo graph
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Aic Test
3
+ emoji: 💻
4
+ colorFrom: pink
5
+ colorTo: indigo
6
+ sdk: docker
 
 
7
  pinned: false
 
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import gradio as gr
5
+ from aiconfigurator.webapp.components.static_tab import create_static_tab
6
+ from aiconfigurator.webapp.components.ifb_tab import create_ifb_tab
7
+ from aiconfigurator.webapp.components.ifb_pareto_tab import create_ifb_pareto_tab
8
+ from aiconfigurator.webapp.components.disagg_pareto_tab import create_disagg_pareto_tab
9
+ from aiconfigurator.webapp.components.pareto_comparison_tab import create_pareto_comparison_tab
10
+ from aiconfigurator.webapp.components.disagg_pd_ratio_tab import create_disagg_pd_ratio_tab
11
+ from aiconfigurator.webapp.components.readme_tab import create_readme_tab
12
+ from aiconfigurator.webapp.events.event_handler import EventHandler
13
+ from collections import defaultdict
14
+ import argparse
15
+ import logging
16
+ import aiconfigurator
17
+ import sys
18
+ from typing import List
19
+
20
+ def configure_parser(parser):
21
+ """
22
+ Configures the argument parser for the WebApp.
23
+ """
24
+ parser.add_argument("--server_name", type=str, default="0.0.0.0", help="Server name")
25
+ parser.add_argument("--server_port", type=int, default=7860, help="Server port")
26
+ parser.add_argument("--enable_ifb", action="store_true", help="Enable IFB tab")
27
+ parser.add_argument("--enable_disagg_pd_ratio", action="store_true", help="Enable Disagg PD Ratio tab")
28
+ parser.add_argument("--debug", help="Debug mode", action="store_true")
29
+ parser.add_argument("--experimental", help="enable experimental features", action="store_true")
30
+
31
+ def main(args):
32
+ """
33
+ Main function for the WebApp.
34
+ """
35
+ app_config = {
36
+ 'enable_ifb': args.enable_ifb,
37
+ 'enable_disagg_pd_ratio': args.enable_disagg_pd_ratio,
38
+ 'experimental': args.experimental,
39
+ 'debug': args.debug,
40
+ }
41
+
42
+ if app_config['debug']:
43
+ logging.basicConfig(level=logging.DEBUG,
44
+ format="%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s",
45
+ datefmt="%m-%d %H:%M:%S")
46
+ else:
47
+ logging.basicConfig(level=logging.INFO,
48
+ format="%(levelname)s %(asctime)s] %(message)s",
49
+ datefmt="%m-%d %H:%M:%S")
50
+
51
+ with gr.Blocks(css="""
52
+ .config-column {
53
+ border-right: 5px solid #e0e0e0;
54
+ padding-right: 20px;
55
+ }
56
+ .config-column:last-child {
57
+ border-right: none;
58
+ }
59
+ """) as demo:
60
+ pareto_results_state = gr.State(defaultdict())
61
+
62
+ # title
63
+ with gr.Row():
64
+ gr.Markdown(
65
+ f"""
66
+ <div style="text-align: center;">
67
+ <h1>Dynamo aiconfigurator for Disaggregated Serving Deployment</h1>
68
+ <p style="font-size: 14px; margin-top: -10px;">Version {aiconfigurator.__version__}</p>
69
+ </div>
70
+ """
71
+ )
72
+
73
+ # create tabs
74
+ with gr.Tabs() as tabs:
75
+ readme_components = create_readme_tab(app_config)
76
+ static_components = create_static_tab(app_config)
77
+ if app_config['enable_ifb']:
78
+ ifb_components = create_ifb_tab(app_config)
79
+ ifb_pareto_components = create_ifb_pareto_tab(app_config)
80
+ disagg_pareto_components = create_disagg_pareto_tab(app_config)
81
+ if app_config['enable_disagg_pd_ratio']:
82
+ disagg_pd_ratio_components = create_disagg_pd_ratio_tab(app_config)
83
+ pareto_comparison_components = create_pareto_comparison_tab(app_config)
84
+
85
+ # setup events
86
+ EventHandler.setup_static_events(static_components)
87
+ if app_config['enable_ifb']:
88
+ EventHandler.setup_ifb_events(ifb_components)
89
+ EventHandler.setup_ifb_pareto_events(ifb_pareto_components)
90
+ EventHandler.setup_disagg_pareto_events(disagg_pareto_components)
91
+ EventHandler.setup_save_events(ifb_pareto_components['result_name'], ifb_pareto_components['save_btn'], ifb_pareto_components['result_df'], pareto_comparison_components['candidates_dropdown'], pareto_results_state)
92
+ EventHandler.setup_save_events(disagg_pareto_components['result_name'], disagg_pareto_components['save_btn'], disagg_pareto_components['result_df'], pareto_comparison_components['candidates_dropdown'], pareto_results_state)
93
+ if app_config['enable_disagg_pd_ratio']:
94
+ EventHandler.setup_disagg_pd_ratio_events(disagg_pd_ratio_components)
95
+ EventHandler.setup_pareto_comparison_events(pareto_comparison_components, pareto_results_state)
96
+
97
+ demo.launch(server_name=args.server_name, server_port=args.server_port)
98
+
99
+
100
+ if __name__ == "__main__":
101
+ parser = argparse.ArgumentParser(description="Dynamo aiconfigurator Web App")
102
+ configure_parser(parser)
103
+ args = parser.parse_args()
104
+ main(args)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ fastapi
2
+ uvicorn[standard]
3
+ gradio
4
+ aiconfigurator==0.4.0