Skip to content

Commit f42fdde

Browse files
committed
docs(skills): add MatMaster DPA4 workflows
Signed-off-by: weiqichen77 <weiqchen@hku.hk>
1 parent d5e2d6c commit f42fdde

9 files changed

Lines changed: 796 additions & 0 deletions

File tree

doc/agent-skills.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ in the DeePMD-kit repository under `skills/`.
2929
- `lammps-deepmd`: Prepare, explain, and run LAMMPS simulations with DeePMD-kit
3030
potentials, including DPA4/SeZM `.pt2` deployment and common NVE, NVT, and
3131
NPT setups.
32+
- `matmaster-dpa4-workflows`: Run prepared DPA4 training, fine-tuning,
33+
inference, and LAMMPS cases on MatMaster/Bohrium while delegating scientific
34+
setup and acceptance to the sibling DeePMD-kit skills.
3235

3336
## Related reference
3437

@@ -85,3 +88,5 @@ without launching an expensive calculation. For example:
8588
a LoRA fine-tuning input, but do not start training.”
8689
- “Use the `lammps-deepmd` skill to prepare an NVT LAMMPS input file for a
8790
DeePMD-kit model, and explain each command.”
91+
- “Use the `matmaster-dpa4-workflows` skill to prepare and validate a Bohrium
92+
job specification for an existing DPA4 case, but do not submit it.”
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
name: matmaster-dpa4-workflows
3+
description: Run prepared DPA4 training, fine-tuning, inference, and LAMMPS cases on MatMaster/Bohrium. Use when an agent must stage persistent inputs, resolve Bohrium projects/images/GPU resources, generate and validate a job specification, submit or monitor jobs, collect outputs, recover checkpoints or restarts, and record platform provenance. Delegate scientific setup and acceptance to the installed DeePMD-kit skills.
4+
compatibility: Install with deepmd-train, deepmd-finetune-dpa4, deepmd-python-inference, and lammps-deepmd. Requires Python 3; production submission requires a MatMaster platform tool or a Bohrium CLI compatible with 2.5.17.
5+
license: LGPL-3.0-or-later
6+
metadata:
7+
author: MatMaster
8+
version: '1.0'
9+
repository: https://github.com/deepmodeling/deepmd-kit
10+
---
11+
12+
# Run DPA4 workflows on MatMaster
13+
14+
Act only as the MatMaster/Bohrium platform layer. Own storage, resource
15+
resolution, job packaging, submission, monitoring, collection, and retry
16+
lineage. Do not own model architecture, training parameters, checkpoint/head
17+
selection, inference semantics, LAMMPS input design, or scientific acceptance.
18+
19+
## Route scientific work
20+
21+
- Use `deepmd-train` for a new DPA4 training case.
22+
- Use `deepmd-finetune-dpa4` for standard or LoRA fine-tuning.
23+
- Use `deepmd-python-inference` for Python inference or `dp test`.
24+
- Use `lammps-deepmd` for deployment, minimization, and MD.
25+
26+
Require the owning skill to return a prepared case contract. If that skill is
27+
unavailable, install or reload the complete DeePMD-kit skill set instead of
28+
reconstructing its instructions here.
29+
30+
Read references only when needed:
31+
32+
- [workflow-handoffs.md](references/workflow-handoffs.md): required inputs,
33+
outputs, and acceptance boundary for each workflow;
34+
- [matmaster-operations.md](references/matmaster-operations.md): storage,
35+
resources, Bohrium CLI fallback, lifecycle, and recovery.
36+
37+
## Execute
38+
39+
### 1. Accept a prepared case
40+
41+
Require a relative entry command, normally `bash run.sh`, plus all referenced
42+
files or durable paths, checksums, runtime/resource requirements, declared
43+
outputs, smoke-test criteria, and checkpoint/restart policy. Do not change the
44+
scientific command to fit an available resource.
45+
46+
### 2. Inventory and stage
47+
48+
Run:
49+
50+
```bash
51+
python scripts/check_environment.py --case-dir CASE_DIR
52+
```
53+
54+
Use `--require-file`, `--require-deepmd`, and `--require-lammps` as required by
55+
the handoff. Keep durable inputs and results under `/personal` or `/share`.
56+
Use relative paths inside job packages; the Bohrium working directory is not a
57+
stable absolute path.
58+
59+
### 3. Resolve execution resources
60+
61+
Discover a real project ID, full image address, current machine type, wall
62+
time, and output destination. Never reuse a historical project, image tag, GPU
63+
SKU, or case count as a default. Prove image/data/output compatibility with the
64+
bounded smoke test supplied by the owning skill.
65+
66+
### 4. Build and validate the job
67+
68+
Generate a concrete job specification:
69+
70+
```bash
71+
python scripts/make_job_spec.py CASE_DIR \
72+
--output CASE_DIR/job.json \
73+
--project-id PROJECT_ID \
74+
--image FULL_IMAGE_ADDRESS \
75+
--machine MACHINE_TYPE \
76+
--name JOB_NAME
77+
```
78+
79+
Preview submission, then use the installed platform tool or the native Bohrium
80+
CLI dry run. Submit only after validation and explicit authorization. Stop if
81+
neither a submission tool nor a compatible `bohr` executable exists.
82+
83+
### 5. Monitor and collect
84+
85+
Reconcile every job/group ID with `assets/bohrium-job/manifest.json`. Download
86+
finished and failed cases, retain partial checkpoints/restarts, and run a
87+
filesystem/log first pass:
88+
89+
```bash
90+
python scripts/audit_cases.py ROOT --json REPORT.json
91+
```
92+
93+
Add `--mode` and repeat `--require` for declared outputs. A scheduler success
94+
or file-audit pass is not scientific acceptance; return artifacts to the owning
95+
DeePMD skill.
96+
97+
### 6. Recover the smallest subset
98+
99+
Classify packaging, path, image, quota, queue, resource, interruption, and
100+
wall-time failures here. Route training divergence/configuration, checkpoint
101+
validity, inference correctness, model export, type mapping, LAMMPS input, and
102+
numerical failures back to the owning skill. Retry only invalid cases and set
103+
`retry_of`; never overwrite evidence from an earlier attempt.
104+
105+
## Return the platform ledger
106+
107+
Return persistent paths, project/image/machine selections, case/job/group and
108+
attempt mappings, expected/submitted/downloaded/platform-valid counts, retry
109+
lineage, logs, declared outputs, audit report, and unresolved platform risks.
110+
Keep the platform verdict separate from training, inference, MD, and scientific
111+
verdicts.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"job_name": "__JOB_NAME__",
3+
"command": "bash run.sh",
4+
"log_file": "run.log",
5+
"backward_files": [
6+
"run.log",
7+
"runtime.txt",
8+
"logs/",
9+
"results/",
10+
"provenance.json"
11+
],
12+
"project_id": "__PROJECT_ID__",
13+
"machine_type": "__MACHINE_TYPE__",
14+
"image_address": "__FULL_IMAGE_ADDRESS__",
15+
"job_type": "container",
16+
"max_reschedule_times": 0,
17+
"max_run_time": "__MINUTES__",
18+
"nnode": 1
19+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"run_id": "__RUN_ID__",
3+
"workflow": "__TRAIN_FINETUNE_INFERENCE_OR_LAMMPS__",
4+
"prepared_by": "__DEEPMD_SKILL__",
5+
"project_id": "__PROJECT_ID__",
6+
"image_address": "__FULL_IMAGE_ADDRESS__",
7+
"machine_type": "__MACHINE_TYPE__",
8+
"cases": [
9+
{
10+
"case_id": "__CASE_ID__",
11+
"case_dir": "__RELATIVE_CASE_DIR__",
12+
"entry_command": "bash run.sh",
13+
"input_checksums": {},
14+
"declared_outputs": [],
15+
"attempts": [
16+
{
17+
"attempt": 0,
18+
"job_id": null,
19+
"group_id": null,
20+
"retry_of": null,
21+
"platform_status": "prepared",
22+
"platform_verdict": null,
23+
"reason": null,
24+
"changed_platform_fields": [],
25+
"result_dir": null
26+
}
27+
]
28+
}
29+
]
30+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# MatMaster and Bohrium operations
2+
3+
## Capability order
4+
5+
Use the first available capability:
6+
7+
1. installed MatMaster/Bohrium skill or platform tool;
8+
1. an installed Bohrium CLI whose help matches the required operation;
9+
1. explicit prerequisite installation or user/platform intervention.
10+
11+
This skill bundles no executable, credential, project, image, or GPU default.
12+
Do not invent an OpenAPI route when a platform tool or compatible CLI is
13+
missing. Use `python scripts/check_environment.py --probe --require-bohr` to
14+
inventory the fallback without exposing secret values.
15+
16+
## Storage and job boundaries
17+
18+
| Layer | Use | Persistence |
19+
| ---------------------- | ---------------------------------- | --------------------------------- |
20+
| MatMaster session node | prepare, inspect, and post-process | system disk is not durable |
21+
| `/personal` | user-scoped inputs and results | durable |
22+
| `/share` | project-shared inputs and results | durable, permission scoped |
23+
| Bohrium job workspace | production execution | temporary except declared outputs |
24+
25+
Do not assume that a session-node package exists in the job image. Do not save
26+
mounted `/personal` or `/share` data into an image. Confirm project permission
27+
before writing shared storage, and stop unused billable nodes according to the
28+
accepted lifecycle policy.
29+
30+
## Images and resources
31+
32+
- Query current projects, full image addresses, and machine availability.
33+
- Pin the image address and version/digest; a display name is insufficient.
34+
- Select resources that satisfy the prepared handoff, then run its smoke test.
35+
- Treat image-pull/cache startup as distinct from a hung calculation.
36+
- Confirm project, quota, budget, wall time, and reschedule policy before submit.
37+
38+
## Package and submit
39+
40+
Keep the command in a short `run.sh`, use relative paths, write an incremental
41+
log, and declare every result needed after the temporary workspace disappears.
42+
Start from `assets/bohrium-job/job.json` or generate the resolved specification
43+
with `scripts/make_job_spec.py`. Reject every remaining `__PLACEHOLDER__`.
44+
45+
For Bohrium CLI 2.5.17, the validation shape is:
46+
47+
```bash
48+
bohr version
49+
bohr job submit -i job.json \
50+
--input_directory ./case_dir/ \
51+
--dry-run --output json
52+
```
53+
54+
Inspect `bohr job submit --help` when the installed interface differs. Remove
55+
`--dry-run` only for the authorized production submission. Prefer a MatMaster
56+
built-in submit tool when present.
57+
58+
Record the case ID, attempt, job/group IDs, project, image, machine, input
59+
checksums, declared outputs, and `retry_of` in the manifest. A reschedule may
60+
restart `run.sh` from the beginning; enable rescheduling only when the wrapper
61+
is safely restart-aware.
62+
63+
## Monitor, collect, and recover
64+
65+
For each job group:
66+
67+
1. reconcile its members with the manifest;
68+
1. inspect representative running and failed logs;
69+
1. distinguish queue/image startup from execution progress;
70+
1. download finished and failed terminal jobs;
71+
1. run the file/log audit and return results to the owning skill;
72+
1. retry only invalid cases in a new attempt directory.
73+
74+
`Finished` is a platform state, not proof of a valid model or simulation.
75+
Preserve partial logs, checkpoints, and restarts before any retry.
76+
77+
Use terminate when recoverable outputs should normally remain. Use kill only
78+
for an unrecoverable job after resolving its exact ID. Delete jobs or persistent
79+
files only when explicitly requested and after verifying the target.
80+
81+
## Authentication
82+
83+
Let platform tools handle credentials when possible. For a CLI fallback, read
84+
the access key from the injected environment (`BOHR_ACCESS_KEY`, or
85+
`ACCESS_KEY` when required by that CLI version). Never print, hard-code, copy
86+
into a job package, or return credentials, storage tokens, or node passwords.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# DeePMD workflow handoffs
2+
3+
## Common contract
4+
5+
Before staging, require the owning DeePMD skill to provide:
6+
7+
- workflow kind, owning skill, case ID, and relative entry command;
8+
- every input file or durable path plus checksums/manifests;
9+
- image/runtime, accelerator, memory, node/rank, and wall-time requirements;
10+
- incremental logs, checkpoints/restarts, final outputs, and output cadence;
11+
- smoke-test contract, retry/resume constraints, and acceptance owner.
12+
13+
Wrap the exact accepted command in `run.sh`. Do not reinterpret scientific
14+
configuration during packaging.
15+
16+
## Training and fine-tuning
17+
18+
`deepmd-train` or `deepmd-finetune-dpa4` owns the training input, data split,
19+
starting checkpoint/head, checkpoint cadence, command, metrics, and scientific
20+
acceptance.
21+
22+
- Reference large durable datasets/checkpoints rather than copying partial data.
23+
- Prove data access, representative batch size, accelerator compatibility, and
24+
checkpoint writing with the supplied bounded smoke test.
25+
- Preserve resolved inputs, logs, metrics, periodic checkpoints, runtime record,
26+
and all attempts.
27+
- On interruption, return every checkpoint. The owning skill selects the valid
28+
resume checkpoint and command.
29+
30+
The platform layer may report progress and file growth, but must not choose the
31+
best checkpoint or interpret convergence.
32+
33+
## Inference
34+
35+
`deepmd-python-inference` owns the model artifact, input ordering, type mapping,
36+
command, batch size, declared predictions, and accuracy acceptance. Preserve
37+
ordering and case identity; return predictions, logs, runtime metadata, and
38+
failures without interpreting accuracy.
39+
40+
## LAMMPS
41+
42+
`lammps-deepmd` owns deployment, type mapping, LAMMPS inputs, ensemble,
43+
timestep, ranks, output cadence, restart policy, and simulation acceptance.
44+
Preserve trajectories, logs, final structures, and partial restarts without
45+
rewriting those scientific choices.
46+
47+
## Return boundary
48+
49+
Return case/attempt/job/group identity, platform selections and versions,
50+
input/output paths, scheduler/exit evidence, logs, retry lineage, and a platform
51+
verdict. The owning skill determines training, inference, MD, and scientific
52+
validity.

0 commit comments

Comments
 (0)