From 605b95c193501ac727c0a60613775637835d04cc Mon Sep 17 00:00:00 2001
From: sunchao <1299792067@qq.com>
Date: Fri, 15 Aug 2025 14:25:47 +0800
Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0TensorBoard?=
=?UTF-8?q?=E7=9B=91=E6=8E=A7=E5=8F=AF=E8=A7=86=E5=8C=96=E6=8F=92=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tb_graph_ascend/monvis_plugin/LICENSE | 201 ++++++++++++
.../tb_graph_ascend/monvis_plugin/README.md | 112 +++++++
.../tb_graph_ascend/monvis_plugin/__init__.py | 15 +
.../tb_graph_ascend/monvis_plugin/fe/.babelrc | 3 +
.../monvis_plugin/fe/.prettierrc | 13 +
.../monvis_plugin/fe/package.json | 49 +++
.../monvis_plugin/fe/public/index.html | 10 +
.../fe/src/common/SelectWithLabel/index.less | 59 ++++
.../fe/src/common/SelectWithLabel/index.tsx | 37 +++
.../fe/src/common/constant/index.ts | 57 ++++
.../fe/src/common/type/index.d.ts | 40 +++
.../fe/src/controller/index.less | 34 ++
.../monvis_plugin/fe/src/controller/index.tsx | 216 +++++++++++++
.../fe/src/controller/type/index.d.ts | 39 +++
.../fe/src/controller/useController.ts | 59 ++++
.../fe/src/graph/components/HeatMap/index.tsx | 97 ++++++
.../graph/components/HeatMap/useHeatMap.ts | 297 ++++++++++++++++++
.../src/graph/components/LineChart/index.tsx | 140 +++++++++
.../fe/src/graph/components/type/index.d.ts | 32 ++
.../monvis_plugin/fe/src/graph/index.less | 41 +++
.../monvis_plugin/fe/src/graph/index.tsx | 50 +++
.../monvis_plugin/fe/src/index.tsx | 26 ++
.../monvis_plugin/fe/src/main/index.less | 26 ++
.../monvis_plugin/fe/src/main/index.tsx | 60 ++++
.../monvis_plugin/fe/src/main/type/index.d.ts | 26 ++
.../monvis_plugin/fe/src/store/index.ts | 39 +++
.../monvis_plugin/fe/src/utils/index.ts | 27 ++
.../monvis_plugin/fe/src/utils/request.ts | 91 ++++++
.../monvis_plugin/fe/tsconfig.json | 40 +++
.../monvis_plugin/fe/webpack.config.js | 81 +++++
.../monvis_plugin/fe/webpack.dev.js | 160 ++++++++++
.../monvis_plugin/server/__init__.py | 15 +
.../monvis_plugin/server/app.py | 57 ++++
.../server/controllers/__init__.py | 15 +
.../server/controllers/monvis_controller.py | 103 ++++++
.../monvis_plugin/server/database/__init__.py | 15 +
.../server/database/db_connection.py | 40 +++
.../server/repositories/__init__.py | 15 +
.../server/repositories/monvis_repo.py | 116 +++++++
.../monvis_plugin/server/services/__init__.py | 15 +
.../server/services/monvis_service.py | 196 ++++++++++++
.../monvis_plugin/server/static/__init__.py | 15 +
.../monvis_plugin/server/static/index.js | 19 ++
43 files changed, 2798 insertions(+)
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/LICENSE
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/README.md
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/__init__.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.babelrc
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.prettierrc
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/package.json
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/public/index.html
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.less
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.tsx
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/constant/index.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/type/index.d.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.less
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.tsx
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/type/index.d.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/useController.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/graph/components/HeatMap/index.tsx
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/graph/components/HeatMap/useHeatMap.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/graph/components/LineChart/index.tsx
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/graph/components/type/index.d.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/graph/index.less
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/graph/index.tsx
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/index.tsx
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/main/index.less
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/main/index.tsx
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/main/type/index.d.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/store/index.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/utils/index.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/utils/request.ts
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/tsconfig.json
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/webpack.config.js
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/webpack.dev.js
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/__init__.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/app.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/controllers/__init__.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/controllers/monvis_controller.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/database/__init__.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/database/db_connection.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/repositories/__init__.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/repositories/monvis_repo.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/services/__init__.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/services/monvis_service.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/static/__init__.py
create mode 100644 plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/server/static/index.js
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/LICENSE b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/LICENSE
new file mode 100644
index 000000000..261eeb9e9
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/README.md b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/README.md
new file mode 100644
index 000000000..9e3e96938
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/README.md
@@ -0,0 +1,112 @@
+# TensorBoard 监控可视化插件
+一个用于可视化模型监控指标的TensorBoard插件,支持热力图和趋势图分析。项目文件中提供将CSV格式的监控数据导入SQLite数据库的脚本,然后使用可插件生成交互式可视化界面。
+
+## 核心功能
+- **数据导入DB**:将monitor工具CSV文件转换为SQLite格式
+- **交互式热力图**:支持跨维度(训练步数、rank、模块/参数)指标统计量可视化
+- **趋势分析**:查看选定维度的指标变化趋势
+
+## 使用流程
+```mermaid
+
+graph LR
+ F[安装插件包] --> A
+
+ subgraph 数据准备
+ A[monitor输出数据] -->|CSV格式| B(数据转换脚本)
+ B -->|SQLite格式| C[数据库文件]
+ end
+
+ subgraph 可视化
+ C --> D[TensorBoard]
+ D --> E[MonVis插件]
+ end
+```
+
+## 安装指南
+
+1. 克隆项目仓库
+git clone https://gitee.com/jiandaobao/MoniVis.git
+
+2. 安装插件包:
+```bash
+cd MoniVis
+pip install -e .
+```
+
+3. 插件安装后会被TensorBoard自动识别
+
+## 数据准备
+
+### 监控数据路径目录结构要求
+```bash
+monitor_output/
+├── date-rank0
+│ ├── grad_reduced_0-100.csv
+│ └── param_0-100.csv
+└── date-rank1
+ ├── grad_reduced_0-100.csv
+ └── param_0-100.csv
+```
+
+### 数据转换脚本
+```bash
+python3 csv2sqlite.py --db ./db --data ./monitor_output --workers 4
+```
+
+### 命令行参数
+
+| 参数名称 | 必选 | 数据类型 | 默认值 | 描述 |
+| ------------- | ---- | -------- | ------ | ---------------------------------------------- |
+| `--db` | 是 | string | 无 | SQLite数据库文件存储目录 |
+| `--data` | 是 | string | 无 | 监控数据目录路径 |
+| `--workers` | 否 | int | 1 | 并行处理的工作线程数 |
+| `--partition` | 否 | int | 50 | Step分区大小(控制每个SQLite表存储的step范围) |
+
+#### 输入数据要求
+| 文件命名格式 | 示例 | 说明 |
+| ---------------------------- | ---------------------------- | ------------------- |
+| `[metric]_[start]-[end].csv` | `grad_reduced_1000-1004.csv` | 必须包含step范围 |
+| 文件内容字段 | | |
+| `vpp_stage` | 0,1,2... | 模块层级标识 |
+| `name` | "encoder.layer1" | 模块名称 |
+| `micro_step` | 0 | 微步长(可选,默认0) |
+| `step` | 1000 | 训练步数 |
+| `[stat]` | norm,mean等 | 统计量字段 |
+
+## TensorBoard使用
+1. 启动服务:
+```bash
+tensorboard --logdir=./db --port=6008
+```
+
+访问路径:
+
+浏览器打开 http://localhost:6008
+
+选择顶部导航栏的 MonVis 标签页
+
+
+
+## 数据库结构
+| 表名 | 说明 |
+| -------------------- | -------------------- |
+| `monitoring_targets` | 被监控模块/层信息 |
+| `monitoring_metrics` | 可用指标列表 |
+| `metric_stats` | 指标的统计量类型 |
+| `global_stats` | 全局步数/rank范围 |
+| `metric_*_step_*` | 分片存储的指标数据表 |
+
+
+## 项目文件
+```bash
+tb_monitor_plugin/
+├── frontend/ # 前端资源
+│ ├── index.js # 可视化主逻辑
+│ └── echarts.js # ECharts库定制版
+├── backend.py # 插件后端核心
+to_SQlite
+├── csv2sqlite.py # 数据转换器
+setup.py # 安装配置
+monitor_metrics.db # 自动生成的数据库名
+```
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/__init__.py b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/__init__.py
new file mode 100644
index 000000000..ee2432f47
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/__init__.py
@@ -0,0 +1,15 @@
+# Copyright (c) 2025, Huawei Technologies.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==============================================================================
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.babelrc b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.babelrc
new file mode 100644
index 000000000..18151f1f8
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.babelrc
@@ -0,0 +1,3 @@
+{
+ "presets": ["@babel/preset-env", "@babel/preset-react"]
+}
\ No newline at end of file
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.prettierrc b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.prettierrc
new file mode 100644
index 000000000..e3d2acb00
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/.prettierrc
@@ -0,0 +1,13 @@
+{
+ "parser": "typescript",
+ "semi": true,
+ "singleQuote": true,
+ "jsxSingleQuote": false,
+ "bracketSpacing": true,
+ "tabWidth": 2,
+ "useTabs": false,
+ "trailingComma": "all",
+ "proseWrap": "always",
+ "endOfLine": "lf",
+ "printWidth": 120
+}
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/package.json b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/package.json
new file mode 100644
index 000000000..bcd958160
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "fe",
+ "version": "1.0.0",
+ "main": "webpack.config.js",
+ "scripts": {
+ "dev": "webpack serve --config webpack.dev.js",
+ "buildWin": "cross-env NODE_ENV=production webpack && copy dist\\index.html ..\\server\\static\\",
+ "prettier": "prettier --config ./.prettierrc --write ./src/**/*.ts"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "ISC",
+ "description": "",
+ "devDependencies": {
+ "@babel/core": "^7.27.3",
+ "@babel/preset-env": "^7.27.2",
+ "@babel/preset-react": "^7.27.1",
+ "babel-loader": "^10.0.0",
+ "clean-webpack-plugin": "^4.0.0",
+ "cross-env": "^7.0.3",
+ "css-loader": "^7.1.2",
+ "file-loader": "^6.2.0",
+ "html-loader": "^5.1.0",
+ "html-webpack-plugin": "^5.6.3",
+ "inline-chunk-html-plugin": "^1.1.1",
+ "less": "^4.3.0",
+ "less-loader": "^12.3.0",
+ "mini-css-extract-plugin": "^2.9.2",
+ "prettier": "^3.5.3",
+ "style-loader": "^4.0.0",
+ "ts-loader": "^9.5.2",
+ "typescript": "^5.8.3",
+ "webpack": "^5.96.1",
+ "webpack-cli": "^5.1.4",
+ "webpack-dev-server": "4.15.1"
+ },
+ "dependencies": {
+ "ahooks": "^3.8.5",
+ "antd": "^5.25.3",
+ "axios": "^1.9.0",
+ "echarts": "^5.6.0",
+ "echarts-for-react": "^3.0.2",
+ "lodash": "^4.17.21",
+ "react": "^18.0.0",
+ "react-dom": "^18.0.0",
+ "use-sync-external-store": "^1.5.0",
+ "zustand": "^5.0.5"
+ }
+}
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/public/index.html b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/public/index.html
new file mode 100644
index 000000000..a0c678cdf
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/public/index.html
@@ -0,0 +1,10 @@
+
+
+
+
+ Graph
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.less b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.less
new file mode 100644
index 000000000..a016ed61b
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.less
@@ -0,0 +1,59 @@
+/* -------------------------------------------------------------------------
+ Copyright (c) 2025, Huawei Technologies.
+ All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--------------------------------------------------------------------------------------------*/
+
+.selector {
+ padding: 6px 2px;
+ background-color: white;
+ box-sizing: border-box;
+ color: rgb(0, 0, 0);
+ font-size: 14px;
+ line-height: 1.5;
+ margin-bottom: 8px;
+
+ .label {
+ width: 36%;
+ cursor: pointer;
+ margin-bottom: 8px;
+ color: rgb(68, 68, 68);
+ font-weight: 400;
+
+ .question-icon {
+ margin-left: 6px;
+ font-size: medium;
+ background-color: white;
+ cursor: pointer;
+ }
+
+ &:hover {
+ color: #0660e7;
+ }
+ }
+
+ .select {
+ width: 100%;
+
+ .ant-select-selector {
+ border-radius: 0px;
+ border: 1px solid #161616;
+
+ }
+
+ .ant-select-selection-item {
+ font-weight: 500;
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.tsx b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.tsx
new file mode 100644
index 000000000..7b9a788af
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/SelectWithLabel/index.tsx
@@ -0,0 +1,37 @@
+/* -------------------------------------------------------------------------
+ Copyright (c) 2025, Huawei Technologies.
+ All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--------------------------------------------------------------------------------------------*/
+
+import React from 'react';
+import { Select, Tooltip } from 'antd';
+import { QuestionCircleOutlined } from '@ant-design/icons';
+import './index.less';
+const SelectWithLabel = ({ label, className, text, ...args }: any) => {
+ return (
+
+
+
+ {label}
+
+
+
+
+
+
+ );
+};
+
+export default SelectWithLabel;
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/constant/index.ts b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/constant/index.ts
new file mode 100644
index 000000000..52cc0d4cc
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/constant/index.ts
@@ -0,0 +1,57 @@
+/* -------------------------------------------------------------------------
+ Copyright (c) 2025, Huawei Technologies.
+ All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--------------------------------------------------------------------------------------------*/
+
+import { createContext } from 'react';
+import { GlobalContextType } from '../type';
+
+export const STEP_DIMENSION = 'step';
+export const RANK_DIMENSION = 'rank';
+export const MODULE_NAME_DIMENSION = 'module_name';
+
+export const CONTINUOUS = 'continuous';
+export const PIECEWISE = 'piecewise';
+
+export const DIMENSIONS_OPTIONS = [
+ { value: STEP_DIMENSION, label: 'Step' },
+ { value: RANK_DIMENSION, label: 'Rank' },
+ { value: MODULE_NAME_DIMENSION, label: 'Module Name' },
+];
+
+export const HEATMAP_TYPE = [
+ { value: CONTINUOUS, label: '渐变模式' },
+ { value: PIECEWISE, label: '分段模式' },
+];
+
+export const DIMENSIONS_AXIS_MAP = {
+ [STEP_DIMENSION]: {
+ x: 'Rank',
+ y: 'Module Name',
+ },
+ [RANK_DIMENSION]: {
+ x: 'Step',
+ y: 'Module Name',
+ },
+ [MODULE_NAME_DIMENSION]: {
+ x: 'Step',
+ y: 'Rank',
+ },
+};
+
+export const GlobalContext = createContext({
+ contextState: [],
+ setContextState: () => { },
+});
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/type/index.d.ts b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/type/index.d.ts
new file mode 100644
index 000000000..c50cce52d
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/common/type/index.d.ts
@@ -0,0 +1,40 @@
+/* -------------------------------------------------------------------------
+ Copyright (c) 2025, Huawei Technologies.
+ All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--------------------------------------------------------------------------------------------*/
+
+import type { TrendResponseData } from '../../graph/components/type';
+export interface ContextStateType {
+ heatMaphData?: Array;
+ trendData?: TrendResponseData['data'];
+ metric?: string;
+ stat?: string;
+ dimension?: string;
+ dimensionValue?: string;
+ heatMapType?: string;
+ dimX?: string;
+ dimY?: string;
+ loadingHeatMap?: boolean;
+ loadingLineChart?: boolean;
+ setContextState: (newState: Partial) => void;
+}
+export type GlobalContextType = {
+ contextState: ContextStateType;
+ setContextState: (contextState: ContextStateType) => void;
+};
+export type SelectOptionType = {
+ label: string;
+ value: string;
+};
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.less b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.less
new file mode 100644
index 000000000..2d10e24d0
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.less
@@ -0,0 +1,34 @@
+/* -------------------------------------------------------------------------
+ Copyright (c) 2025, Huawei Technologies.
+ All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--------------------------------------------------------------------------------------------*/
+
+.warpper {
+ background-color: #eeeeee;
+ height: 100%;
+}
+
+.controller {
+ padding: 16px 12px;
+ background-color: white;
+}
+
+.title {
+ font-size: 16px;
+ font-weight: 500;
+ text-align: center;
+ padding-block: 6px;
+ background-color: #f1f1f1;
+}
\ No newline at end of file
diff --git a/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.tsx b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.tsx
new file mode 100644
index 000000000..ee2a7a787
--- /dev/null
+++ b/plugins/tensorboard-plugins/tb_graph_ascend/monvis_plugin/fe/src/controller/index.tsx
@@ -0,0 +1,216 @@
+/* -------------------------------------------------------------------------
+ Copyright (c) 2025, Huawei Technologies.
+ All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--------------------------------------------------------------------------------------------*/
+
+import React, { useEffect, useState, memo } from 'react';
+import { shallow, useShallow } from 'zustand/shallow';
+import { message } from 'antd';
+import { isEmpty } from 'lodash';
+import './index.less';
+import { useGlobalStore } from '../store';
+import { DIMENSIONS_OPTIONS, HEATMAP_TYPE } from '../common/constant';
+import SelectWithLabel from '../common/SelectWithLabel';
+import useController from './useController';
+import type { SelectOptionType } from '../common/type';
+import type { ControllerProps, ValuesResponseType, ValuesRequestParamsType } from './type';
+
+const Controller: React.FC = (props: ControllerProps) => {
+ const { metrics } = props;
+ const useControllerInstance = useController();
+ const { metric, stat, dimension, dimensionValue, heatMapType, setContextState } = useGlobalStore(
+ useShallow((state) => ({
+ metric: state.metric,
+ stat: state.stat,
+ dimension: state.dimension,
+ dimensionValue: state.dimensionValue,
+ heatMapType: state.heatMapType,
+ setContextState: state.setContextState,
+ })),
+ shallow,
+ );
+ const [metricsMapStats, setMetricsMapStats] = useState>>({});
+ const [metricsNameList, setMetricsNameList] = useState([]);
+ const [statNameList, setStatNameList] = useState([]);
+ const [dimensionValueList, setDimensionValueList] = useState();
+
+ useEffect(() => {
+ if (metrics) {
+ const metricsMapStats: Record> = {};
+ const metricsNameList: Array = [];
+ metrics.forEach(({ name, stats }) => {
+ metricsMapStats[name] = stats.map((stat) => {
+ return {
+ label: stat,
+ value: stat,
+ };
+ });
+ metricsNameList.push({ label: name, value: name });
+ });
+
+ const selecrMetric = metricsNameList?.[0]?.value;
+ const statNameList: Array = metricsMapStats[selecrMetric];
+ const selectedStat = statNameList?.[0]?.value;
+ setMetricsMapStats(metricsMapStats);
+ // 初始化指标
+ setMetricsNameList(metricsNameList);
+ // 初始化统计量
+ setStatNameList(statNameList);
+ setContextState({ metric: selecrMetric, stat: selectedStat });
+ // 初始化维度,默认选中step维度
+ const params: ValuesRequestParamsType = {
+ metric: selecrMetric,
+ stat: selectedStat,
+ dimension: DIMENSIONS_OPTIONS[0].value,
+ value: 0,
+ };
+ updateDimensionValueList(params);
+ }
+ }, [metrics]);
+
+ useEffect(() => {
+ if (!metric || !stat || !dimension || !dimensionValue) {
+ return;
+ }
+ const params = {
+ metric,
+ stat,
+ dimension,
+ value: dimensionValue,
+ };
+ const loadGraphData = async (params) => {
+ setContextState({ loadingHeatMap: true });
+ const result = await useControllerInstance.loadGraphData(params);
+ setContextState({ loadingHeatMap: false });
+ if (result.error) {
+ message.error(result?.error);
+ return;
+ }
+ setContextState({
+ heatMaphData: result?.data,
+ trendData: { dimensions: [], values: [] },
+ dimX: ' ',
+ dimY: ' ',
+ });
+ };
+ loadGraphData(params);
+ }, [metric, stat, dimension, dimensionValue]);
+
+ const updateDimensionValueList = async (params: ValuesRequestParamsType) => {
+ const result: ValuesResponseType = await useControllerInstance.loadDimensionValueList(params);
+ if (result.error) {
+ message.error(result.error);
+ return;
+ }
+ if (!isEmpty(result)) {
+ const dimensionValueList = Object.entries(result?.data || {}).map(([key, value]) => {
+ return {
+ value: key,
+ label: value,
+ };
+ });
+ setContextState({
+ dimension: params.dimension,
+ dimensionValue: dimensionValueList?.[0]?.value,
+ });
+ setDimensionValueList(dimensionValueList);
+ }
+ };
+
+ // 指标选择
+ const onSelectMetricChange = (value: string) => {
+ const statNameList = metricsMapStats[value];
+ const selectedStat = statNameList?.[0]?.value;
+ setContextState({ metric: value, stat: selectedStat });
+ setStatNameList(statNameList);
+ };
+
+ // 统计量选择
+ const onSelectStatChange = (value: string) => {
+ setContextState({ stat: value });
+ };
+
+ // 维度选择
+ const onSelectDimensionChange = (value: string) => {
+ const params: ValuesRequestParamsType = {
+ metric,
+ stat,
+ dimension: value,
+ value: 0,
+ } as ValuesRequestParamsType;
+ updateDimensionValueList(params);
+ };
+ // 维度值选择
+ const onSelectDimensionValueChange = (value: string) => {
+ setContextState({ dimensionValue: value });
+ };
+
+ return (
+