pping-lang 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. pping_lang-0.1.0/.githooks/commit-msg +23 -0
  2. pping_lang-0.1.0/.githooks/pre-commit +23 -0
  3. pping_lang-0.1.0/.gitignore +67 -0
  4. pping_lang-0.1.0/AGENTS.md +26 -0
  5. pping_lang-0.1.0/CHANGELOG.md +160 -0
  6. pping_lang-0.1.0/CONTRIBUTING.md +85 -0
  7. pping_lang-0.1.0/LICENSE +201 -0
  8. pping_lang-0.1.0/PKG-INFO +550 -0
  9. pping_lang-0.1.0/README.en.md +301 -0
  10. pping_lang-0.1.0/README.md +304 -0
  11. pping_lang-0.1.0/docs/.nojekyll +0 -0
  12. pping_lang-0.1.0/docs/autopilot-quickstart.md +89 -0
  13. pping_lang-0.1.0/docs/index.html +1390 -0
  14. pping_lang-0.1.0/examples/embedded/demo.py +241 -0
  15. pping_lang-0.1.0/examples/embedded/run_real_vllm.sh +61 -0
  16. pping_lang-0.1.0/examples/embedded/run_vllm_020.sh +59 -0
  17. pping_lang-0.1.0/examples/embedded/stress_vllm.sh +55 -0
  18. pping_lang-0.1.0/examples/embedded/vllm_dashboard.py +110 -0
  19. pping_lang-0.1.0/pyproject.toml +104 -0
  20. pping_lang-0.1.0/scripts/setup-hooks.sh +28 -0
  21. pping_lang-0.1.0/src/pping_lang/__init__.py +18 -0
  22. pping_lang-0.1.0/src/pping_lang/api/__init__.py +11 -0
  23. pping_lang-0.1.0/src/pping_lang/api/queries.py +17 -0
  24. pping_lang-0.1.0/src/pping_lang/api/routes.py +1660 -0
  25. pping_lang-0.1.0/src/pping_lang/api/schemas.py +61 -0
  26. pping_lang-0.1.0/src/pping_lang/api/server.py +89 -0
  27. pping_lang-0.1.0/src/pping_lang/autopilot/__init__.py +14 -0
  28. pping_lang-0.1.0/src/pping_lang/autopilot/action_space.py +555 -0
  29. pping_lang-0.1.0/src/pping_lang/autopilot/agent.py +648 -0
  30. pping_lang-0.1.0/src/pping_lang/autopilot/api.py +299 -0
  31. pping_lang-0.1.0/src/pping_lang/autopilot/config_review.py +40 -0
  32. pping_lang-0.1.0/src/pping_lang/autopilot/kvfit.py +178 -0
  33. pping_lang-0.1.0/src/pping_lang/autopilot/objective.py +109 -0
  34. pping_lang-0.1.0/src/pping_lang/autopilot/promote.py +61 -0
  35. pping_lang-0.1.0/src/pping_lang/autopilot/repeat.py +47 -0
  36. pping_lang-0.1.0/src/pping_lang/autopilot/run.py +247 -0
  37. pping_lang-0.1.0/src/pping_lang/autopilot/runner.py +1128 -0
  38. pping_lang-0.1.0/src/pping_lang/autopilot/sandbox.py +572 -0
  39. pping_lang-0.1.0/src/pping_lang/autopilot/scorecard.py +86 -0
  40. pping_lang-0.1.0/src/pping_lang/autopilot/search.py +106 -0
  41. pping_lang-0.1.0/src/pping_lang/autopilot/session_store.py +307 -0
  42. pping_lang-0.1.0/src/pping_lang/autopilot/workload.py +77 -0
  43. pping_lang-0.1.0/src/pping_lang/bench/__init__.py +57 -0
  44. pping_lang-0.1.0/src/pping_lang/bench/client.py +195 -0
  45. pping_lang-0.1.0/src/pping_lang/bench/measurement.py +186 -0
  46. pping_lang-0.1.0/src/pping_lang/bench/microbench.py +175 -0
  47. pping_lang-0.1.0/src/pping_lang/bench/prompts/__init__.py +16 -0
  48. pping_lang-0.1.0/src/pping_lang/bench/prompts/data/__init__.py +1 -0
  49. pping_lang-0.1.0/src/pping_lang/bench/prompts/data/code.jsonl +35 -0
  50. pping_lang-0.1.0/src/pping_lang/bench/prompts/data/mixed-long.jsonl +15 -0
  51. pping_lang-0.1.0/src/pping_lang/bench/prompts/data/mixed-short.jsonl +40 -0
  52. pping_lang-0.1.0/src/pping_lang/bench/prompts/loader.py +102 -0
  53. pping_lang-0.1.0/src/pping_lang/bench/runner.py +247 -0
  54. pping_lang-0.1.0/src/pping_lang/bench/scenarios/__init__.py +8 -0
  55. pping_lang-0.1.0/src/pping_lang/bench/scenarios/schema.py +281 -0
  56. pping_lang-0.1.0/src/pping_lang/bench/store.py +272 -0
  57. pping_lang-0.1.0/src/pping_lang/cli.py +62 -0
  58. pping_lang-0.1.0/src/pping_lang/clock.py +21 -0
  59. pping_lang-0.1.0/src/pping_lang/collector/__init__.py +18 -0
  60. pping_lang-0.1.0/src/pping_lang/collector/cupti.py +1559 -0
  61. pping_lang-0.1.0/src/pping_lang/collector/nvml.py +187 -0
  62. pping_lang-0.1.0/src/pping_lang/collector/vllm_stats.py +190 -0
  63. pping_lang-0.1.0/src/pping_lang/engine_pcs.py +286 -0
  64. pping_lang-0.1.0/src/pping_lang/hardware.py +156 -0
  65. pping_lang-0.1.0/src/pping_lang/metrics_catalog.py +128 -0
  66. pping_lang-0.1.0/src/pping_lang/native/Makefile +31 -0
  67. pping_lang-0.1.0/src/pping_lang/native/README.md +99 -0
  68. pping_lang-0.1.0/src/pping_lang/native/__init__.py +1 -0
  69. pping_lang-0.1.0/src/pping_lang/native/builder.py +133 -0
  70. pping_lang-0.1.0/src/pping_lang/native/ppingcupti.cpp +726 -0
  71. pping_lang-0.1.0/src/pping_lang/native/ppingcupti.h +98 -0
  72. pping_lang-0.1.0/src/pping_lang/native/sass_source.py +262 -0
  73. pping_lang-0.1.0/src/pping_lang/otel/__init__.py +15 -0
  74. pping_lang-0.1.0/src/pping_lang/otel/sink.py +121 -0
  75. pping_lang-0.1.0/src/pping_lang/plugin.py +393 -0
  76. pping_lang-0.1.0/src/pping_lang/rules/__init__.py +23 -0
  77. pping_lang-0.1.0/src/pping_lang/rules/defaults.py +141 -0
  78. pping_lang-0.1.0/src/pping_lang/rules/diagnosis_config.py +137 -0
  79. pping_lang-0.1.0/src/pping_lang/rules/diagnosis_engine.py +85 -0
  80. pping_lang-0.1.0/src/pping_lang/rules/diagnosis_rules.py +167 -0
  81. pping_lang-0.1.0/src/pping_lang/rules/diagnosis_runtime.py +175 -0
  82. pping_lang-0.1.0/src/pping_lang/rules/engine.py +52 -0
  83. pping_lang-0.1.0/src/pping_lang/rules/loader.py +70 -0
  84. pping_lang-0.1.0/src/pping_lang/rules/operating_point.py +140 -0
  85. pping_lang-0.1.0/src/pping_lang/rules/schema.py +73 -0
  86. pping_lang-0.1.0/src/pping_lang/rules/store.py +113 -0
  87. pping_lang-0.1.0/src/pping_lang/sink/__init__.py +25 -0
  88. pping_lang-0.1.0/src/pping_lang/sink/base.py +293 -0
  89. pping_lang-0.1.0/src/pping_lang/sink/local.py +92 -0
  90. pping_lang-0.1.0/src/pping_lang/sink/metric_log.py +271 -0
  91. pping_lang-0.1.0/src/pping_lang/sink/tee.py +65 -0
  92. pping_lang-0.1.0/src/pping_lang/types.py +45 -0
  93. pping_lang-0.1.0/src/pping_lang/ui/__init__.py +1 -0
  94. pping_lang-0.1.0/src/pping_lang/ui/dashboard.css +2124 -0
  95. pping_lang-0.1.0/src/pping_lang/ui/dashboard.js +3013 -0
  96. pping_lang-0.1.0/src/pping_lang/ui/index.html +1917 -0
  97. pping_lang-0.1.0/src/pping_lang/ui/vendor/alpine.min.js +5 -0
  98. pping_lang-0.1.0/src/pping_lang/ui/vendor/chart.umd.min.js +20 -0
  99. pping_lang-0.1.0/tests/__init__.py +0 -0
  100. pping_lang-0.1.0/tests/test_api_bench.py +132 -0
  101. pping_lang-0.1.0/tests/test_api_routes.py +707 -0
  102. pping_lang-0.1.0/tests/test_api_rules_crud.py +203 -0
  103. pping_lang-0.1.0/tests/test_api_scaling.py +45 -0
  104. pping_lang-0.1.0/tests/test_api_server_lifecycle.py +54 -0
  105. pping_lang-0.1.0/tests/test_api_ui.py +427 -0
  106. pping_lang-0.1.0/tests/test_autopilot.py +2848 -0
  107. pping_lang-0.1.0/tests/test_bench_measurement.py +145 -0
  108. pping_lang-0.1.0/tests/test_bench_prompts.py +132 -0
  109. pping_lang-0.1.0/tests/test_bench_runner.py +117 -0
  110. pping_lang-0.1.0/tests/test_bench_schema.py +107 -0
  111. pping_lang-0.1.0/tests/test_bench_slo_spec.py +156 -0
  112. pping_lang-0.1.0/tests/test_bench_store.py +185 -0
  113. pping_lang-0.1.0/tests/test_bench_sweep.py +109 -0
  114. pping_lang-0.1.0/tests/test_collector_cupti.py +660 -0
  115. pping_lang-0.1.0/tests/test_collector_nvml.py +219 -0
  116. pping_lang-0.1.0/tests/test_collector_vllm.py +256 -0
  117. pping_lang-0.1.0/tests/test_diagnosis_config.py +117 -0
  118. pping_lang-0.1.0/tests/test_diagnosis_engine.py +95 -0
  119. pping_lang-0.1.0/tests/test_diagnosis_rules.py +142 -0
  120. pping_lang-0.1.0/tests/test_diagnosis_runtime.py +63 -0
  121. pping_lang-0.1.0/tests/test_e2e_marquee.py +101 -0
  122. pping_lang-0.1.0/tests/test_hardware.py +73 -0
  123. pping_lang-0.1.0/tests/test_metric_log.py +115 -0
  124. pping_lang-0.1.0/tests/test_metrics_catalog.py +108 -0
  125. pping_lang-0.1.0/tests/test_native_packaging.py +145 -0
  126. pping_lang-0.1.0/tests/test_operating_point.py +83 -0
  127. pping_lang-0.1.0/tests/test_otel_sink.py +126 -0
  128. pping_lang-0.1.0/tests/test_perf.py +47 -0
  129. pping_lang-0.1.0/tests/test_plugin_discovery.py +54 -0
  130. pping_lang-0.1.0/tests/test_plugin_sink_integration.py +102 -0
  131. pping_lang-0.1.0/tests/test_rules_defaults.py +58 -0
  132. pping_lang-0.1.0/tests/test_rules_loader.py +117 -0
  133. pping_lang-0.1.0/tests/test_rules_schema.py +48 -0
  134. pping_lang-0.1.0/tests/test_rules_store.py +148 -0
  135. pping_lang-0.1.0/tests/test_sink_base.py +173 -0
  136. pping_lang-0.1.0/tests/test_sink_local.py +119 -0
  137. pping_lang-0.1.0/tests/test_sink_tee.py +100 -0
  138. pping_lang-0.1.0/tests/test_types.py +76 -0
@@ -0,0 +1,23 @@
1
+ #!/bin/sh
2
+ # Strip any AI-assistant Co-Authored-By trailers from commit messages
3
+ # before they land. AI agents (Claude Code, Codex, Copilot, etc.) sometimes
4
+ # auto-insert these — once committed they make the bot show up as a
5
+ # GitHub contributor, and removing them later requires history rewrite.
6
+ #
7
+ # Activate once per clone: git config core.hooksPath .githooks
8
+ set -e
9
+
10
+ MSG_FILE="$1"
11
+ [ -z "$MSG_FILE" ] && exit 0
12
+
13
+ # Pattern: any Co-Authored-By line that names an AI assistant or its email
14
+ # domain. Case-insensitive. Extend the alternation list as new tools appear.
15
+ PATTERN='^Co-Authored-By:.*\(claude\|codex\|copilot\|anthropic\|openai\|noreply@anthropic\.com\|noreply@openai\.com\)'
16
+
17
+ if grep -qi "$PATTERN" "$MSG_FILE"; then
18
+ echo "[commit-msg hook] stripping AI-assistant Co-Authored-By trailer(s)"
19
+ # Portable in-place edit (avoids GNU sed -i / BSD sed -i '' divergence)
20
+ tmp="$(mktemp)"
21
+ grep -vi "$PATTERN" "$MSG_FILE" > "$tmp"
22
+ mv "$tmp" "$MSG_FILE"
23
+ fi
@@ -0,0 +1,23 @@
1
+ #!/bin/sh
2
+ # Refuse to commit anything under AI-assistant config directories. These
3
+ # directories belong on the developer's machine, not in shared history.
4
+ # .gitignore already excludes them; this hook is the second line of defense
5
+ # for the case where someone uses `git add -f` or for new tools we forgot
6
+ # to gitignore.
7
+ #
8
+ # Activate once per clone: git config core.hooksPath .githooks
9
+ set -e
10
+
11
+ # Staged paths matching any of these prefixes will be rejected.
12
+ BAD_PATTERN='^\(\.claude\|\.codex\|\.copilot\|\.cursor\|\.aider\|\.continue\)/'
13
+
14
+ STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep "$BAD_PATTERN" || true)
15
+ if [ -n "$STAGED" ]; then
16
+ echo "[pre-commit hook] refusing to commit AI-assistant local config:"
17
+ echo "$STAGED" | sed 's/^/ /'
18
+ echo
19
+ echo "These directories belong on your machine, not in git history."
20
+ echo "Unstage with: git restore --staged <path>"
21
+ echo "If you genuinely intend to track this file, bypass with --no-verify."
22
+ exit 1
23
+ fi
@@ -0,0 +1,67 @@
1
+ # Byte-compiled / optimized
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+
7
+ # Distribution / packaging
8
+ build/
9
+ dist/
10
+ *.egg-info/
11
+ *.egg
12
+ MANIFEST
13
+ *.whl
14
+ *.tar.gz
15
+
16
+ # Virtualenvs
17
+ .venv/
18
+ venv/
19
+ env/
20
+ ENV/
21
+
22
+ # Test / coverage
23
+ .pytest_cache/
24
+ .coverage
25
+ htmlcov/
26
+ .mypy_cache/
27
+ .ruff_cache/
28
+
29
+ # IDE
30
+ .vscode/
31
+ .idea/
32
+ *.swp
33
+ .DS_Store
34
+
35
+ # Claude Code local config — all of it stays out of git
36
+ .claude/
37
+
38
+ # Codex project-local handoff/secrets — machine-private, never committed
39
+ .codex/
40
+
41
+ # Other agent tool local config — machine-private, never committed
42
+ .agents/
43
+
44
+ # pping-lang runtime data
45
+ *.duckdb
46
+ *.duckdb.wal
47
+ .pping-lang/
48
+ /var/lib/pping-lang/
49
+
50
+ # logs
51
+ *.log
52
+ .gstack/
53
+
54
+ # Personal design notes — kept on disk for reference, never committed
55
+ _design-notes/
56
+ _scratch/
57
+ _autopilot-stress/
58
+
59
+ # Ad-hoc root-level debug/check scripts from working sessions — never committed
60
+ /check_*.py
61
+ /dump_events.py
62
+
63
+ # Deploy tooling for the runw GPU box — kept on disk for the deploy-runw skill,
64
+ # never committed (carries infra topology + tailnet addressing)
65
+ deploy/runw/
66
+ .kimi-code/skills/deploy-runw/
67
+ src/pping_lang/ui/_*.html
@@ -0,0 +1,26 @@
1
+ # pping-lang Agent Notes
2
+
3
+ Read the project-local imported Claude handoff first for Autopilot, runw, diagnosis-engine, and live GPU validation context:
4
+
5
+ - `.codex/memories/pping-lang-claude-handoff.md`
6
+
7
+ ## Key Local Docs
8
+
9
+ - `_design-notes/autopilot-自动调优agent-设计.md`
10
+ - `_design-notes/autopilot-任务清单.md`
11
+ - `deploy/runw/README.md`
12
+ - `.codex/skills/deploy-runw/SKILL.md`
13
+ - `.codex/skills/runw-diagnose/SKILL.md`
14
+ - `src/pping_lang/autopilot/`
15
+ - `src/pping_lang/rules/`
16
+
17
+ ## Working Notes
18
+
19
+ - Use explicit UTF-8 when reading Chinese markdown in PowerShell:
20
+ `Get-Content -LiteralPath '<path>' -Raw -Encoding UTF8`
21
+ - `deploy/runw/` is intentionally local/deploy-specific and ignored by Git.
22
+ - `.codex/` is intentionally project-local/private and ignored by Git; it contains migrated Claude handoff notes and local secrets.
23
+ - For "deploy to runw", "publish dashboard", or remote runw validation, read `.codex/skills/deploy-runw/SKILL.md` first. For "drive traffic / inspect diagnoses on runw", read `.codex/skills/runw-diagnose/SKILL.md` first.
24
+ - runw is the live GPU validation machine: RTX 5060 Ti 16GB, vLLM 0.21, default model `Qwen/Qwen2.5-0.5B-Instruct`.
25
+ - runw deployment intentionally avoids `--enforce-eager` so validation follows the production CUDA graph path; keep `--enable-mfu-metrics` for diagnosis.
26
+ - Autopilot M0 is mostly implemented and true-run validated; known remaining gaps are resume, D/capacity-wall end-to-end with a larger model, `applies_to` completion, mid-bench budget interruption, explicit teardown verification, constraint/live-effective-config completion, and T2 equivalence checks.
@@ -0,0 +1,160 @@
1
+ # Changelog
2
+
3
+ 按 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格,遵循 SemVer。
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.1.0] — 2026-07-27
8
+
9
+ 正式版:跳出 alpha。诊断引擎重写成规则决策树、Autopilot 从 0 到 M0+M1(诊断驱动自主调优的旗舰能力)、
10
+ 全站中英双语、GitHub Pages 展示站、PC Sampling 稳定性修复。
11
+
12
+ ### Added
13
+
14
+ **诊断引擎重写**
15
+ - FactRule 决策树 schema + 10 条内置规则(四大瓶颈:算力 / 带宽 / 容量 / 空载守卫)
16
+ - 纯规则求值核心(precondition guard、any/all、ratio、regime gate)
17
+ - 无 `perf_stats` 时的 analytical operating point(regime / MFU / AI 推算,不依赖 vLLM 0.20+)
18
+ - `DiagnosisEngine` 运行时接入插件(默认启用,legacy DuckDB RuleEngine 下线)
19
+ - 自定义规则复用同一 DiagnosisEngine;规则配置改成弹窗表单
20
+
21
+ **Sink 与持久化**
22
+ - JSONL 持久化取代 DuckDB 存储;规则求值直接读内存 ring,DuckDB 移出诊断热路径
23
+ - Sink 背压下自适应降采样,替代原先的尾部无序丢弃
24
+
25
+ **Autopilot —— 旗舰能力,从无到有(M0 + M1)**
26
+ - 沙盒化诊断驱动自动调优 Agent:观察诊断 → 假设一个参数 → 压测验证 → 留下 / 回滚
27
+ - 支持 OpenAI 兼容 / Anthropic / Kimi Coding 三种 Agent 供应商;真流式(SSE)调用,替代阻塞式整段等待
28
+ - 6 种业务负载形态(chat / RAG / agent / reasoning / code / custom)一键给出匹配的压测负载与 SLA 默认值
29
+ - E2E p99 SLA 从硬性关卡改为仅监控(TTFT / TPOT 仍卡关,避免因通用默认值不合模型实际而误判"无改善")
30
+ - session 结束给结构化摘要:因果链叙述 + 逐轮账本(每个参数的 from→to、判定、Δ)
31
+ - 全中英双语(Agent 应答语言可配置、UI 全量 i18n),支持随时中断
32
+ - 一大批真机 dogfood 修复:waiting 队列作为 load-binding 判据、agent HTTP 调用重试退避、
33
+ Kimi max_tokens 避免 thinking 饿死输出、vLLM 硬拒绝的 knob 不再提议、p99 延迟按 median-of-N 去噪、
34
+ session 边界正确性、baseline 失败自愈
35
+
36
+ **UI / i18n**
37
+ - 全站 i18n 框架(中 / 英切换),KPI / Kernel / Bench / Rules / Autopilot 全量翻译
38
+ - Linear 风格主题(冷灰 + 靛蓝)+ sticky tabs
39
+ - GitHub Pages 双语展示站(`docs/index.html`),含实测 runw 数据与 Autopilot 真机轨迹
40
+
41
+ ### Changed
42
+ - "规则决策树"改名为"规则"(去掉不必要的术语包装)
43
+ - Autopilot 启动按钮改名为"执行"(更准确描述动作)
44
+
45
+ ### Fixed
46
+ - PC Sampling:禁用会在 Blackwell + CUDA 13 上与在飞推理死锁的 reprime 自愈机制
47
+ - 指标 / 诊断时间戳改存墙钟而非单调钟(避免跨进程 / 重启后时间线错位)
48
+ - `/api/diagnoses` 按 `rule_id` 去重
49
+ - Autopilot 大量正确性修复(详见上)及 dashboard 面板的一系列展示 / 状态 bug
50
+
51
+ ### Tests
52
+ - 测试数从 209 增至 612
53
+
54
+ ## [0.1.0a1] — 2026-06-14
55
+
56
+ 首个 alpha。第 1-3 周采集/诊断/Sink 完成后,继续做完 CUPTI kernel 级剖析(阶段 1a/2/3)、
57
+ 压测闭环、dashboard 诊断面板与 pip 一键打包。
58
+
59
+ ### Added
60
+
61
+ **采集与派生**(Day 1-3)
62
+ - vLLM `stat_logger_plugins` entry point + `PpingLangStatLogger`
63
+ - NVML 周期采样(util / mem / power / temp / sm/mem clock,按 GPU index 区分)
64
+ - vLLM SchedulerStats / IterationStats / FinishedRequestStats 完整字段映射
65
+ - cudagraph_stats / perf_stats 派生指标:**`padding_ratio`** / **`mfu_ratio`** / **`mem_bw_util_ratio`**
66
+ - 16 款常见 GPU 的 BF16 peak FLOPs + 内存带宽常量表(hardware.py)
67
+
68
+ **诊断**(Day 4 / Day 9)
69
+ - 微型 DSL(10 字段 Rule + Condition),加载时校验 metric ∈ catalog
70
+ - 10 条内置规则覆盖 6 个 category,含 marquee `high-cudagraph-padding` + `low-mfu`
71
+ - 周期 SQL 评估(DuckDB QUANTILE_CONT 支持 p50/p95/p99)
72
+ - 触发即终端打印 + 推 Diagnosis 到 sink
73
+ - 抑制窗口避免重复告警
74
+ - **规则热加载**:CRUD 后下次评估即生效,无需重启 vLLM
75
+
76
+ **Sink 与存储**(Day 2 / Day 11)
77
+ - Fire-and-forget Sink ABC,push <5μs(实测 156ns)
78
+ - LocalSink → DuckDB(schema 含 instance_id + gpu_idx)
79
+ - TeeSink fan-out 多 sink 并联
80
+ - OTelSink → OTLP gRPC(metric 名 `pping_lang.<name>`,含 engine_idx + gpu_idx attrs)
81
+
82
+ **HTTP API + UI**(Day 6-8)
83
+ - 14 个端点:health / metrics (available/recent/snapshot) / diagnoses / rules CRUD / rule test / report / instances
84
+ - 单文件 HTML dashboard(Alpine.js + Chart.js via CDN,~12KB)
85
+ - 三 tab:实时(KPI + chart + 诊断卡片)、规则(CRUD 表单 + inline 测试)、报告
86
+
87
+ **报告**(Day 10)
88
+ - 单 HTML 文件含 Executive Summary / 关键问题 / 趋势 / 配置审计 / Roofline / 规则汇总
89
+ - Plotly via CDN 默认(~30KB),inline 选项(~3.5MB 邮件离线)
90
+ - Roofline 散点 + 理论上界折线(compute roof + memory bandwidth roof)
91
+ - 配置审计含 4 条启发式建议(batch / prefix cache / KV / padding)
92
+
93
+ **性能**(Day 12)
94
+ - 微基准:push_metric 156ns mean,collect 22μs,record 12μs
95
+ - CI regression test 守 hot path 预算
96
+ - 自我观测指标:`pping_lang.overhead.record_us` / `rule_eval_ms` / `sink.dropped_total`
97
+
98
+ **CUPTI kernel 级剖析**(阶段 1a)
99
+ - 注入式 `.so`(`CUDA_INJECTION64_PATH`)抢占 CUPTI subscriber,避开 PyTorch Kineto 冲突
100
+ - Activity API per-kernel GPU 时间分解 + 算子分类(gemm / attention / comm / norm / activation / …)
101
+ - Kernel tab:占比、主导 stall、CUDA Graph 覆盖率、launch 频率、自身开销(cb_ms / dropped)
102
+ - 服务端 findings:compute-bound / launch-bound / memcpy 开销 / CUDA Graph 覆盖低 等结论
103
+
104
+ **PC Sampling**(阶段 2)
105
+ - SASS 指令 + stall reason 采样,库内预聚合(不全量回流,守 5% 开销)
106
+ - 多进程 `vllm serve` 工作:EngineCore 进程驱动 PC sampling + 跨进程共享 JSON 回流前端
107
+ - Deep Evidence 面板:warp 三态、全局 stall 分解、PerfWorks 原始 reason 下钻、测量方法卡
108
+ - 按需触发 5–30s 采样的深度分析端点
109
+
110
+ **行级归因**(阶段 3,对标 zymtrace 阶段 2)
111
+ - PC → 源码行 / SASS 热点双轨;源码行显示该行 Python 原文
112
+ - kernel → Python launch 栈(向外归因 MVP),派发器噪音清洗后露出真算子名(addmm/mm/linear)
113
+ - decode 覆盖 cuBLAS GEMV / FlashInfer 采样;区分 `_ZN` mangled vs Triton
114
+
115
+ **Roofline 调优地图**(P0-C 实测闭环)
116
+ - 一键压测扫并发,实测 scaling 曲线叠加理论 envelope(外推 → 实测)
117
+ - scaling verdict 用扩展效率口径(相对基线加速比 / 理想加速比,eff<70% = 收益递减点)
118
+ - 散点聚合成簇心 + operating point / batch scaling envelope / ridge point 语义标签
119
+
120
+ **压测**(bench)
121
+ - OpenAI 协议静态压测(chat / completions)+ SLO 校验,结果落 DuckDB 可回看
122
+ - 并发 sweep(CLI)
123
+ - 任选两条 run 逐指标 A/B/Δ% 对比 + 图表化对比面板(每卡 A/B 双横条 + Δ% 优劣徽标)
124
+
125
+ **打包与硬件**
126
+ - `pping-vllm serve <model>` 一条命令,`.so` 现编(cu12/cu13 自适应,编不出自动降级)
127
+ - roofline 峰值改从 CUDA 设备属性现读现算(`read_gpu_peak`),回退型号表 / env
128
+ - GPU 名现读 `torch.cuda.get_device_name` + 可选部署标签(`PPING_DEPLOY_TAG`)
129
+
130
+ **Dashboard 演进**
131
+ - Kernel tab 扩成完整诊断面板;HTTP API 扩到 36 端点(含 kernels / deep_evidence / roofline / scaling_sweep / bench)
132
+ - KPI 卡 + TTFT/TPOT 分位分布条 + 用户延迟趋势(平均为主、p99 退为浅线参考)
133
+
134
+ ### Changed
135
+ - 项目命名从 `llmprof` 改为 `pping-lang`(PyPI 名带连字符,Python 模块带下划线)
136
+ - roofline 从「分类器」升级为「调优地图」:operating point + batch scaling envelope,文案改工程口吻
137
+ - 用户延迟趋势 / TTFT·TPOT 改以平均为主显,p50/p95/p99 退为分布/参考
138
+
139
+ ### Fixed
140
+ - cudagraph 采样:HW 缓冲溢出会永久楔死 CUPTI 会话 → 默认周期 2^12→2^16;capture 打断早 prime 采样 → 检测空窗自愈 reprime
141
+ - correlate 拼 `dirName`+`fileName` 成全路径(否则只得 basename,读不到源码原文)
142
+ - UI no-cache(`dashboard.js` / `css` / `index.html`,防 F5 复用旧版致新功能不渲染)
143
+ - Deep Evidence findings 卡片黏连(`x-show` 与内联 `display:flex` 同元素冲突,拆两层)
144
+
145
+ ### Tests
146
+ - 初版 209 测试(采集 / 诊断 / Sink / API CRUD / e2e marquee / 性能 regression)
147
+ - 后续新增覆盖:bench(runner / schema / SLO / sweep / store / prompts)、CUPTI collector、scaling、API server 生命周期
148
+
149
+ ---
150
+
151
+ 模板(未来 release):
152
+
153
+ ## [0.x.0] — YYYY-MM-DD
154
+
155
+ ### Added
156
+ ### Changed
157
+ ### Deprecated
158
+ ### Removed
159
+ ### Fixed
160
+ ### Security
@@ -0,0 +1,85 @@
1
+ # Contributing to pping-lang
2
+
3
+ 谢谢关注!项目在 v0.1 阶段快速演进,欢迎 issue / PR。
4
+
5
+ ## 开发环境
6
+
7
+ ```bash
8
+ git clone https://github.com/leon/pping-lang.git
9
+ cd pping-lang
10
+ pip install -e ".[dev]"
11
+ pytest
12
+ ```
13
+
14
+ vLLM 不是 dev 必须依赖(plugin.py 有 fallback),但要测真实集成需要:
15
+
16
+ ```bash
17
+ pip install -e ".[dev,vllm]"
18
+ ```
19
+
20
+ ## 项目结构
21
+
22
+ ```
23
+ pping_lang/
24
+ ├── plugin.py # vLLM stat_logger entry point + 生命周期
25
+ ├── types.py # MetricPoint / Diagnosis (frozen + slots)
26
+ ├── metrics_catalog.py # 单一 metric 名常量源 + ALLOWED_METRICS
27
+ ├── hardware.py # GPU peak FLOPs / 带宽表
28
+ ├── collector/ # NVML + vLLM stats → MetricPoint
29
+ ├── sink/ # base ABC + Local (DuckDB) / Tee / (v0.2 Remote)
30
+ ├── rules/ # schema / defaults / loader / store / engine
31
+ ├── api/ # FastAPI app + routes + queries
32
+ ├── otel/ # OTLP exporter sink
33
+ ├── report/ # HTML 报告生成 (Jinja2 + Plotly)
34
+ ├── ui/ # 单文件 dashboard HTML
35
+ └── bench/ # 微基准
36
+ ```
37
+
38
+ ## 提交规范
39
+
40
+ - commit message 中文/英文都行;用第一行简洁概括(< 72 字符)
41
+ - 重要改动加 body 解释为什么(不只是做了什么)
42
+ - 测试通过再提:`pytest -q`
43
+ - 改 hot path 的提交必须跑:`pytest tests/test_perf.py -v`
44
+
45
+ ## 写测试
46
+
47
+ 新代码必须配套测试。看现有测试找风格:
48
+ - 单元测试:`tests/test_<module>.py`
49
+ - 集成测试:用真 LocalSink + 临时 DuckDB(`tmp_path` fixture)
50
+ - e2e:`tests/test_e2e_marquee.py` 跑完整数据流
51
+ - 性能 regression:`tests/test_perf.py` 守预算
52
+
53
+ UI 改动**必须** headless 浏览器实地验:
54
+
55
+ ```bash
56
+ DEMO_DURATION_S=600 python examples/embedded/demo.py &
57
+ # 然后用 browse / playwright / 手动浏览器看 http://localhost:8765
58
+ ```
59
+
60
+ 类似 Chart.js × Alpine.js proxy 冲突这种 bug 单元测试覆盖不到,必须真渲染。
61
+
62
+ ## 加新 metric
63
+
64
+ 1. 加常量到 `pping_lang/metrics_catalog.py:M`
65
+ 2. 命名守卫测试(`test_metrics_catalog.py`)会自动覆盖
66
+ 3. 在 collector 里 emit
67
+ 4. 如有派生计算,单元测试覆盖
68
+
69
+ ## 加新规则
70
+
71
+ 写在 `pping_lang/rules/defaults.py:DEFAULT_RULES`,跑:
72
+
73
+ ```bash
74
+ pytest tests/test_rules_defaults.py -v
75
+ ```
76
+
77
+ 模板渲染、metric ∈ catalog、字段完整性都自动验。
78
+
79
+ ## 设计决策记录
80
+
81
+ 大改动看:
82
+ - [docs/pping-lang-design-v0.2.md](docs/pping-lang-design-v0.2.md) — 整体设计
83
+ - [docs/pping-lang-pre-impl-rfc.md](docs/pping-lang-pre-impl-rfc.md) — 5 项关键决策的来龙去脉
84
+
85
+ 新增"为什么这么写"的设计决策应记录到 RFC 或新 ADR 文档。
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Leon
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.