dsh-runnpu 0.1.0

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -0
  3. package/compute-mode/preset/agent.cordis.yml +368 -0
  4. package/compute-mode/preset/preset.yml +3 -0
  5. package/compute-mode/preset/skills/runnpu/SKILL.md +233 -0
  6. package/compute-mode/preset/skills/runnpu/VENDOR.txt +11 -0
  7. package/compute-mode/preset/skills/runnpu/examples/01-dev-environment.sh +26 -0
  8. package/compute-mode/preset/skills/runnpu/examples/02-training-job.sh +26 -0
  9. package/compute-mode/preset/skills/runnpu/examples/03-inference-service.sh +24 -0
  10. package/compute-mode/preset/skills/runnpu/examples/04-fractional-vnpu.sh +14 -0
  11. package/compute-mode/preset/skills/runnpu/examples/05-troubleshoot.sh +17 -0
  12. package/compute-mode/preset/skills/runnpu/references/admin.md +60 -0
  13. package/compute-mode/preset/skills/runnpu/references/data-sources.md +35 -0
  14. package/compute-mode/preset/skills/runnpu/references/templates-assets.md +61 -0
  15. package/compute-mode/preset/skills/runnpu/references/training-runs.md +56 -0
  16. package/compute-mode/preset/skills/runnpu/references/troubleshooting.md +75 -0
  17. package/compute-mode/preset/skills/runnpu/references/workload-types.md +47 -0
  18. package/cordis.patch.yml +80 -0
  19. package/dist/chunk-JLZMOSQC.mjs +1 -0
  20. package/dist/chunk-JUBIWGKW.mjs +4 -0
  21. package/dist/chunk-JZXLCA2E.mjs +1 -0
  22. package/dist/chunk-KQOFBYGE.mjs +9 -0
  23. package/dist/chunk-XMZG2NP7.mjs +2 -0
  24. package/dist/chunk-XQPU3AJN.mjs +1 -0
  25. package/dist/chunk-YKASEMP3.mjs +1 -0
  26. package/dist/chunk-YPL4VUYF.mjs +4 -0
  27. package/dist/compute-node.mjs +1 -0
  28. package/dist/compute-tools.mjs +41 -0
  29. package/dist/connectors.mjs +3 -0
  30. package/dist/dsh-runnpu.mjs +43 -0
  31. package/dist/json.mjs +1 -0
  32. package/dist/pins.mjs +1 -0
  33. package/dist/series.mjs +1 -0
  34. package/dist/training-node.mjs +2 -0
  35. package/dist/training-tools.mjs +30 -0
  36. package/dist/ui-host.mjs +1 -0
  37. package/lib/client.js +189 -0
  38. package/package.json +78 -0
  39. package/training-mode/preset/agent.cordis.yml +343 -0
  40. package/training-mode/preset/preset.yml +3 -0
  41. package/training-mode/preset/skills/runnpu/SKILL.md +233 -0
  42. package/training-mode/preset/skills/runnpu/VENDOR.txt +11 -0
  43. package/training-mode/preset/skills/runnpu/examples/01-dev-environment.sh +26 -0
  44. package/training-mode/preset/skills/runnpu/examples/02-training-job.sh +26 -0
  45. package/training-mode/preset/skills/runnpu/examples/03-inference-service.sh +24 -0
  46. package/training-mode/preset/skills/runnpu/examples/04-fractional-vnpu.sh +14 -0
  47. package/training-mode/preset/skills/runnpu/examples/05-troubleshoot.sh +17 -0
  48. package/training-mode/preset/skills/runnpu/references/admin.md +60 -0
  49. package/training-mode/preset/skills/runnpu/references/data-sources.md +35 -0
  50. package/training-mode/preset/skills/runnpu/references/templates-assets.md +61 -0
  51. package/training-mode/preset/skills/runnpu/references/training-runs.md +56 -0
  52. package/training-mode/preset/skills/runnpu/references/troubleshooting.md +75 -0
  53. package/training-mode/preset/skills/runnpu/references/workload-types.md +47 -0
  54. package/training-mode/preset/skills/swanlab-skill/LICENSE +21 -0
  55. package/training-mode/preset/skills/swanlab-skill/SKILL.md +163 -0
  56. package/training-mode/preset/skills/swanlab-skill/VENDOR.txt +9 -0
  57. package/training-mode/preset/skills/swanlab-skill/references/ANALYSIS_GUIDE.md +83 -0
  58. package/training-mode/preset/skills/swanlab-skill/references/CLI_REFERENCE.md +510 -0
  59. package/training-mode/preset/skills/swanlab-skill/references/SDK_QUICKSTART.md +341 -0
  60. package/training-mode/preset/skills/swanlab-skill/references/SWANLAB_CONCEPTS.md +523 -0
  61. package/training-mode/preset/skills/swanlab-skill/scripts/plot_metrics.py +353 -0
  62. package/training-mode/preset/skills/swanlab-skill/scripts/runs_benchmark.py +550 -0
  63. package/training-mode/preset/skills/training-research/SKILL.md +33 -0
  64. package/training-mode/preset/skills/training-research/references/pipeline.md +45 -0
  65. package/training-mode/preset/skills/training-research/references/research.md +76 -0
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: swanlab-skill
3
+ metadata:
4
+ version: "0.3.0"
5
+ description: >
6
+ Interact with SwanLab — both writing tracking code (init/log/finish/multimedia) and querying
7
+ experiment data via CLI (`swanlab api`). Use this skill when the user wants to write training
8
+ tracking code, log metrics or media, manage experiments, inspect metrics/logs/keys, list
9
+ projects/runs, filter experiments, manage self-hosted users, automate queries via CLI, or
10
+ mentions "swanlab", "experiment tracking", "log metrics", "swanlab api", "swanlab cli".
11
+ ---
12
+
13
+ # SwanLab Skill
14
+
15
+ SwanLab is an AI training experiment tracking platform. This skill covers two usage patterns:
16
+
17
+ - **Writing tracking code** — use the Python SDK (`swanlab.init`, `swanlab.log`, `swanlab.finish`, media helpers)
18
+ - **Reading experiment data** — use the `swanlab api` CLI to query metrics, logs, summaries, media, etc.
19
+
20
+ ---
21
+
22
+ ## Reference Routing
23
+
24
+ | If the user wants to... | Read this reference |
25
+ | ---------------------------------------------------------------------- | -------------------------------- |
26
+ | Write tracking code (init/log/finish/media) | `references/SDK_QUICKSTART.md` |
27
+ | Query data via CLI (metrics/summary/logs/filter/etc.) | `references/CLI_REFERENCE.md` |
28
+ | Understand data model / terminology / filter syntax | `references/SWANLAB_CONCEPTS.md` |
29
+ | Analyze runs/projects, compare experiments, write an experiment report | `references/ANALYSIS_GUIDE.md` |
30
+ | Plot metrics or compare experiments visually | See **Scripts** below |
31
+
32
+ > **Version note (SDK ≥ 0.9.0)**: use `swanlab api run series` to discover an experiment's metric keys. `run column` / `run columns` are deprecated since `0.9.0` and do not apply to multi-view experiments — only fall back to them when the installed SDK is `< 0.9.0`. See `CLI_REFERENCE.md > Version Applicability`.
33
+
34
+ ---
35
+
36
+ ## Run Modes
37
+
38
+ `swanlab.init(mode=...)` controls where data goes:
39
+
40
+ | Mode | Local Storage | Cloud Upload | Use Case |
41
+ | ---------- | -------------- | -------------------------------------- | ------------------------------------ |
42
+ | `online` | Yes (protobuf) | Yes (Transport → HTTP) | Normal cloud usage. Requires login. |
43
+ | `local` | Yes (protobuf) | No | Air-gapped / no account needed. |
44
+ | `offline` | Yes (protobuf) | No (syncable later via `swanlab sync`) | Save locally, upload to cloud later. |
45
+ | `disabled` | No | No | Completely disable all logging. |
46
+
47
+ Default is `online` if logged in; otherwise an interactive prompt offers login, registration, or `offline`. In non-interactive environments without an API key, init raises an error instead of falling back.
48
+
49
+ ---
50
+
51
+ ## Scripts
52
+
53
+ Two helper scripts are available for visualizing experiment data:
54
+
55
+ ### `scripts/plot_metrics.py` — Single Experiment Line Chart
56
+
57
+ Trigger when the user wants to **visualize scalar metrics from one experiment** (e.g. "plot my loss curve", "show training metrics chart").
58
+
59
+ ```bash
60
+ python scripts/plot_metrics.py username/project_name/run_id --keys loss,acc
61
+ python scripts/plot_metrics.py user/proj/run1 -k loss -o loss_chart.png -s 500
62
+ python scripts/plot_metrics.py --data metrics.json -k loss,acc -o chart.png # from saved JSON
63
+ ```
64
+
65
+ ### `scripts/runs_benchmark.py` — Cross-Experiment Comparison
66
+
67
+ Trigger when the user wants to **compare the same metric across multiple experiments** (e.g. "compare loss across runs", "benchmark these experiments").
68
+
69
+ ```bash
70
+ python scripts/runs_benchmark.py user/proj/run1 user/proj/run2 user/proj/run3 -k loss
71
+ python scripts/runs_benchmark.py user/proj/run1 user/proj/run2 -k loss --direction lower
72
+ python scripts/runs_benchmark.py user/proj/run1 user/proj/run2 -k loss,acc --normalize
73
+ python scripts/runs_benchmark.py --data benchmark_data.json -k loss # from saved JSON
74
+ ```
75
+
76
+ Both scripts require `swanlab login` (or `--api-key` / `--host` flags).
77
+
78
+ ---
79
+
80
+ ## Path Convention
81
+
82
+ CLI commands use `username/project_name` (project) or `username/project_name/run_id` (experiment). See `SWANLAB_CONCEPTS.md > Path Convention` for details.
83
+
84
+ ---
85
+
86
+ ## Quick Disambiguation
87
+
88
+ | User says... | They probably mean... | Route |
89
+ | ------------------------------------------------ | ------------------------ | ----------------------------------------- |
90
+ | "track my training" / "log metrics" | Write tracking code | `SDK_QUICKSTART.md` |
91
+ | "log images/audio/text" | Log media data | `SDK_QUICKSTART.md` |
92
+ | "my loss curve" / "experiment metrics" | Query scalar data | `CLI_REFERENCE.md > run metrics` |
93
+ | "filter experiments" | Query by conditions | `CLI_REFERENCE.md > run filter` |
94
+ | "my experiments" / "list runs" | List experiments | `CLI_REFERENCE.md > run list` |
95
+ | "compare runs visually" | Cross-experiment chart | `scripts/runs_benchmark.py` |
96
+ | "plot metric chart" | Single-experiment chart | `scripts/plot_metrics.py` |
97
+ | "experiment config" | Hyperparameters | `CLI_REFERENCE.md > run info` |
98
+ | "console output" | Captured logs | `CLI_REFERENCE.md > run logs` |
99
+ | "what metrics are tracked" | Metric keys | `CLI_REFERENCE.md > run series` |
100
+ | "check connectivity" / "can I reach swanlab" | Environment check | `swanlab ping` |
101
+ | "check login status" / "am I logged in" | Verify credentials | `swanlab verify` |
102
+ | "project not found" / a query returns 404 | Wrong host (most likely) | `CLI_REFERENCE.md > Troubleshooting` |
103
+ | run fields / run list or run info response | Run object schema | `SWANLAB_CONCEPTS.md > Run Object Schema` |
104
+ | "analyze this project/run" / "experiment report" | Analysis pipeline | `ANALYSIS_GUIDE.md` |
105
+
106
+ ---
107
+
108
+ ## Environment Connectivity
109
+
110
+ Before writing tracking code or running CLI queries, especially in `online` mode, run these two checks to confirm the environment is ready:
111
+
112
+ ### 1. `swanlab ping` — Test network reachability
113
+
114
+ The fastest way to diagnose connectivity issues. Run it first when a user reports upload failures, login problems, or unknown mode fallbacks.
115
+
116
+ ```bash
117
+ swanlab ping
118
+ # Reports: API host, web host, latency, and login status.
119
+ # If ping fails, check SWANLAB_API_HOST / network proxy / firewall settings.
120
+ ```
121
+
122
+ ### 2. `swanlab verify` — Validate login credentials
123
+
124
+ After confirming the server is reachable, use `swanlab verify` to check that stored credentials are valid and have not expired. This reads the API key and host from the local `.netrc` file (created by `swanlab login`).
125
+
126
+ ```bash
127
+ swanlab verify
128
+ # Validates stored API key against the server.
129
+ # Reports: which host (default https://swanlab.cn) and the logged-in username.
130
+ # Fails if: not logged in, API key is invalid, or key has expired.
131
+
132
+ swanlab verify --local
133
+ # Check local login status (.swanlab in current directory) instead of the global one.
134
+ ```
135
+
136
+ **Recommended pre-flight sequence**:
137
+
138
+ 1. `swanlab ping` → confirm the server is reachable
139
+ 2. `swanlab verify` → confirm credentials are valid, and **note which host you are logged into**
140
+ 3. **Confirm the target project lives on that host.** SwanLab has multiple independent instances (public `swanlab.cn` + self-hosted deployments) and credentials are per-instance — see `SWANLAB_CONCEPTS.md > Instances, Hosts & Credentials`. If the project is on another instance, pass `--host` / `--api-key` on every command (or export `SWANLAB_API_HOST` / `SWANLAB_API_KEY`). A `404 Not_Found` from `project info` / `run list` means **wrong host, not a missing project** — see `CLI_REFERENCE.md > Troubleshooting`.
141
+ 4. Proceed with `swanlab api` queries or SDK code
142
+
143
+ ---
144
+
145
+ ## Behavioral Constraints
146
+
147
+ See `CLI_REFERENCE.md > Behavioral Constraints` for the full list. Key rules:
148
+
149
+ - **Use `--all` only when the user explicitly asks for it** (e.g. "fetch all", "get everything", "complete list"). For paginated list commands, always use default pagination (`--page_num` / `--page_size`).
150
+ - **Always ask for specific metric keys before running `run metrics` or `run medias`.** If the user doesn't know the key names, first run `run series PATH` to discover them (`run columns PATH` only as a fallback on SDK `< 0.9.0`).
151
+ - **Always persist large metric data to file via `--save`**, then visualize with `scripts/plot_metrics.py --data file.json` or use `run summary` for aggregate stats.
152
+
153
+ ---
154
+
155
+ ## Further Reading
156
+
157
+ This skill covers the most common SwanLab workflows for AI coding agents. For
158
+ details that are out of scope here (full SDK surface, advanced CLI flags,
159
+ self-hosted deployment, integrations, etc.), consult the official SwanLab
160
+ documentation:
161
+
162
+ - **Cloud guide (what is SwanLab, concepts, usage)**: https://docs.swanlab.cn/guide_cloud/general/what-is-swanlab.md
163
+ - **Python SDK & OpenAPI reference**: https://docs.swanlab.cn/api/api-index.md
@@ -0,0 +1,9 @@
1
+ vendored swanlab-skill v0.3.0 from https://github.com/SwanHubX/SwanLab-Skill (MIT)
2
+ upstream commit: 6fa471b "Fix/env name (#9)" 2026-09-07 (synced 2026-09-13)
3
+ LICENSE 来自上游仓库根目录。
4
+
5
+ LOCAL PATCHES:无。
6
+ v0.2.5 时期本地补过 SDK_QUICKSTART.md 的环境变量表(SWANLAB_NAME 已过时、SDK 0.9.8 实际读
7
+ SWANLAB_EXP_NAME);0.3.0 上游已改为 SWANLAB_EXPERIMENT_NAME 主名 + SWANLAB_EXP_NAME 旧别名
8
+ (SDK ≥ 0.8.0,两者同设时主名优先),补丁作废。训练模式提交时三个名字都注入
9
+ (shared/swanlab.mjs),与哪个 SDK 版本都对得上。
@@ -0,0 +1,83 @@
1
+ # Analysis Guide — Experiment Analysis Pipelines
2
+
3
+ Workflow recipes for turning `swanlab api` queries into analysis or reports. Command syntax: `CLI_REFERENCE.md`. Response schemas: `SWANLAB_CONCEPTS.md`.
4
+
5
+ | User says... | Pipeline |
6
+ | ---------------------------------------------------------- | ------------- |
7
+ | "analyze this run" / "why did it crash or diverge" | Run-level |
8
+ | "analyze this project" / "write a report" / "compare runs" | Project-level |
9
+
10
+ Pre-flight first: confirm host + credentials (`SKILL.md > Environment Connectivity`). A 404 on project-scoped queries means wrong host, not missing data.
11
+
12
+ ---
13
+
14
+ ## Run-Level Pipeline
15
+
16
+ ```
17
+ run info → run series → branch by intent
18
+ ```
19
+
20
+ 1. **`run info PATH`** — what the run actually was.
21
+ - Hyperparameters: `profile.config.<key>.value` (nested `{value, desc, sort}`, not flat).
22
+ - Environment: `profile.metadata` (`command`, `git_info`, `gpu`, `swanlab.version`).
23
+ - Duration = `finished_at` − `created_at`.
24
+ - **Trust config over run name** — names are free-text and can contradict config.
25
+ 2. **`run series PATH`** — discover metric keys (`--class system` for hardware, `--type media` for media).
26
+ 3. **Branch by intent**:
27
+
28
+ | Intent | Next step |
29
+ | ------------------------------------- | ----------------------------------------------------------- |
30
+ | Quick conclusion / final numbers | `run summary` (latest + min/max/avg per key, one call) |
31
+ | Curve shape, convergence, overfitting | `run metrics --keys k1,k2 --save` → plot (see below) |
32
+ | State `CRASHED` / suspicious | `run logs --level ERROR` first; bulk-read via `export-logs` |
33
+ | A step range or tail | `run metrics` with `--range-start/--range-end/--range-tail` |
34
+ | Logged images/audio/text | `run medias --keys KEY --step N` |
35
+
36
+ ---
37
+
38
+ ## Project-Level Pipeline
39
+
40
+ ```
41
+ run list → (optional) run filter → per-run info + summary → synthesize
42
+ ```
43
+
44
+ 1. **`run list PROJECT_PATH`** — inventory. Items embed the full `profile`; extract only `run_id` / `name` / `state` / `description` / timestamps with `jq`/`python` instead of dumping raw JSON.
45
+ 2. **`run filter`** (optional) — narrow the set first: by `state`, config dimension, metric threshold, or time range (`SWANLAB_CONCEPTS.md > Filter Query`).
46
+ 3. **Per-run `run info` + `run summary`** — loop over shortlisted `run_id`s into a table. Check exit codes and retry transient failures before parsing stdout.
47
+ - Summary gives only the latest value + aggregates. For per-key fine-grained analysis — trends, oscillation, when a metric peaked — also pull the time series: `run metrics PATH --keys KEY --save` per run, then compare curves or plot them (see Visualization). Don't rank runs on final values alone.
48
+ 4. **Synthesize** — group by config dimensions (model, dataset, lr, ...), rank by the target metric, cite run names/ids as evidence.
49
+
50
+ ### Analysis discipline
51
+
52
+ - **Config is truth, names are labels.** Names are not unique and can drift from config; group and compare by config values.
53
+ - **`description` often carries variant labels** — read it together with `name`.
54
+ - **Watch for invalidated batches.** Mid-project pipeline fixes make older runs incomparable; time clusters and description markers reveal the boundary. Flag suspect batches, don't average them in.
55
+ - **Single-run ablations are directional only.** Within-noise differences need repeated seeds before becoming conclusions.
56
+ - **Check convergence before ranking.** If val `max ≈ last`, training hadn't saturated — note it instead of ranking undertrained runs.
57
+
58
+ ---
59
+
60
+ ## Visualization
61
+
62
+ Charts are a pipeline step, not a separate task:
63
+
64
+ | Scenario | Script |
65
+ | ------------------------- | ---------------------------- |
66
+ | One run, several keys | `scripts/plot_metrics.py` |
67
+ | Same key across runs | `scripts/runs_benchmark.py` |
68
+ | Unequal-length runs | add `--normalize` |
69
+ | Only final numbers needed | no chart — use `run summary` |
70
+
71
+ **Data bridge (no double-fetching)**: both scripts accept `--data FILE.json` and skip API calls:
72
+
73
+ ```bash
74
+ swanlab api run metrics user/proj/RUN_ID --keys val/loss --save
75
+ python scripts/plot_metrics.py --data swanlab-YYYYMMDD_HHMMSS-xxxx.json -k val/loss -o val_loss.png
76
+ ```
77
+
78
+ **Benchmark path list from a project**: extract run ids from `run list` output and expand to `user/proj/<id>` paths, then pass them to `runs_benchmark.py`.
79
+
80
+ Notes:
81
+
82
+ - Scripts use the OOP `swanlab.api.Api`, which reuses the saved login state (`.netrc` / `SWANLAB_API_KEY`): no flags needed on the logged-in default instance; pass `--host` / `--api-key` only for other instances.
83
+ - Scripts render static matplotlib images. For interactive ECharts needs, implement equivalent rendering over the same fetched JSON (from `run metrics --save` or the scripts' `--data` format); the data-acquisition half of `plot_metrics.py` is the reference to follow.