Skip to main content

cannlog

用于浏览和解析 cannsim 仿真日志的本地 Web 可视化工具。后端给定日志目录启动,前端在浏览器中动态查看日志、访存数据和指令关联关系。

安装

从 PyPI 安装:

pip install cannlog

从源码安装:

pip install .

开发模式安装:

pip install -e .

安装后主命令是 cannlog:

cannlog /path/to/log_dir --host localhost --port 18000

也保留了兼容别名:cann-log-parser、cann-log-viewer。

也可以继续使用模块入口:

python -m cannlog.server /path/to/log_dir --host localhost --port 18000
python -m app.server /path/to/log_dir --host localhost --port 18000

打开:http://localhost:18000

默认 host 是 localhost,默认端口是 18000。如果不传 --port 且 18000 被占用,会自动尝试后续端口;如果显式传了 --port,端口被占用时会直接提示并退出。

远程机器上运行时:

  • 如果使用 VS Code Remote,可以在 Ports/端口 面板中转发服务提示的端口,然后点浏览器图标打开。
  • 如果没有 VS Code 端口转发功能,在本地终端建立 SSH 隧道:
ssh -N -L 18000:127.0.0.1:18000 <user>@<ip>

然后在本地浏览器打开:http://localhost:18000。如果服务自动切换到了其它端口,把命令里的 18000 换成实际提示的端口。

已支持的日志类型

  • 指令日志:*.instr_log.dump、*.instr_popped_log.dump
  • 访存日志:*.rd_log.dump、*.wr_log.dump
  • PV 访存日志:*rvec_pv.dump,按指令 ID 合并 Rd/Wr 数据块并支持解码
  • CCU/队列事件:*.ccu_log.dump、*issque.dump、*.OOO.dump
  • PMU/summary:*.perf_pmu.log、*.perf_pmu_per_vf.log、*summary_log

功能

  • 给定日志目录启动本地 Web 服务
  • 前端动态加载文件树和事件页,大日志分页读取
  • 访存日志按指令 ID 合并展示;PV 日志中同一指令下相同读写和寄存器会合并,不同读写或寄存器会分块展示
  • 支持 hex32、uint8/int8、uint16/int16/float16/bfloat16、uint32/int32/float32、uint64/int64/float64 解码
  • 按 instructionId 跨文件查询关联访存事件,并可跳转定位到具体事件
  • 支持分类、Core、Unit、文件名过滤
  • 支持多日志页签、右键菜单、新窗口打开、重载日志
  • 日志文件树和详情面板支持收起/展开

使用示例

cannlog /mnt/workspace/log/cann-sim/log_ca --host 0.0.0.0 --port 18000

打开:http://localhost:18000

API

  • GET /api/overview
  • GET /api/files
  • GET /api/file?path=...&page=1&pageSize=50
  • GET /api/stats?path=...
  • GET /api/instruction-memory?instructionId=4309
  • GET /api/decode-memory?path=core0.veccore0.ub.wr_log.dump&eventIndex=0&dtype=float32
  • POST /api/reload

打包发布到 PyPI

安装构建和上传工具:

python -m pip install build twine

构建源码包和 wheel:

python -m build

检查包元数据:

python -m twine check dist/*

上传到 TestPyPI:

python -m twine upload --repository testpypi dist/*

上传到正式 PyPI:

python -m twine upload dist/*

发布前建议:

  • 确认 pyproject.toml 中的 name = "cannlog" 没有被 PyPI 占用
  • 为每次发布递增 version
  • 许可证已在 LICENSE 和 pyproject.toml 中声明为 MIT

实现说明

  • 后端仅使用 Python 标准库,无运行时依赖
  • 前端为原生 HTML/CSS/JS,无需构建
  • 静态资源已作为 package data 打进 wheel,pip 安装后可直接运行

许可证

本项目使用 MIT License,详见 LICENSE。

Metadata

Release files for cannlog 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cannlog 0.1.13
File Size Uploaded Provenance Actions
cannlog-0.1.13.tar.gz 69.1 kB Without provenance Details for cannlog-0.1.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cannlog 0.1.13
File Interpreter ABI Platform Actions
cannlog-0.1.13-py3-none-any.whl Python 3 none any Details for cannlog-0.1.13-py3-none-any.whl

Total release size: 139.1 kB

Release files / cannlog-0.1.13.tar.gz

Download URL cannlog-0.1.13.tar.gz
Size 69.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6310af80ff58cb3fa2ce4b0834e4b97eccebbe71281d1c4742a7374723220f1c
BLAKE2b-256 checksum
How to use checksums
d2090a7d748b282c76993bf7bc680a9815469fc062782c12301609697b5abf38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.4

Release files / cannlog-0.1.13-py3-none-any.whl

Download URL cannlog-0.1.13-py3-none-any.whl
Size 70.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e79748b0bbd26d22bdc64d8ce77e2994bd2afe6c52f615c437a85851fc73ef4
BLAKE2b-256 checksum
How to use checksums
07d1389be93a4b092b5e34f373988ff42a3e1ee1211180b00f1767ffaa1f81a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.4

Security for cannlog 0.1.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page