
Huawei Cloud Ascend Profiler Db Explorer
- 46 installs
- 19 repo stars
- Updated July 31, 2026
- huaweicloud/huaweicloud-skills
Turn natural-language questions into safe SQL against Ascend PyTorch Profiler / msprof databases to query operator time, communication, and dispatch data.
About
Converts natural language into safe executable SQL to query Ascend PyTorch Profiler / msprof SQLite databases for operator timing, communication, and dispatch bottlenecks. A developer uses it to analyze profiling data and pull table schemas without writing SQL by hand.
- Natural-language to safe SQL over msprof/PyTorch profiler DB
- Analyzes operator time, communication, and dispatch bottlenecks
Huawei Cloud Ascend Profiler Db Explorer by the numbers
- 46 all-time installs (skills.sh)
- +4 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #953 of 2,101 Data Science & ML skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-ascend-profiler-db-explorerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 46 |
|---|---|
| repo stars | ★ 19 |
| Last updated | July 31, 2026 |
| Repository | huaweicloud/huaweicloud-skills ↗ |
What it does
Turn natural-language questions into safe SQL against Ascend PyTorch Profiler / msprof databases to query operator time, communication, and dispatch data.
Files
Huawei Cloud Ascend Profiler DB Explorer
Overview
This skill converts natural language questions about profiling data into safe SQL queries for Ascend PyTorch Profiler and msprof databases.
Architecture: Natural Language Input → Intent Recognition → SQL Generation → Database Execution → Result Analysis
Related Skills:
huawei-cloud-msot-msopprof-operator-profiler- Operator performance data
collection
huawei-cloud-ascend-small-model-migrate- Migration workflow that uses
profiling analysis
huawei-cloud-ascendc-operator-performance-optim- Operator optimization
workflow
Architecture Components
This skill involves the following cloud services and components:
- MSProf: Ascend profiling tool for data collection and database management
- SQLite: Database engine for storing profiling data
- Ascend NPU: Target hardware for performance profiling
- msprof_mcp: Tool for executing SQL queries on profiling database
Architecture Diagram:
┌─────────────────────────────────────────────────────────────┐
│ Profiler DB Explorer Skill │
├─────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Natural │───▶│ SQL │───▶│ Database │ │
│ │ Language │ │ Generation │ │ Execution │ │
│ │ Input │ │ │ │ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Intent │ │ CTE Macro │ │ Result │ │
│ │ Recognition │ │ Templates │ │ Analysis │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────┘Use Cases
Typical Problem Scenarios:
- Analyzing operator time consumption on Ascend NPU
- Identifying communication bottlenecks in distributed training
- Understanding framework dispatch overhead
- Querying profiling database for performance insights
- Debugging performance issues in model inference
Typical User Phrases:
- "Which operators are most time-consuming?"
- "Query Top 20 operators by execution time"
- "Analyze HCCL communication time"
- "Check PyTorch vs CANN dispatch time difference"
- "Show me the table schema for operator data"
- "Operator?"
- "AnalysisOperatorPerformance"
- "QueryprofilerDatabase"
Skill Objectives
- Convert natural language questions to SQL drafts: Quickly construct safe,
readable profiling queries based on preset CTE macros and dictionary rules.
- Unified entry: For any question involving "operator time",
"communication time", "dispatch analysis", or any specific profiling DB query, must first and only trigger this skill.
- Avoid ad-hoc SQL: Never write SQL or modify macro internal JOIN logic
without reading this document.
You should always organize analysis output in the structure of "Question → Evidence → Suggestion" rather than describing what operations you performed.
Role Positioning
You are an Ascend Profiling Database Query and SQL Design Expert, responsible for:
- Understanding user's performance problem intent
(operator/communication/dispatch, etc.).
- Selecting appropriate query channel (Track A / Track B).
- Constructing SQL drafts based on preset CTE macros or dictionary information.
- Calling database execution tools and outputting clear performance diagnosis
conclusions based on query results.
Usage Scenarios
Prioritize calling this skill in following scenarios:
- User asks "which operators are most time-consuming", "TopK operators",
"computation bottlenecks".
- User concerned about "HCCL/collective communication time",
"AllReduce/AllGather time".
- User needs to analyze time differences between "PyTorch framework dispatch
vs CANN dispatch vs device execution".
- Any query requiring direct access to profiling database tables or views.
Trigger Words (Recall Enhancement)
When user's question contains following words or similar expressions, prioritize triggering this skill:
ascend-pytorch-profiler-db/ascend_pytorch_profiler*.db/msprof_*.dbsqlite/table/schema/fieldTopK operators/communication time/dispatch analysis/
scheduling bottleneck
Mandatory Restrictions
- Main query must satisfy at least one of following:
- Contains aggregation functions (e.g.,
SUM,AVG,COUNT, etc.), OR - Explicitly includes
ORDER BY ... LIMIT 20(or smaller LIMIT). - Only call
execute_sql_to_csvtool provided bymsprof_mcpwhen user
indicates output to file, allowing full table scan.
- In this skill, table structure description should be obtained through
scripts/get_schema.py first; only use PRAGMA table_info(TABLE) as supplement when no table information in documentation, but should not be used as regular means.
Track A: Golden Views / CTE Macros (Priority)
When handling any profiling database query, must first try Track A (fast path):
1. Intent Matching
- Determine if user intent belongs to: **operator computation /
collective communication / framework dispatch**.
- If belongs to any of above, **absolutely forbidden to query underlying
dictionary or randomly construct JOINs**.
2. Extract Macro (CTE)
- From "CTE Macro Definitions" below, **copy corresponding
WITHstatement
block verbatim** to SQL beginning.
- Never modify JOIN logic and field expressions inside macros.
3. Concatenate Main Query
- After copied
WITH ... AS (...), writeSELECTquery for corresponding
view (e.g., compute_view, comm_view, dispatch_view).
- Example: `SELECT op_name, SUM(duration_ns) AS total_ns FROM compute_view
GROUP BY op_name ORDER BY total_ns DESC LIMIT 20;`
Track B: Underlying Documentation / profiler_db_data_format.md
Only enter Track B when one of following conditions met:
- User explicitly requests querying underlying hardware metrics
(e.g., PMU counts, memory allocation, Step division, etc.).
- Requirement not covered by existing views in "CTE Macro Definitions".
Core tool for Track B is scripts/get_schema.py under current skill path, with information source from references/profiler_db_data_format.md.
1. Get Real Table Names from Current DB (Recommended)
First execute sqlite query on target db to get actual tables present in current version:
sqlite3 {db_path} ".tables"
sqlite3 {db_path} "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"Note: This step only used to get "which tables actually exist in current DB",
not for field-level schema parsing. For field descriptions, use
get_schema.py --table_name.2. Use Script for Document/DB Alignment (Recommended)
- Purpose: Automatically list document table names, current DB table names,
or directly do intersection comparison to reduce manual filtering.
- Command line examples:
cd {skills_path}/huawei-cloud-ascend-profiler-db-explorer/scripts
python3 get_schema.py --list_tables
python3 get_schema.py --db_path {db_path} --list_db_tables
python3 get_schema.py --db_path {db_path} --compare_doc_db3. get_schema_by_table_name(table_name)
- Purpose: Extract corresponding section (fields, format, description, etc.)
for the table from profiler_db_.md by table name.
- Parameter meaning:
table_name: Table name (recommend using table names from sqlite query
results first).
- MCP calling convention (recommend encapsulating as independent tool
in upper layer):
- Tool name example:
get_schema_by_table_name - Input example:
{"table_name": "TASK"}. - Command line examples:
cd {skills_path}/huawei-cloud-ascend-profiler-db-explorer/scripts
python3 get_schema.py --table_name TASK
python3 get_schema.py --table_name COMMUNICATION_OPReturns original description paragraph for the table from reference documentation.
Track B Usage Principles
1. Use real table names from sqlite query first, then call get_schema.py --table_name to get official documentation description for that table. 2. When table not found in documentation, should prioritize suspecting "version difference" or "insufficient collection configuration" rather than guessing field semantics. 3. Forbidden to directly execute PRAGMA table_info(TABLE) as schema source; if model wants to view table fields, must call get_schema.py instead.
Execution and Summary
- Execution: After assembling SQL, call
execute_sqlorexecute_sql_to_csv
tool provided by msprof_mcp to execute query.
- Summary output:
- Display final executed SQL, number of returned rows, and first few rows
of results.
CTE Macro Definitions (Must Reuse in Track A)
[Highest Warning] Below are macro blocks (CTE) dedicated to Ascend Profiling. In Track A:
- Must completely copy corresponding macro code block as
WITHheader
of SQL.
- Never modify JOIN, field meaning, or computation logic inside macros.
1. Operator Computation Detail Macro (Compute Macro)
Purpose: Query operator time consumption, TopK operators, computation bottlenecks.
WITH compute_view AS (
SELECT c.globalTaskId, ROUND(t.endNs - t.startNs) AS duration_ns,
n.value AS op_name, type_str.value AS op_type
FROM COMPUTE_TASK_INFO c
LEFT JOIN TASK t ON t.globalTaskId = c.globalTaskId
LEFT JOIN STRING_IDS n ON n.id = c.name
LEFT JOIN STRING_IDS type_str ON type_str.id = c.opType
)2. Communication Detail Macro (Communication Macro)
Purpose: Query HCCL collective communication (AllReduce, AllGather, etc.) time.
WITH comm_view AS (
SELECT ROUND(c.endNs - c.startNs) AS duration_ns, n.value AS op_name,
t.value AS op_type, g.value AS group_name
FROM COMMUNICATION_OP c
LEFT JOIN STRING_IDS n ON n.id = c.opName
LEFT JOIN STRING_IDS t ON t.id = c.opType
LEFT JOIN STRING_IDS g ON g.id = c.groupName
)3. Dispatch Mapping Macro (Dispatch Macro)
Purpose: Compare time differences between PyTorch framework dispatch, CANN layer dispatch, and underlying execution to locate scheduling congestion.
WITH dispatch_view AS (
SELECT
ROUND(t.endNs - t.startNs) AS task_duration_ns,
ROUND(c.endNs - c.startNs) AS cann_duration_ns,
ROUND(p.endNs - p.startNs) AS pytorch_duration_ns,
c_str.value AS cann_api_name,
p_str.value AS pytorch_api_name,
t_str.value AS task_type
FROM TASK t
LEFT JOIN CANN_API c ON t.connectionId = c.connectionId
LEFT JOIN CONNECTION_IDS conn ON conn.connectionId = t.connectionId
LEFT JOIN PYTORCH_API p ON p.connectionId = conn.id
LEFT JOIN STRING_IDS c_str ON c.name = c_str.id
LEFT JOIN STRING_IDS p_str ON p.name = p_str.id
LEFT JOIN STRING_IDS t_str ON t.taskType = t_str.id
)Enhanced Features
Intelligent Bottleneck Diagnoser
This skill includes an AI-powered bottleneck diagnosis system that analyzes profiling data to identify root causes automatically:
Features:
- Automatic Root Cause Analysis: Identifies performance bottlenecks from
profiling data
- Bottleneck Classification: Categorizes bottlenecks into memory-bound,
compute-bound, communication-bound, or operator-fallback types
- Actionable Recommendations: Provides prioritized optimization
recommendations
- Pattern Matching: Detects known performance anti-patterns and suggests
fixes
- Impact Assessment: Estimates potential performance improvement from
each optimization
Bottleneck Classification:
| Category | Characteristics | Causes | Strategy |
|---|---|---|---|
| Memory-bound | High memory bandwidth | TransData ops | Reduce transfer |
| Compute-bound | High AI_CORE util | Large matmul | Optimize ops |
| Comm-bound | HCCL ops significant | Inefficient coll | Optimize comm |
| Operator-fallback | AI_CPU execution | Missing NPU impl | AscendC ops |
Bottleneck Diagnosis Output:
## Intelligent Bottleneck Diagnosis Report
### Overall Performance Summary
- Total Inference Time: 15.2 ms
- Bottleneck Score: 78/100
- Main Bottleneck Type: Memory-bound
### Identified Bottlenecks
| Rank | Operator | Type | Time | Percentage | Issue |
|------|----------|------|------|------------|-------|
| 1 | TransData | AI_CPU | 4.2 ms | 27.6% | Frequent CPU-NPU transfer |
| 2 | IndexSelect | AI_CPU | 2.8 ms | 18.4% | Operator fallback to CPU |
| 3 | NMS | AI_CPU | 1.5 ms | 9.9% | No NPU implementation |
### Optimization Recommendations
| Priority | Operator | Issue | Solution | Expected Gain |
|----------|----------|-------|----------|---------------|
| P0 | TransData | Data transfer | Reduce redundant movement | 20-25% |
| P1 | IndexSelect | CPU fallback | Implement AscendC version | 15-20% |
| P2 | NMS | CPU fallback | Use NPU-optimized NMS | 10-15% |
### Quick Wins
1. Batch pre-processing on NPU instead of CPU
2. Use async data transfer with overlap
3. Enable memory pooling for intermediate tensorsReference Documents
| Document | Description |
|---|---|
| Profiler DB Data Format | Table structure |
| Acceptance Criteria | Acceptance criteria |
| Verification Method | Verification approach |
| Troubleshooting | Common issues |
Prerequisites
- msprof >= 7.0.0 installed
- sqlite3 >= 3.0.0 installed
- Have Ascend PyTorch Profiler or msprof generated database file
Core Commands
# Query operator time consumption
python3 scripts/query_profiler_db.py \
--db /path/to/ascend_pytorch_profiler.db \
--query "Top 10 operators by time consumption"Parameter Confirmation
| Parameter | Description | Required |
|---|---|---|
| db | Profiler database path | Yes |
| query | Natural language query | Yes |
| output | Output format | No |
Acceptance Criteria
Functional Acceptance Criteria
1. SQL Generation
| Criteria | Description | Verification Method |
|---|---|---|
| AC-1.1 | Should generate valid SQL from natural language | Execute and verify results |
| AC-1.2 | Should use Track A CTE macros for common queries | Check CTE usage |
| AC-1.3 | Should follow security rules (aggregation/LIMIT) | Verify query structure |
2. Track Selection
| Criteria | Description | Verification Method |
|---|---|---|
| AC-2.1 | Should select Track A for common queries | Check intent matching |
| AC-2.2 | Should select Track B for edge cases | Verify conditions met |
| AC-2.3 | Should explain track selection reasoning | Check output explanation |
3. Schema Query
| Criteria | Description | Verification Method |
|---|---|---|
| AC-3.1 | Should use get_schema.py for table info | Check script usage |
| AC-3.2 | Should handle missing tables gracefully | Verify error handling |
| AC-3.3 | Should document table structure | Check reference updates |
4. Query Execution
| Criteria | Description | Verification Method |
|---|---|---|
| AC-4.1 | Should execute SQL via msprof_mcp tool | Verify tool call |
| AC-4.2 | Should present results clearly | Check output format |
| AC-4.3 | Should limit output rows | Verify LIMIT usage |
Correct/Error Pattern Comparison
SQL Generation
Correct: Include aggregation and LIMIT
SELECT op_name, SUM(duration_ns) AS total_ns
FROM compute_view
GROUP BY op_name
ORDER BY total_ns DESC
LIMIT 20;Error: Missing aggregation or LIMIT
SELECT op_name, duration_ns -- No aggregation
FROM compute_view;
-- Missing LIMIT can return too many rowsCTE Macro Usage
Correct: Use Track A macros for common queries
-- Operator time query
WITH compute_view AS (
SELECT c.globalTaskId, ROUND(t.endNs - t.startNs) AS duration_ns, ...
FROM COMPUTE_TASK_INFO c
LEFT JOIN TASK t ON ...
)
SELECT op_name, SUM(duration_ns) AS total_ns
FROM compute_view
GROUP BY op_name ORDER BY total_ns DESC LIMIT 20;Error: Ignore Track A for common queries
-- Rewriting Track A logic from scratch is error-prone
SELECT op_name, SUM(ROUND(t.endNs - t.startNs)) AS total_ns
FROM TASK t, COMPUTE_TASK_INFO c, STRING_IDS n
WHERE ... -- Complex manual joinSchema Reference
Correct: Use get_schema.py
python3 scripts/get_schema.py --table_name TASKError: Use PRAGMA as primary source
sqlite3 profiling.db "PRAGMA table_info(TASK)" # Not recommended as primaryNon-Functional Acceptance Criteria
| Criteria | Description | Threshold |
|---|---|---|
| NAC-1.1 | SQL generation time | < 10 seconds |
| NAC-1.2 | Query execution time | < 60 seconds |
| NAC-1.3 | Result accuracy | > 95% |
Test Cases Summary
Positive Test Cases
1. TC-001: TopK operator query (Track A) 2. TC-002: Communication time query (Track A) 3. TC-003: Dispatch analysis query (Track A) 4. TC-004: Custom table schema query (Track B) 5. TC-005: Cross-table join query
Negative Test Cases
1. TC-N01: Query without aggregation 2. TC-N02: Query without LIMIT 3. TC-N03: Using PRAGMA instead of get_schema.py 4. TC-N04: Ignoring Track A for common query 5. TC-N05: Invalid table name in query
msprofguideoutputdbformatformulaDataDescription
msprofcommandcommandExecution Completeafter, ableGenerate aSummaryallhavePerformanceDataofmsprof\_\{timebetweenstab\}.dbtableStructurefile, oughtfilepushrecommendUsageMindStudio InsightToolssearchsee, alsocanin order toUsageNavicat PremiumetcDatabaseDevelopmentToolsstraightconnectprintopen. whenpreviousdbfileSummaryofPerformanceDataifunder:
>[!NOTE] Description >dbfileaveragein order totableformatshapeformulaexpandshowPerformanceData, andallhaveDataaveragein order tonumbercharacterreflectshoot (exampleifopNamecharacterparagraphunderofOperatornamedisplayshowas194) , numbercharacterandNameofreflectshoottableasSTRING\_IDS.
singlebitRelated
1. timebetweenRelated, statisticsoneUsagecontainsecond (ns) , andasthisregionUnixtimebetween. 2. MemoryRelated, statisticsoneUsagecharactersection (Byte) . 3. bandwidthwidthRelated, statisticsoneUsageByte/s. 4. frequencyrateRelated, statisticsoneUsageMHz.
ENUM\_API\_TYPE
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 1 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, ID |
| name | TEXT | APItypetype |
table 2 insidecontent
| id | name |
|---|---|
| 20000 | acl |
| 15000 | model |
| 10000 | node |
| 5500 | communication |
| 5000 | runtime |
| 50001 | op |
| 50002 | queue |
| 50003 | trace |
| 50004 | mstx |
ENUM\_MODULE
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 3 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, ID |
| name | TEXT | Componentsname |
table 4 insidecontent
| id | name |
|---|---|
| 0 | SLOG |
| 1 | IDEDD |
| 2 | SCC |
| 3 | HCCL |
| 4 | FMK |
| 5 | CCU |
| 6 | DVPP |
| 7 | RUNTIME |
| 8 | CCE |
| 9 | HDC |
| 10 | DRV |
| 11 | NET |
| 22 | DEVMM |
| 23 | KERNEL |
| 24 | LIBMEDIA |
| 25 | CCECPU |
| 27 | ROS |
| 28 | HCCP |
| 29 | ROCE |
| 30 | TEFUSION |
| 31 | PROFILING |
| 32 | DP |
| 33 | APP |
| 34 | TS |
| 35 | TSDUMP |
| 36 | AICPU |
| 37 | LP |
| 38 | TDT |
| 39 | FE |
| 40 | MD |
| 41 | MB |
| 42 | ME |
| 43 | IMU |
| 44 | IMP |
| 45 | GE |
| 47 | CAMERA |
| 48 | ASCENDCL |
| 49 | TEEOS |
| 50 | ISP |
| 51 | SIS |
| 52 | HSM |
| 53 | DSS |
| 54 | PROCMGR |
| 55 | BBOX |
| 56 | AIVECTOR |
| 57 | TBE |
| 58 | FV |
| 59 | MDCMAP |
| 60 | TUNE |
| 61 | HSS |
| 62 | FFTS |
| 63 | OP |
| 64 | UDF |
| 65 | HICAID |
| 66 | TSYNC |
| 67 | AUDIO |
| 68 | TPRT |
| 69 | ASCENDCKERNEL |
| 70 | ASYS |
| 71 | ATRACE |
| 72 | RTC |
| 73 | SYSMONITOR |
| 74 | AMP |
| 75 | ADETECT |
| 76 | MBUFF |
| 77 | CUSTOM |
ENUM\_HCCL\_DATA\_TYPE
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 5 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, ID |
| name | TEXT | throughinformationDatatypetype |
table 6 insidecontent
| id | name |
|---|---|
| 0 | INT8 |
| 1 | INT16 |
| 2 | INT32 |
| 3 | FP16 |
| 4 | FP32 |
| 5 | INT64 |
| 6 | UINT64 |
| 7 | UINT8 |
| 8 | UINT16 |
| 9 | UINT32 |
| 10 | FP64 |
| 11 | BFP16 |
| 12 | INT128 |
| 255 | RESERVED |
| 65534 | N/A |
| 65535 | INVALID_TYPE |
ENUM\_HCCL\_LINK\_TYPE
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 7 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, ID |
| name | TEXT | throughinformationlinkpathtypetype |
table 8 insidecontent
| id | name |
|---|---|
| 0 | ON_CHIP |
| 1 | HCCS |
| 2 | PCIE |
| 3 | ROCE |
| 4 | SIO |
| 5 | HCCS_SW |
| 6 | STANDARD_ROCE |
| 255 | RESERVED |
| 65534 | N/A |
| 65535 | INVALID_TYPE |
ENUM\_HCCL\_TRANSPORT\_TYPE
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 9 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, ID |
| name | TEXT | throughinformationtransferoutputtypetype |
table 10 insidecontent
| id | name |
|---|---|
| 0 | SDMA |
| 1 | RDMA |
| 2 | LOCAL |
| 255 | RESERVED |
| 65534 | N/A |
| 65535 | INVALID_TYPE |
ENUM\_HCCL\_RDMA\_TYPE
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 11 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, ID |
| name | TEXT | throughinformationRDMAtypetype |
table 12 insidecontent
| id | name |
|---|---|
| 0 | RDMA_SEND_NOTIFY |
| 1 | RDMA_SEND_PAYLOAD |
| 255 | RESERVED |
| 65534 | N/A |
| 65535 | INVALID_TYPE |
ENUM\_MSTX\_EVENT\_TYPE
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 13 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, HostsidetxprintpointDataeventtypetypeCorrespondingofID |
| name | TEXT | HostsidetxprintpointDataeventtypetype |
table 14 insidecontent
| id | name |
|---|---|
| 0 | marker |
| 1 | push/pop |
| 2 | start/end |
| 3 | marker_ex |
ENUM\_MEMCPY\_OPERATION
pieceraisetable.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 15 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | mainkey, ID |
| name | TEXT | copyshelltypetype |
table 16 insidecontent
| id | name |
|---|---|
| 0 | host to host |
| 1 | host to device |
| 2 | device to host |
| 3 | device to device |
| 4 | managed memory |
| 5 | addr device to device |
| 6 | host to device ex |
| 7 | device to host ex |
| 65535 | other |
STRING\_IDS
reflectshoottable, Used forMemoryIDandcharactercharacterstringreflectshootrelatedsystem.
noCorrespondingopenrelated.
table 17 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | searchlead, string ID |
| value | TEXT | string value |
SESSION\_TIME\_INFO
timebetweentable, Used forMemoryPerformanceDatamiddleofopenbeginconclusionendtimebetween. inCollectionnotpositiveoftenretreatoutputtime, noconclusionendtimebetween.
noCorrespondingopenrelated.
table 18 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| startTimeNs | INTEGER | TaskopenstarttimeofUnixtimebetween, singlebitns |
| endTimeNs | INTEGER | TaskconclusionendtimeofUnixtimebetween, singlebitns |
NPU\_INFO
CorrespondingdeviceIdofcoreslicetypesign.
noCorrespondingopenrelated.
table 19 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| id | INTEGER | DeviceID, displayshowas-1timetableshownotCollectiontodeviceId |
| name | TEXT | DeviceCorrespondingofcoreslicetypesign |
HOST\_INFO
hostUidandName.
noCorrespondingopenrelated.
table 20 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| hostUid | TEXT | standardrecognizeHostofonlyoneID |
| hostName | TEXT | HostmainmachineName, iflocalhost |
TASK
taskData, presentappearallhaveHardwareExecuteofOperatorinformationinformation.
by--task-timeopenrelatedControl.
table 21 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| startNs | INTEGER | andglobalTaskIdconnectmatchsearchlead, searchleadNameTaskIndex, OperatorTaskopenbegintimebetween, singlebitns |
| endNs | INTEGER | OperatorTaskconclusionendtimebetween, singlebitns |
| deviceId | INTEGER | OperatorTaskCorrespondingofDeviceID |
| connectionId | INTEGER | Generatehost-deviceconnectline |
| globalTaskId | INTEGER | andstartNsconnectmatchsearchlead, searchleadNameTaskIndex, Used foronlyonestandardrecognizeGlobalOperatorTask |
| globalPid | INTEGER | OperatorTaskExecutetimeofPID |
| taskType | INTEGER | DeviceExecuteoughtOperatorofaddspeedadaptertypetype |
| contextId | INTEGER | Used forregiondistributechildfiguresmallOperator, oftenseeinMIXOperatorandFFTS+Task |
| streamId | INTEGER | OperatorTaskCorrespondingofstreamId |
| taskId | INTEGER | OperatorTaskCorrespondingoftaskId |
| modelId | INTEGER | OperatorTaskCorrespondingofmodelId |
COMPUTE\_TASK\_INFO
CalculationOperatorDescriptioninformationinformation.
by--task-timeopenrelatedControl.
table 22 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| name | INTEGER | Operatorname, STRING_IDS(name) |
| globalTaskId | INTEGER | searchlead, GlobalOperatorTaskID, Used forrelatedconnectTASKtable |
| blockDim | INTEGER | OperatorRunTilingnumberamount, CorrespondingOperatorRuntimeCore count |
| mixBlockDim | INTEGER | mixOperatorfromaddspeedadapterofBlockNumvalue |
| taskType | INTEGER | HostExecuteoughtOperatorofaddspeedadaptertypetype, STRING_IDS(taskType) |
| opType | INTEGER | Operatortypetype, STRING_IDS(opType) |
| inputFormats | INTEGER | OperatoroutputinputDataformatformula, STRING_IDS(inputFormats) |
| inputDataTypes | INTEGER | OperatoroutputinputDatatypetype, STRING_IDS(inputDataTypes) |
| inputShapes | INTEGER | Operatorofoutputinputdimensiondegree, STRING_IDS(inputShapes) |
| outputFormats | INTEGER | OperatorOutputDataformatformula, STRING_IDS(outputFormats) |
| outputDataTypes | INTEGER | OperatorOutputDatatypetype, STRING_IDS(outputDataTypes) |
| outputShapes | INTEGER | OperatorOutputdimensiondegree, STRING_IDS(outputShapes) |
| attrInfo | INTEGER | Operatorofattrinformationinformation, usecomereflectshootOperatorshape, OperatorCustomofparameternumberetc, STRING_IDS(attrInfo) |
| opState | INTEGER | Operatorofmovequietstateinformationinformation, dynamictableshowmovestateOperator, statictableshowquietstateOperator, N/AtableshowoughtScenariosoroughtOperatornotrecognizecategory, STRING_IDS(opState) |
| hf32Eligible | INTEGER | standardrecognizeiswhetherUsageHF32precisiondegreestandardremember, YEStableshowUsage, NOtableshownotUsage, N/AtableshowoughtScenariosoroughtOperatornotrecognizecategory, STRING_IDS(hf32Eligible) |
COMMUNICATION\_TASK\_INFO
DescriptionthroughinformationsmallOperatorinformationinformation.
by--task-time, --hccl, --ascendclopenrelatedControlCorrespondingDataofCollection. Configuration--task-timeasnonl0timeDatahavevalid. havethroughinformationDataofScenariosundersilentrecognizeGenerateoughttable.
table 23 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| name | INTEGER | Operatorname, STRING_IDS(name) |
| globalTaskId | INTEGER | searchlead, searchleadNameCommunicationTaskIndex, GlobalOperatorTaskID, Used forrelatedconnectTASKtable |
| taskType | INTEGER | Operatortypetype, STRING_IDS(taskType) |
| planeId | INTEGER | networknetworkaveragesurfaceID |
| groupName | INTEGER | throughinformationdomain, STRING_IDS(groupName) |
| notifyId | INTEGER | notifyonlyoneID |
| rdmaType | INTEGER | RDMAtypetype, Packagecontain: RDMASendNotify, RDMASendPayload, ENUM_HCCL_RDMA_TYPE(rdmaType) |
| srcRank | INTEGER | sourceRank |
| dstRank | INTEGER | itemofRank |
| transportType | INTEGER | transferoutputtypetype, Packagecontain: LOCAL, SDMA, RDMA, ENUM_HCCL_TRANSPORT_TYPE(transportType) |
| size | INTEGER | Dataamount, singlebitByte |
| dataType | INTEGER | Dataformatformula, ENUM_HCCL_DATA_TYPE(dataType) |
| linkType | INTEGER | linkpathtypetype, Packagecontain: HCCS, PCIe, RoCE, ENUM_HCCL_LINK_TYPE(linkType) |
| opId | INTEGER | CorrespondingoflargeOperatorId, Used forrelatedconnectCOMMUNICATION_OPtable |
| isMaster | INTEGER | standardremembermainfromflowthroughinformationOperator, Analysistimein order tomainflowOperatorasstandard, getvalueas: 0: fromflow1: mainflow |
| bandwidth | NUMERIC | oughtthroughinformationsmallOperatorofbandwidthwidthData, singlebitByte / s |
COMMUNICATION\_OP
DescriptionthroughinformationlargeOperatorinformationinformation.
by--task-time, --hcclopenrelatedControlCorrespondingDataofCollection. havethroughinformationDataofScenariosundersilentrecognizeGenerateoughttable.
table 24 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| opName | INTEGER | Operatorname, STRING_IDS(opName), example: hcom_allReduce__428_0_1 |
| startNs | INTEGER | throughinformationlargeOperatorofopenbegintimebetween, singlebitns |
| endNs | INTEGER | throughinformationlargeOperatorofconclusionendtimebetween, singlebitns |
| connectionId | INTEGER | Generatehost-deviceconnectline |
| groupName | INTEGER | throughinformationdomain, STRING_IDS(groupName), example: 10.170.22.98%enp67s0f5_60000_0_1708156014257149 |
| opId | INTEGER | searchlead, throughinformationlargeOperatorId, Used forrelatedconnectCOMMUNICATION_TASK_INFOtable |
| relay | INTEGER | leasetrackthroughinformationstandardrecognize |
| retry | INTEGER | weighttransferstandardrecognize |
| dataType | INTEGER | largeOperatortransferoutputofDatatypetype, if (INT8, FP32) , ENUM_HCCL_DATA_TYPE(dataType) |
| algType | INTEGER | throughinformationOperatorUsageofcomputemethod, candistributeasmultiplecountPhase, STRING_IDS(algType), if (HD-MESH) |
| count | NUMERIC | OperatortransferoutputofdataTypetypetypeofDataamount |
| opType | INTEGER | Operatortypetype, STRING_IDS(opType), example: hcom_broadcast_ |
| deviceld | INTEGER | DeviceID |
CANN\_API
CANN APIData.
by--ascendclopenrelatedControl.
table 25 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| startNs | INTEGER | APIofopenbegintimebetween, singlebitns |
| endNs | INTEGER | APIofconclusionendtimebetween, singlebitns |
| type | INTEGER | APItypetype, ENUM_API_TYPE(type) |
| globalTid | INTEGER | APIallattributeofGlobalTID. high32bit: PID, low32bit: TID |
| connectionId | INTEGER | searchlead, Used forrelatedconnectTASKtableandCOMMUNICATION_OPtable |
| name | INTEGER | APIofName, STRING_IDS(name) |
QOS
keepkeepQoSofData.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 26 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| eventName | NUMERIC | QoSmatterfileName, STRING_IDS(eventName) |
| bandwidth | NUMERIC | QoSCorrespondingtimebetweenofbandwidthwidth, singlebitByte / s |
| timestampNs | NUMERIC | thisregiontimebetween, singlebitns |
AICORE\_FREQ
AI Corefrequencyrateinformationinformation.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 27 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceld | INTEGER | DeviceID |
| timestampNs | NUMERIC | frequencyratechangetransformtimeofthisregiontimebetween, singlebitns |
| freq | INTEGER | AI Corefrequencyratevalue, singlebitMHz |
ACC\_PMU
ACC\_PMUData.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 28 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| accId | INTEGER | addspeedadapterID |
| readBwLevel | INTEGER | DVPPandDSAaddspeedadapterreadbandwidthwidthofetclevel |
| writeBwLevel | INTEGER | DVPPandDSAaddspeedadaptercomposebandwidthwidthofetclevel |
| readOstLevel | INTEGER | DVPPandDSAaddspeedadapterreadandissueofetclevel |
| writeOstLevel | INTEGER | DVPPandDSAaddspeedadaptercomposeandissueofetclevel |
| timestampNs | NUMERIC | thisregiontimebetween, singlebitns |
| deviceId | INTEGER | DeviceID |
SOC\_BANDWIDTH\_LEVEL
SoCbandwidthwidthetclevelinformationinformation.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 29 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| l2BufferBwLevel | INTEGER | L2 Bufferbandwidthwidthetclevel |
| mataBwLevel | INTEGER | Matabandwidthwidthetclevel |
| timestampNs | NUMERIC | thisregiontimebetween, singlebitns |
| deviceId | INTEGER | DeviceID |
NIC
eachcounttimebetweensectionpointnetworknetworkinformationinformationData.
Controlopenrelated:
- msprofcommandcommandof--sys-io-profiling, --sys-io-sampling-freq
- Ascend PyTorch Profilerofsys\_io
table 30 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| bandwidth | INTEGER | bandwidthwidth, singlebitByte/s |
| rxPacketRate | NUMERIC | receivePackagespeedrate, singlebitpacket/s |
| rxByteRate | NUMERIC | connectreceivecharactersectionspeedrate, singlebitByte/s |
| rxPackets | INTEGER | accumulatecalculatereceivePackagenumberamount, singlebitpacket |
| rxBytes | INTEGER | accumulatecalculateconnectreceivecharactersectionnumberamount, singlebitByte |
| rxErrors | INTEGER | accumulatecalculateconnectreceiveerrorerrorPackagenumberamount, singlebitpacket |
| rxDropped | INTEGER | accumulatecalculateconnectreceivelosePackagenumberamount, singlebitpacket |
| txPacketRate | NUMERIC | issuePackagespeedrate, singlebitpacket/s |
| txByteRate | NUMERIC | issuepresentcharactersectionspeedrate, singlebitByte/s |
| txPackets | INTEGER | accumulatecalculateissuePackagenumberamount, singlebitpacket |
| txBytes | INTEGER | accumulatecalculateissuepresentcharactersectionnumberamount, singlebitByte |
| txErrors | INTEGER | accumulatecalculateissuepresenterrorerrorPackagenumberamount, singlebitpacket |
| txDropped | INTEGER | accumulatecalculateissuepresentlosePackagenumberamount, singlebitpacket |
| funcId | INTEGER | Sidemouthsign |
ROCE
RoCEthroughinformationInterfacebandwidthwidthData.
Controlopenrelated:
- msprofcommandcommandof--sys-io-profiling, --sys-io-sampling-freq
- Ascend PyTorch Profilerofsys\_io
table 31 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| bandwidth | INTEGER | bandwidthwidth, singlebitByte/s |
| rxPacketRate | NUMERIC | receivePackagespeedrate, singlebitpacket/s |
| rxByteRate | NUMERIC | connectreceivecharactersectionspeedrate, singlebitByte/s |
| rxPackets | INTEGER | accumulatecalculatereceivePackagenumberamount, singlebitpacket |
| rxBytes | INTEGER | accumulatecalculateconnectreceivecharactersectionnumberamount, singlebitByte |
| rxErrors | INTEGER | accumulatecalculateconnectreceiveerrorerrorPackagenumberamount, singlebitpacket |
| rxDropped | INTEGER | accumulatecalculateconnectreceivelosePackagenumberamount, singlebitpacket |
| txPacketRate | NUMERIC | issuePackagespeedrate, singlebitpacket/s |
| txByteRate | NUMERIC | issuepresentcharactersectionspeedrate, singlebitByte/s |
| txPackets | INTEGER | accumulatecalculateissuePackagenumberamount, singlebitpacket |
| txBytes | INTEGER | accumulatecalculateissuepresentcharactersectionnumberamount, singlebitByte |
| txErrors | INTEGER | accumulatecalculateissuepresenterrorerrorPackagenumberamount, singlebitpacket |
| txDropped | INTEGER | accumulatecalculateissuepresentlosePackagenumberamount, singlebitpacket |
| funcId | INTEGER | Sidemouthsign |
LLC
threelevelslowkeepbandwidthwidthData.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 32 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| llcId | INTEGER | threelevelslowkeepID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| hitRate | NUMERIC | threelevelslowkeepcommandmiddlerate(100%) |
| throughput | NUMERIC | threelevelslowkeepinputoutputamount, singlebitByte/s |
| mode | INTEGER | modelformula, Used forregiondistributeisreadorcompose, STRING_IDS(mode) |
TASK\_PMU\_INFO
CalculationOperatorofPMUData.
Controlopenrelated:
- msprofcommandcommandof--ai-core, --aic-mode=task-basedopenrelatedControloughttableGenerate, --aic-metricsopenrelatedControltoolbodyDataCollection
- Ascend PyTorch Profilerofaic\_metrics
- MindSpore Profilerofaic\_metrics
onlyAtlas 200I/500 A2 pushmanageproduceproductandAtlas A2 trainpracticesystemcolumnproduceproduct/Atlas A2 pushmanagesystemcolumnproduceproductSupportCollectionoughtData.
table 33 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| globalTaskId | INTEGER | GlobalOperatorTaskID, Used forrelatedconnectTASKtable |
| name | INTEGER | PMU metricfingerstandardname, STRING_IDS(name) |
| value | NUMERIC | Correspondingfingerstandardnameofnumbervalue |
SAMPLE\_PMU\_TIMELINE
sample-basedofPMUData, Used fortimelinetypeofDatapresentappear.
Controlopenrelated:
- msprofcommandcommandof--ai-core, --aic-mode=sample-basedopenrelatedControloughttableGenerate, --aic-metricsopenrelatedControltoolbodyDataCollection
- Ascend PyTorch Profilerofaic\_metrics
- MindSpore Profilerofaic\_metrics
table 34 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| totalCycle | INTEGER | Correspondingcoreintimebetweensliceaboveofcyclenumber |
| usage | NUMERIC | Correspondingcoreintimebetweensliceaboveofutilizeuserate (100%) |
| freq | NUMERIC | Correspondingcoreintimebetweensliceaboveoffrequencyrate, singlebitMHz |
| coreId | INTEGER | coreId |
| coreType | INTEGER | coretypetype(AICorAIV), STRING_IDS(coreType) |
SAMPLE\_PMU\_SUMMARY
sample-basedofPMUData, Used forsummarytypeofDatapresentappear.
Controlopenrelated:
- msprofcommandcommandof--ai-core, --aic-mode=sample-basedopenrelatedControloughttableGenerate, --aic-metricsopenrelatedControltoolbodyDataCollection
- Ascend PyTorch Profilerofaic\_metrics
- MindSpore Profilerofaic\_metrics
table 35 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| metric | INTEGER | PMU metricfingerstandardname, STRING_IDS(metric) |
| value | NUMERIC | Correspondingfingerstandardnameofnumbervalue |
| coreId | INTEGER | coreId |
| coreType | INTEGER | coretypetype(AICorAIV), STRING_IDS(coreType) |
NPU\_MEM
NPUMemoryoccupyuseData.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 36 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| type | INTEGER | eventtypetype, appordevice, STRING_IDS(type) |
| ddr | NUMERIC | ddroccupyuselargesmall, singlebitByte |
| hbm | NUMERIC | hbmoccupyuselargesmall, singlebitByte |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| deviceId | INTEGER | DeviceID |
NPU\_MODULE\_MEM
NPUComponentsMemoryoccupyuseData.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 37 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| moduleId | INTEGER | Componentstypetype, ENUM_MODULE(moduleId) |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| totalReserved | NUMERIC | Memoryoccupyuselargesmall, singlebitByte |
| deviceId | INTEGER | DeviceID |
NPU\_OP\_MEM
CANNOperatorMemoryoccupyuseData, onlyGEOperatorSupport.
by--task-memoryopenrelatedControl.
table 38 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| operatorName | INTEGER | Operatornamecharacter, STRING_IDS(operatorName) |
| addr | INTEGER | Memoryapplypleaseexplainreleasefirstregionaddress |
| type | INTEGER | Used forregiondistributeapplypleaseorisexplainrelease, STRING_IDS(type) |
| size | INTEGER | applypleaseofMemorylargesmall, singlebitByte |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| globalTid | INTEGER | oughtitemrememberdocumentofGlobalTID. high32bit: PID, low32bit: TID |
| totalAllocate | NUMERIC | totalbodyalreadydistributematchofMemorylargesmall, singlebitByte |
| totalReserve | NUMERIC | totalbodymaintainhaveofMemorylargesmall, singlebitByte |
| component | INTEGER | Componentsname, STRING_IDS(component) |
| deviceId | INTEGER | DeviceID |
HBM
sliceaboveMemoryreadcomposespeedrateData.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 39 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| bandwidth | NUMERIC | bandwidthwidth, singlebitByte/s |
| hbmId | INTEGER | MemoryvisitasksingleunitID |
| type | INTEGER | Used forregiondistributereadorcompose, STRING_IDS(type) |
DDR
sliceaboveMemoryreadcomposespeedrateData.
by--sys-hardware-mem, --sys-hardware-mem-freqopenrelatedControl.
table 40 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| read | NUMERIC | MemoryReadbandwidthwidth, singlebitByte/s |
| write | NUMERIC | Memorycomposeinputbandwidthwidth, singlebitByte/s |
HCCS
HCCSsetmatchthroughinformationbandwidthwidthData.
Controlopenrelated:
- msprofcommandcommandof--sys-interconnection-profiling, --sys-interconnection-freq
- Ascend PyTorch Profilerofsys\_interconnection
table 41 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| txThroughput | NUMERIC | issuepresentbandwidthwidth, singlebitByte/s |
| rxThroughput | NUMERIC | connectreceivebandwidthwidth, singlebitByte/s |
PCIE
PCIebandwidthwidthData.
Controlopenrelated:
- msprofcommandcommandof--sys-interconnection-profiling, --sys-interconnection-freq
- Ascend PyTorch Profilerofsys\_interconnection
table 42 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | thisregiontimebetween, singlebitns |
| txPostMin | NUMERIC | issuepresentSidePCIe PostDatatransferoutputbandwidthwidthmostsmallvalue, singlebitByte/s |
| txPostMax | NUMERIC | issuepresentSidePCIe PostDatatransferoutputbandwidthwidthmostlargevalue, singlebitByte/s |
| txPostAvg | NUMERIC | issuepresentSidePCIe PostDatatransferoutputbandwidthwidthaverageaveragevalue, singlebitByte/s |
| txNonpostMin | NUMERIC | issuepresentSidePCIe Non-PostDatatransferoutputbandwidthwidthmostsmallvalue, singlebitByte/s |
| txNonpostMax | NUMERIC | issuepresentSidePCIe Non-PostDatatransferoutputbandwidthwidthmostlargevalue, singlebitByte/s |
| txNonpostAvg | NUMERIC | issuepresentSidePCIe Non-PostDatatransferoutputbandwidthwidthaverageaveragevalue, singlebitByte/s |
| txCplMin | NUMERIC | issuepresentSideconnectreceivecomposepleaserequestofcompletedDataPackagemostsmallvalue, singlebitByte/s |
| txCplMax | NUMERIC | issuepresentSideconnectreceivecomposepleaserequestofcompletedDataPackagemostlargevalue, singlebitByte/s |
| txCplAvg | NUMERIC | issuepresentSideconnectreceivecomposepleaserequestofcompletedDataPackageaverageaveragevalue, singlebitByte/s |
| txNonpostLatencyMin | NUMERIC | issuepresentSidePCIe Non-Postmodelformulaunderoftransferoutputtimeextendmostsmallvalue, singlebitns |
| txNonpostLatencyMax | NUMERIC | issuepresentSidePCIe Non-Postmodelformulaunderoftransferoutputtimeextendmostlargevalue, singlebitns |
| txNonpostLatencyAvg | NUMERIC | issuepresentSidePCIe Non-Postmodelformulaunderoftransferoutputtimeextendaverageaveragevalue, singlebitns |
| rxPostMin | NUMERIC | connectreceiveSidePCIe PostDatatransferoutputbandwidthwidthmostsmallvalue, singlebitByte/s |
| rxPostMax | NUMERIC | connectreceiveSidePCIe PostDatatransferoutputbandwidthwidthmostlargevalue, singlebitByte/s |
| rxPostAvg | NUMERIC | connectreceiveSidePCIe PostDatatransferoutputbandwidthwidthaverageaveragevalue, singlebitByte/s. |
| rxNonpostMin | NUMERIC | connectreceiveSidePCIe Non-PostDatatransferoutputbandwidthwidthmostsmallvalue, singlebitByte/s |
| rxNonpostMax | NUMERIC | connectreceiveSidePCIe Non-PostDatatransferoutputbandwidthwidthmostlargevalue, singlebitByte/s |
| rxNonpostAvg | NUMERIC | connectreceiveSidePCIe Non-PostDatatransferoutputbandwidthwidthaverageaveragevalue, singlebitByte/s |
| rxCplMin | NUMERIC | connectreceiveSidereceivetocomposepleaserequestofcompletedDataPackagemostsmallvalue, singlebitByte/s |
| rxCplMax | NUMERIC | connectreceiveSidereceivetocomposepleaserequestofcompletedDataPackagemostlargevalue, singlebitByte/s |
| rxCplAvg | NUMERIC | connectreceiveSidereceivetocomposepleaserequestofcompletedDataPackageaverageaveragevalue, singlebitByte/s |
META\_DATA
BaseData, whenpreviousonlykeepkeepVersionsigninformationinformation.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate.
table 43 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| name | TEXT | characterparagraphname |
| value | TEXT | numbervalue |
table 44 insidecontent
| name | containmeaning |
|---|---|
| SCHEMA_VERSION | totalVersionsign, if1.0.2 |
| SCHEMA_VERSION_MAJOR | largeVersionsign, if1, onlywhenDatabaseformatformulakeepinweightcomposeorweightstructuretimeupdatemodify |
| SCHEMA_VERSION_MINOR | middleVersionsign, if0, whenupdatemodifycolumnortypetypetimeupdatemodify, keepinCompatibilityaskproblem |
| SCHEMA_VERSION_MICRO | smallVersionsign, if2, whenUpdatetabletimeallableupdatemodify, nottoolhaveCompatibilityaskproblem |
MSTX\_EVENTS
mstxInterfaceCollectionofHostsideData, DevicesideDatainTASKtablemiddleadjustmatch.
by--msproftxopenrelatedControltableformatOutput, mstxInterfaceControlDataofCollection.
table 45 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| startNs | INTEGER | HostsidetxprintpointDataopenbegintimebetween, singlebitns |
| endNs | INTEGER | HostsidetxprintpointDataconclusionendtimebetween, singlebitns |
| eventType | INTEGER | HostsidetxprintpointDatatypetype, ENUM_MSTX_EVENT_TYPE(eventType) |
| rangeId | INTEGER | HostsiderangetypetypetxDataCorrespondingofrange ID |
| category | INTEGER | HostsidetxDataallattributeofdistributetypeID |
| message | INTEGER | HostsidetxprintpointDatacarrybandwidthinformationinformation, STRING_IDS(message) |
| globalTID | INTEGER | HostsidetxprintpointDataopenbeginlineprocessofGlobalTID |
| endGlobalTid | INTEGER | HostsidetxprintpointDataconclusionendlineprocessofGlobalTID |
| domainId | INTEGER | HostsidetxprintpointDataallattributedomainofdomainID |
| connectionId | INTEGER | HostsidetxprintpointDataofrelatedconnectID, TASK(connectionId) |
COMMUNICATION\_SCHEDULE\_TASK\_INFO
throughinformationadjustdegreeDescriptioninformationinformation, whenpreviousonlyneedlepairAI CPUthroughinformationOperatorofDescription.
noCorrespondingopenrelated, guideoutputmsprof\_\{timebetweenstab\}.dbfiletimesilentrecognizeGenerate. requiresCollectionEnvironmentmiddlePackagecontainAI CPUthroughinformationOperator.
table 46 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| name | INTEGER | Operatorname, STRING_IDS(name) |
| globalTaskId | INTEGER | mainkey, GlobalOperatorTaskID, Used forrelatedconnectTASKtable |
| taskType | INTEGER | HostExecuteoughtOperatorofaddspeedadaptertypetype, STRING_IDS(taskType) |
| opType | INTEGER | Operatortypetype, STRING_IDS(opType) |
MEMCPY\_INFO
DescriptionmemcpyRelatedOperatorofcopyshellDataamountandcopyshellmethoddirection.
by--runtime-apiopenrelatedControl.
table 47 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| globalTaskId | NUMERIC | mainkey, GlobalOperatorTaskID, Used forrelatedconnectTASK |
| size | NUMERIC | copyshellofDataamount |
| memcpyOperation | NUMERIC | copyshelltypetype, STRING_IDS(memcpyDirection) |
CPU\_USAGE
HostsideCPUutilizeuserateData.
by--host-sys=cpuopenrelatedControl.
table 48 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| timestampNs | NUMERIC | adoptsampletimeofthisregiontimebetween, singlebitns |
| cpuId | NUMERIC | cpucompilesign |
| usage | NUMERIC | utilizeuserate(%) |
HOST\_MEM\_USAGE
HostsideMemoryutilizeuserateData.
by--host-sys=memopenrelatedControl.
table 49 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| timestampNs | NUMERIC | adoptsampletimeofthisregiontimebetween, singlebitns |
| usage | NUMERIC | utilizeuserate(%) |
HOST\_DISK\_USAGE
HostsidemagneticdiskI/OutilizeuserateData.
by--host-sys=diskopenrelatedControl.
table 50 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| timestampNs | NUMERIC | adoptsampletimeofthisregiontimebetween, singlebitns |
| readRate | NUMERIC | magneticdiskreadspeedrate, singlebitB/s |
| writeRate | NUMERIC | magneticdiskcomposespeedrate, singlebitB/s |
| usage | NUMERIC | utilizeuserate(%) |
HOST\_NETWORK\_USAGE
HostsidesystemstatisticslevelcategoryofnetworknetworkI/OutilizeuserateData.
by--host-sys=networkopenrelatedControl.
table 51 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| timestampNs | NUMERIC | adoptsampletimeofthisregiontimebetween, singlebitns |
| usage | NUMERIC | utilizeuserate(%) |
| speed | NUMERIC | networknetworkUsagespeedrate, singlebitB/s |
OSRT\_API
HostsidesyscallandpthreadcallData.
by--host-sys=osrtopenrelatedControl.
table 52 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| name | INTEGER | OS Runtime APIInterfacename |
| globalTid | NUMERIC | oughtAPIallinlineprocessofGlobalTID. high32bit: PID, low32bit: TID |
| startNs | INTEGER | APIofopenbegintimebetween, singlebitns |
| endNs | INTEGER | APIofconclusionendtimebetween, singlebitns |
NETDEV\_STATS
throughexceedHardwareadoptsamplebandwidthwidthabilityforce, canin order topartdistributerecognizecategorythroughinformationaskproblem, astotalviewitem, initialsteparrangesearchthroughinformationaskproblem, ifoutputappearthroughinformationTime consumptiondifferentoften, immediatecanoptimizefirstarrangesearchiswhetherasnetworknetworkholdblockguideconsistent.
Controlopenrelated:
- msprofcommandcommandof--sys-io-profiling, --sys-io-sampling-freq
- Ascend PyTorch Profilerofsys\_io
- MindSpore Profilerofsys\_io
table 53 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| deviceId | INTEGER | DeviceID |
| timestampNs | INTEGER | adoptsampletimeofthisregiontimebetween, singlebitns |
| macTxPfcPkt | INTEGER | MACissuepresentofPFCframenumber |
| macRxPfcPkt | INTEGER | MACconnectreceiveofPFCframenumber |
| macTxByte | INTEGER | MACissuepresentofcharactersectionnumber |
| macTxBandwidth | NUMERIC | MACissuepresentbandwidthwidth, singlebitByte / s |
| macRxByte | INTEGER | MACconnectreceiveofcharactersectionnumber |
| macRxBandwidth | NUMERIC | MACconnectreceivebandwidthwidth, singlebitByte / s |
| macTxBadByte | INTEGER | MACissuepresentofbadPackagereportdocumentcharactersectionnumber |
| macRxBadByte | INTEGER | MACconnectreceiveofbadPackagereportdocumentcharactersectionnumber |
| roceTxPkt | INTEGER | RoCEEissuepresentofreportdocumentnumber |
| roceRxPkt | INTEGER | RoCEEconnectreceiveofreportdocumentnumber |
| roceTxErrPkt | INTEGER | RoCEEissuepresentofbadPackagereportdocumentnumber |
| roceRxErrPkt | INTEGER | RoCEEconnectreceiveofbadPackagereportdocumentnumber |
| roceTxCnpPkt | INTEGER | RoCEEissuepresentofCNPtypetypereportdocumentnumber |
| roceRxCnpPkt | INTEGER | RoCEEconnectreceiveofCNPtypetypereportdocumentnumber |
| roceNewPktRty | INTEGER | RoCEEissuepresentofexceedtimeweighttransferofnumberamount |
| nicTxByte | INTEGER | NICissuepresentofcharactersectionnumber |
| nicTxBandwidth | NUMERIC | NICissuepresentbandwidthwidth, singlebitByte / s |
| nicRxByte | INTEGER | NICconnectreceiveofcharactersectionnumber |
| nicRxBandwidth | NUMERIC | NICconnectreceivebandwidthwidth, singlebitByte / s |
RANK\_DEVICE\_MAP
rankIdanddeviceIdofreflectshootrelatedsystemData.
noCorrespondingopenrelated, guideoutputascend\_pytorch\_profiler\_\{Rank\_ID\}.dbfiletimesilentrecognizeGenerate.
table 54 formatformula
| characterparagraphname | typetype | containmeaning |
|---|---|---|
| rankId | INTEGER | getvaluesoliddefineas-1. |
| deviceId | INTEGER | sectionpointaboveofDeviceID, displayshowas-1timetableshownotCollectiontodeviceId. |
Troubleshooting
1. Database Issues
Issue: Database file not found
Symptom: Error: unable to open database
Solution:
# Find profiling database
find . -name "*.db" -o -name "msprof_*.db"
# Check file permissions
ls -la profiling.db
chmod 644 profiling.dbIssue: Database locked
Symptom: Error: database is locked
Solution:
# Close other connections
# Wait for other processes to finish
# Or use read-only mode
sqlite3 -readonly profiling.db "SELECT 1;"Issue: Invalid database format
Symptom: Error: file is not a database
Solution:
# Check file type
file profiling.db
# May need to use correct database from profiling output
ls -la OPPROF_*/profiling.db2. Schema Query Issues
Issue: Table not found
Symptom: Error: no such table
Solution:
# List available tables first
sqlite3 profiling.db ".tables"
# Check actual table names
sqlite3 profiling.db "SELECT name FROM sqlite_master WHERE type='table';"
# Verify get_schema.py table list
python3 scripts/get_schema.py --list_tablesIssue: Column not found
Symptom: Error: no such column
Solution:
# Get table schema
sqlite3 profiling.db ".schema TABLE_NAME"
# Use get_schema.py for reference
python3 scripts/get_schema.py --table_name TABLE_NAME
# Check exact column names
sqlite3 profiling.db "PRAGMA table_info(TABLE_NAME);"3. Query Execution Issues
Issue: Query returns no results
Possible Causes: 1. No matching data 2. WHERE condition too restrictive 3. JOIN condition incorrect
Solution:
# Test with simpler query first
sqlite3 profiling.db "SELECT COUNT(*) FROM TASK;"
# Check data exists
sqlite3 profiling.db "SELECT * FROM TASK LIMIT 1;"
# Verify JOIN keys
sqlite3 profiling.db "SELECT COUNT(*) FROM COMPUTE_TASK_INFO c JOIN TASK t ON c.globalTaskId = t.globalTaskId;"Issue: Query too slow
Solution:
# Add LIMIT
SELECT ... LIMIT 100;
# Use index hints if available
EXPLAIN QUERY PLAN SELECT ...
# Reduce date range
WHERE timestamp BETWEEN '2024-01-01' AND '2024-01-02'4. SQL Generation Issues
Issue: Generated SQL syntax error
Solution:
# Validate SQL syntax
sqlite3 profiling.db "EXPLAIN QUERY PLAN <your_sql>;"
# Check for typos
# Verify table and column names match schemaIssue: Missing aggregation
Solution:
# Ensure GROUP BY is used with aggregate functions
SELECT op_name, SUM(duration_ns) -- Need GROUP BY
FROM compute_view
GROUP BY op_name;Issue: Missing LIMIT
Solution:
# Add LIMIT to prevent large result sets
SELECT ...
ORDER BY total_ns DESC
LIMIT 20;5. Performance Issues
Issue: Full table scan
Solution:
# Check query plan
EXPLAIN QUERY PLAN SELECT ...
# Use appropriate indexes
# Limit date rangeIssue: Memory issues with large results
Solution:
# Increase LIMIT
# Use pagination
# Process in batchesQuick Diagnostic Commands
# Check database
file *.db
sqlite3 profiling.db ".tables"
# Check table size
sqlite3 profiling.db "SELECT COUNT(*) FROM TASK;"
# Test simple query
sqlite3 profiling.db "SELECT 1;"
# Get schema
python3 scripts/get_schema.py --table_name TASKCommon SQL Patterns
-- Top K operators by time
WITH compute_view AS (
SELECT c.globalTaskId, ROUND(t.endNs - t.startNs) AS duration_ns, n.value AS op_name
FROM COMPUTE_TASK_INFO c
LEFT JOIN TASK t ON t.globalTaskId = c.globalTaskId
LEFT JOIN STRING_IDS n ON n.id = c.name
)
SELECT op_name, SUM(duration_ns) AS total_ns, COUNT(*) AS call_count
FROM compute_view
GROUP BY op_name
ORDER BY total_ns DESC
LIMIT 20;
-- Communication time
WITH comm_view AS (
SELECT ROUND(c.endNs - c.startNs) AS duration_ns, n.value AS op_name
FROM COMMUNICATION_OP c
LEFT JOIN STRING_IDS n ON n.id = c.opName
)
SELECT op_name, SUM(duration_ns) AS total_ns
FROM comm_view
GROUP BY op_name
ORDER BY total_ns DESC
LIMIT 10;Verification Methods
Prerequisite Verification
1. Verify Database Files
# Check profiling database exists
ls -la *.db
ls -la msprof_*.db
# Verify database format
file profiling.db2. Verify sqlite3 CLI
# Check sqlite3 installation
sqlite3 --version
# Test basic query
sqlite3 profiling.db "SELECT 1;"3. Verify get_schema.py Script
# Check script exists
ls -la scripts/get_schema.py
# Test script help
python3 scripts/get_schema.py --helpFunctional Verification
1. List Available Tables
# Method 1: Using sqlite3
sqlite3 profiling.db ".tables"
# Method 2: Using get_schema.py
python3 scripts/get_schema.py --list_tables
# Method 3: Using SQL
sqlite3 profiling.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"2. Query Table Schema
# Get schema for specific table
python3 scripts/get_schema.py --table_name TASK
# Compare with actual database
python3 scripts/get_schema.py --db_path profiling.db --compare_doc_db3. Execute Query
# Using sqlite3 CLI for testing
sqlite3 profiling.db "
WITH compute_view AS (
SELECT c.globalTaskId, ROUND(t.endNs - t.startNs) AS duration_ns, n.value AS op_name
FROM COMPUTE_TASK_INFO c
LEFT JOIN TASK t ON t.globalTaskId = c.globalTaskId
LEFT JOIN STRING_IDS n ON n.id = c.name
)
SELECT op_name, SUM(duration_ns) AS total_ns
FROM compute_view
GROUP BY op_name
ORDER BY total_ns DESC
LIMIT 20;
"
# Save results to CSV
sqlite3 profiling.db <<EOF
.headers on
.mode csv
.output results.csv
-- Your SQL here
EOF4. Verify Query Results
# Check result row count
wc -l results.csv
# Preview results
head -20 results.csv
# Validate data types
python3 -c "
import csv
with open('results.csv') as f:
reader = csv.DictReader(f)
for row in reader:
print(row)
break
"End-to-End Verification Script
#!/bin/bash
set -e
DB="profiling.db"
echo "=== 1. Verify Prerequisites ==="
sqlite3 --version
test -f ${DB} && echo "Database exists"
echo "=== 2. List Tables ==="
sqlite3 ${DB} ".tables"
echo "=== 3. Get Schema ==="
python3 scripts/get_schema.py --list_tables
echo "=== 4. Execute Sample Query ==="
sqlite3 ${DB} "
WITH compute_view AS (
SELECT c.globalTaskId, ROUND(t.endNs - t.startNs) AS duration_ns, n.value AS op_name
FROM COMPUTE_TASK_INFO c
LEFT JOIN TASK t ON t.globalTaskId = c.globalTaskId
LEFT JOIN STRING_IDS n ON n.id = c.name
)
SELECT op_name, SUM(duration_ns) AS total_ns
FROM compute_view
GROUP BY op_name
ORDER BY total_ns DESC
LIMIT 5;
"
echo "=== All verifications passed ==="Verification Checklist
| Check | Expected Result |
|---|---|
| sqlite3 installed | Version displayed |
| Database exists | File readable |
| .tables works | List of table names |
| get_schema.py works | Schema output |
| SELECT 1 works | Returns 1 |
| CTE query works | Returns results |
| LIMIT works | Limited rows |
| CSV output works | Valid CSV format |
import argparse
import difflib
import os
import re
import sqlite3
import sys
from typing import Dict, List, Tuple
def _get_reference_doc_path() -> str:
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_dir, "references", "profiler_db_data_format.md")
def _load_reference_doc() -> Tuple[List[str], str]:
ref_path = _get_reference_doc_path()
try:
with open(ref_path, "r", encoding="utf-8") as f:
lines = f.read().splitlines()
except FileNotFoundError:
return [], f"❌ errorerror: notfindtoReference Documents {ref_path}"
except Exception as e:
return [], f"❌ errorerror: ReadReference Documentslossfailure: {str(e)}"
return lines, ""
def _normalize_title(title: str) -> str:
normalized = title.strip()
normalized = re.sub(r"<a\s+name=\"[^\"]+\"></a>", "", normalized, flags=re.IGNORECASE)
normalized = normalized.replace("\\_", "_")
normalized = normalized.replace("\\-", "-")
return normalized.strip()
def _canonical_key(name: str) -> str:
key = name.strip().upper()
key = key.replace("\\_", "_")
key = re.split(r"[\s( (]", key)[0]
return key
def _extract_sections(lines: List[str]) -> List[Dict[str, object]]:
sections: List[Dict[str, object]] = []
current_title = None
current_start = None
title_pattern = re.compile(r"^\*\*(.+?)\*\*$")
for idx, line in enumerate(lines):
matched = title_pattern.match(line.strip())
if not matched:
continue
title = _normalize_title(matched.group(1))
if current_title is not None and current_start is not None:
sections.append(
{
"title": current_title,
"start": current_start,
"end": idx,
}
)
current_title = title
current_start = idx
if current_title is not None and current_start is not None:
sections.append(
{
"title": current_title,
"start": current_start,
"end": len(lines),
}
)
return sections
def list_documented_tables() -> str:
lines, err = _load_reference_doc()
if err:
return err
sections = _extract_sections(lines)
names = []
for sec in sections:
title = sec["title"]
canonical = _canonical_key(title)
if re.fullmatch(r"[A-Z0-9_]+", canonical):
names.append(canonical)
if not names:
return "❌ notinReference DocumentsmiddleParsetotablename. "
unique_names = sorted(set(names))
return "\n".join(unique_names)
def _load_db_tables(db_path: str) -> Tuple[List[str], str]:
if not db_path:
return [], "❌ errorerror: db_path notabilityasempty. "
if not os.path.exists(db_path):
return [], f"❌ errorerror: db filenotkeepin: {db_path}"
try:
conn = sqlite3.connect(db_path)
try:
cursor = conn.execute(
"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
)
tables = [row[0] for row in cursor.fetchall() if row and row[0]]
finally:
conn.close()
except Exception as e:
return [], f"❌ errorerror: Read db tablenamelossfailure: {str(e)}"
return tables, ""
def list_db_tables(db_path: str) -> str:
tables, err = _load_db_tables(db_path)
if err:
return err
if not tables:
return f"❌ db middlenotfindtoanywhattable: {db_path}"
return "\n".join(tables)
def compare_doc_with_db(db_path: str) -> str:
doc_lines, err = _load_reference_doc()
if err:
return err
doc_sections = _extract_sections(doc_lines)
doc_tables = sorted(
{
_canonical_key(sec["title"])
for sec in doc_sections
if re.fullmatch(r"[A-Z0-9_]+", _canonical_key(sec["title"]))
}
)
db_tables, db_err = _load_db_tables(db_path)
if db_err:
return db_err
doc_set = set(doc_tables)
db_set = {_canonical_key(name) for name in db_tables}
both = sorted(doc_set & db_set)
only_doc = sorted(doc_set - db_set)
only_db = sorted(db_set - doc_set)
out = []
out.append("### Documentsandwhenprevious DB tablenameCompare")
out.append(f"- Documentstablenumber: {len(doc_set)}")
out.append(f"- DB tablenumber: {len(db_set)}")
out.append(f"- exchangeset: {len(both)}")
out.append("")
out.append("#### exchangesettable")
out.append("\n".join(both) if both else " (no) ")
out.append("")
out.append("#### onlyDocumentskeepin")
out.append("\n".join(only_doc) if only_doc else " (no) ")
out.append("")
out.append("#### onlyDBkeepin")
out.append("\n".join(only_db) if only_db else " (no) ")
return "\n".join(out)
def get_schema_by_table_name(table_name: str) -> str:
"""
rootdatatablenamefrom profiler_db_data_format.md liftgetCorrespondingchaptersectioninsidecontent.
:param table_name: tablename, exampleif TASK / CANN_API / COMMUNICATION_OP.
"""
if not table_name:
return "❌ errorerror: table_name notabilityasempty. "
lines, err = _load_reference_doc()
if err:
return err
sections = _extract_sections(lines)
if not sections:
return "❌ errorerror: Reference DocumentsmiddlenotParsetocanusechaptersection. "
query_key = _canonical_key(table_name)
exact_matches = []
key_to_title = {}
for sec in sections:
title = sec["title"]
title_key = _canonical_key(title)
key_to_title[title_key] = title
if title_key == query_key:
exact_matches.append(sec)
if not exact_matches:
candidates = sorted(set(key_to_title.keys()))
similar = difflib.get_close_matches(query_key, candidates, n=5, cutoff=0.5)
if similar:
tips = ", ".join(similar)
return f"❌ notfindtotable `{table_name}`. youcanabilitydesiresearch: {tips}"
return f"❌ notfindtotable `{table_name}`. canfirstExecute --list_tables searchseeDocumentsinsidecanusetablename. "
sec = exact_matches[0]
start = sec["start"]
end = sec["end"]
section_text = "\n".join(lines[start:end]).strip()
out_lines = []
out_lines.append("⚠️ ** [Track B tableStructureReference (from profiler_db_data_format.md) ] **")
out_lines.append(f"### tablename: `{_canonical_key(sec['title'])}`")
out_lines.append("")
out_lines.append(section_text)
return "\n".join(out_lines)
def main(argv=None):
parser = argparse.ArgumentParser(description="according totablenameQuery msprof db DocumentsmiddleoftableStructureDescription")
parser.add_argument(
"--db_path",
type=str,
help="canselect, itemstandard sqlite db Path; Used forcolumntablenameorDocuments/DB Compare",
)
parser.add_argument(
"--table_name",
type=str,
help="itemstandardtablename, exampleif TASK / CANN_API / COMMUNICATION_OP",
)
parser.add_argument(
"--list_tables",
action="store_true",
help="columnoutput profiler_db_data_format.md middlecanQueryoftablename",
)
parser.add_argument(
"--list_db_tables",
action="store_true",
help="columnoutputitemstandard db middleactualactualkeepinoftablename (needmatchmatch --db_path) ",
)
parser.add_argument(
"--compare_doc_db",
action="store_true",
help="CompareDocumentstablenameanditemstandard db tablename (needmatchmatch --db_path) ",
)
args = parser.parse_args(argv)
if args.list_db_tables:
if not args.db_path:
print("❌ errorerror: --list_db_tables requiressametimeProvides --db_path")
return
print(list_db_tables(args.db_path))
return
if args.compare_doc_db:
if not args.db_path:
print("❌ errorerror: --compare_doc_db requiressametimeProvides --db_path")
return
print(compare_doc_with_db(args.db_path))
return
if args.list_tables:
print(list_documented_tables())
return
if args.table_name:
print(get_schema_by_table_name(args.table_name))
return
print("❌ errorerror: pleaseProvides --table_name <tablename>, orUsage --list_tables")
if __name__ == "__main__":
main(sys.argv[1:])