Agent no longer gets the platform's model code; each task states its I/O contract
The agent could read and copy harness/adapters (model loading, preprocessing, export, decoding), and every bench dev container carried the whole harness, registry, scripts and export trees, evaluator and gates included. That did the model-specific half of the deployment for it. - guard and private-home jail no longer expose harness/adapters; bench dev packs only container_site - the evaluator still decodes outputs with the platform's own code, so agent/io-contracts states what the graph's inputs and outputs mean (9 families, 71 models so far); the prompt appends the task's contract - SYSTEM.md: says where official sources, weights and environments are; the compile.yaml template is replaced by the facts that differ from the docs - e2e prompt: whole-class int16/float fallback and >1.5x board latency do not pass - agent/VERSION 24 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
061f3ed168
commit
8fb9349907
@ -3,9 +3,9 @@
|
||||
你负责完成 job.json 固定的部署任务:从模型权重出发,交付一个在目标板卡上精度和速度都合格的模型。怎么做由你决定;验收只认平台在板上的实际测量。
|
||||
|
||||
## 环境
|
||||
- 当前目录是你的 workspace,可写。本 rollout 的 job.json、日志和阶段产物可读;公共源码、共享工具链、其他 rollout、评测数据和判分结果不属于本任务。
|
||||
- 当前目录是你的 workspace,可写。本 rollout 的 job.json、日志和阶段产物可读;平台代码、共享工具链、其他 rollout、评测数据和判分结果不属于本任务。
|
||||
- 你的 bash 跑在控制机上,**没有工具链**(hb_compile、hmct、onnx、onnxruntime、torch 都不在),用到它们的命令走 `bench dev`。单条 bash 命令约 14 分钟会被结束,只结束这一条。
|
||||
- 工具链文档:`oe-doc <query>` 和 `.horizon/skills/`。`$BENCH_ROOT/harness/adapters/` 里是公共的预处理和后处理代码,可读。
|
||||
- 工具链文档:`oe-doc <query>` 和 `.horizon/skills/`。
|
||||
|
||||
## 等待不花轮数
|
||||
`bench dev` 和正式阶段都在后台跑,提交后返回 handle。`terminal_exec({"wait_handle": "<handle>"})` 一次等到结束,不管等多久都只算一轮。用 sleep 或反复查看状态来等,每查一次都算一轮,还会占上下文。
|
||||
@ -16,7 +16,7 @@ bench dev "python check.py" # 在带完整工具链的容器
|
||||
bench dev --timeout 7200 -- python export.py # 长任务给足时限(最多 43200 秒;容器启动约 1 分钟)
|
||||
bench dev --board -- python3 run.py # 把当前目录传到本题的板卡上运行,可用 BPU
|
||||
```
|
||||
- `python`、`hb_compile`、`hb_verifier`、`hb_model_info` 来自 OE 工具链(含 hmct、onnx、onnxruntime);torch 用 `/home/ming01.wang/toolchains/bench-venv/bin/python`,或 job.json 里 `model_runtime.python` 指定的环境。权重和模型源码只读可见。
|
||||
- `python`、`hb_compile`、`hb_verifier`、`hb_model_info` 来自 OE 工具链(含 hmct、onnx、onnxruntime);torch 用 `/home/ming01.wang/toolchains/bench-venv/bin/python`,或 job.json 里 `model_runtime.python` 指定的环境(OpenMMLab 模型的环境里装好了 mmdet/mmpose/mmseg,官方配置在包里)。只读可见:官方源码在 `/home/ming01.wang/bench-cache/sources/`,权重在 `/home/ming01.wang/bench-cache/weights/`(`bench stage run fetch` 返回本题的路径),其他 Python 环境在 `/home/ming01.wang/bench-cache/venvs/`。
|
||||
- 校准图片:`$BENCH_CALIB_IMAGES`,是训练集原图,和评测集不重叠;`$BENCH_CALIB_IMAGES/../images.json` 列出顺序和来源。预处理以 job.json 的 `model_spec.preprocess` 为准。
|
||||
- 同步:本机改过的文件在下一次 `bench dev` 开始时传上去;命令里新建或改动的小文件(单个 ≤16 MiB)拷回本机,大文件(图、npy、hbm)只留在开发环境,输出末尾会列出来。
|
||||
- 板上:有 python3、numpy 和 hbm_runtime(`m = hbm_runtime.HB_HBMRuntime('x.hbm')`,`m.model_names`、`m.input_names[name]`、`m.input_shapes[name]`,`m.run({name: {输入名: 数组}})`);写到 `$BENCH_OUT` 的文件会拉回到结果目录的 `output/`。一次最多 30 分钟,板卡和正式阶段共用。
|
||||
@ -32,32 +32,10 @@ bench stage run hbm # 收集并检查编译产物
|
||||
bench stage run board # 板上延迟
|
||||
bench stage run eval # 板上任务精度
|
||||
```
|
||||
- compile.yaml 是 hb_compile 的 PTQ 配置(hb_compile 3.5.3 · hmct 2.6.5),放在 workspace 里。`model_parameters.onnx_model` 和 `calibration_parameters.cal_data_dir` 必填,写你在开发环境里做的图和校准 npy 目录(workspace 内的路径);march、working_dir、输出前缀由平台固定。这一版工具链实际接受的字段(已对源码核实,文档有出入时以这里为准):
|
||||
```yaml
|
||||
model_parameters:
|
||||
onnx_model: my_model.onnx
|
||||
input_parameters: # 默认 featuremap / NCHW / 无归一化,预处理在主机侧,与评测器一致
|
||||
input_type_rt: featuremap # featuremap | rgb | bgr | nv12 | gray | yuv444
|
||||
input_type_train: featuremap
|
||||
input_layout_train: NCHW
|
||||
# mean_value / scale_value / std_value 只在 input_type 不是 featuremap 时有意义
|
||||
calibration_parameters:
|
||||
cal_data_dir: my_calib/ # 每个 .npy 是一个模型输入,形状同 input_spec,float32
|
||||
calibration_type: default # default | max | kl | mix | skip
|
||||
max_percentile: 0.99999 # 只对 max 有效
|
||||
per_channel: true
|
||||
run_on_cpu: "node_a,node_b" # ONNX 节点名,逗号分隔;run_on_bpu 反之
|
||||
optimization: set_model_output_int16 # 或 set_model_output_int8
|
||||
quant_config: # dict 或 json 路径;qtype: int8 | int16 | float16 | float32
|
||||
model_config: { all_node_type: int8, model_output_type: int16 }
|
||||
op_config: { Softmax: { qtype: float16 } } # 按算子类型
|
||||
node_config: { "/features/features.8/Mul": { qtype: int16 } } # 按节点名
|
||||
compiler_parameters:
|
||||
compile_mode: latency # latency | bandwidth | balance
|
||||
optimize_level: O2 # O0 | O1 | O2(O3 会被拒)
|
||||
jobs: 8
|
||||
```
|
||||
- 你的图的输入输出(个数、顺序、类型、形状)要和平台的一致,基线、上板和评测才可比;不一致时编译前就会被拒并列出期望值,不占编译次数。
|
||||
- compile.yaml 是 hb_compile 的 PTQ 配置(hb_compile 3.5.3 · hmct 2.6.5),放在 workspace 里,字段以 `oe-doc` 为准。`model_parameters.onnx_model` 和 `calibration_parameters.cal_data_dir` 必填,写你在开发环境里做的图和校准 npy 目录(workspace 内的路径);march、working_dir、输出前缀由平台固定。
|
||||
- 评测器在主机侧做完预处理,按 featuremap(NCHW float32)把数据喂给模型;校准目录里每个 .npy 是一个模型输入,形状同 input_spec,float32。
|
||||
- 这一版和文档不一致的地方:`optimize_level` 只接受 O0–O2(O3 会被拒);`quant_config` 分 `model_config`、`op_config`、`node_config` 三段,qtype 取 int8、int16、float16、float32。
|
||||
- 你的图的输入输出(个数、顺序、类型、形状、含义)要符合任务说明末尾的输入输出约定,基线、上板和评测才可比;不一致时编译前就会被拒并列出期望值,不占编译次数。
|
||||
- 阶段失败时看等待结果里的 stdout/stderr/meta 再决定下一步;板上延迟记录失败时仍可以跑精度评测。
|
||||
|
||||
## 结束说明
|
||||
|
||||
@ -1 +1 @@
|
||||
23
|
||||
24
|
||||
|
||||
@ -68,7 +68,6 @@ function makeGuard(env) {
|
||||
const allowRead = [
|
||||
WS, RO,
|
||||
path.join(JOB, "job.json"), path.join(JOB, "data"),
|
||||
path.join(BENCH, "harness", "adapters"),
|
||||
path.join(BENCH, "data"), path.join(BENCH, "cache"), path.join(BENCH, "bin"), path.join(BENCH, "agent", "oe-doc.sh"),
|
||||
path.join(BENCH, "agent", "speed_ref"), // default-config latency per job (scripts/speed_ref.py)
|
||||
path.join(PROJ, ".horizon"), path.join(PROJ, "AGENTS.md"),
|
||||
|
||||
@ -32,8 +32,8 @@ expect("read oracle (e2e)", e2e.judgePath("../../../oracle/result.json"), "block
|
||||
expect("read oracle (repair)", repair.judgePath("../../../oracle/result.json"), "allow");
|
||||
expect("read sibling claim", e2e.judgePath("../../00/claim.json"), "block");
|
||||
expect("read sibling via rollouts/", e2e.judgePath("../../00/workspace/compile.yaml"), "block");
|
||||
expect("read public adapter", e2e.judgePath(B + "/harness/adapters/segnext_tiny.py"), "allow");
|
||||
expect("copy public adapter", e2e.judgeCommand("cp " + B + "/harness/adapters/segnext_tiny.py ./model.py"), "allow");
|
||||
expect("read platform adapter", e2e.judgePath(B + "/harness/adapters/segnext_tiny.py"), "block");
|
||||
expect("copy platform adapter", e2e.judgeCommand("cp " + B + "/harness/adapters/segnext_tiny.py ./model.py"), "block");
|
||||
expect("write public adapter", e2e.judgePath(B + "/harness/adapters/segnext_tiny.py", { write: true }), "block");
|
||||
expect("read harness", e2e.judgePath(B + "/harness/gates.py"), "block");
|
||||
expect("read state sqlite", e2e.judgePath(B + "/state/jobs.sqlite"), "block");
|
||||
@ -121,7 +121,7 @@ async function extensionCases() {
|
||||
for (const command of ["find / -maxdepth 6 -name harness", "find '/' -name harness", "find -L / -name harness", "true && /usr/bin/find / -name harness"]) {
|
||||
expect(policy + " root scan " + command, (await handler({toolName: "bash", input: {command}})) || null, "block");
|
||||
}
|
||||
for (const command of ["rg 'find /' .", "find . -name harness", "find . -name '/'", "find " + bench + "/harness/adapters -name '*.py'"]) {
|
||||
for (const command of ["rg 'find /' .", "find . -name harness", "find . -name '/'", "find ./src -name '*.py'"]) {
|
||||
expect(policy + " scoped search " + command, (await handler({toolName: "bash", input: {command}})) || null, "allow");
|
||||
}
|
||||
expect(policy + " shared compile resource", await handler({ toolName: "bash", input: { command: "hb_compile -c x.yaml" } }), "block");
|
||||
|
||||
@ -162,7 +162,7 @@ export default function (pi: ExtensionAPI) {
|
||||
const cmd: string = input.command ?? "";
|
||||
if (rootFind(cmd)) {
|
||||
log("deny-bash-root-find", cmd.slice(0, 500));
|
||||
return { block: true, reason: "不要从 / 扫描服务器;在 workspace、任务返回的日志目录或 $BENCH_ROOT/harness/adapters 内限定搜索。" };
|
||||
return { block: true, reason: "不要从 / 扫描服务器;在 workspace 或任务返回的日志目录内限定搜索。" };
|
||||
}
|
||||
// The private mount jail enforces filesystem boundaries. The lexer here is
|
||||
// only a diagnostic for direct shared-resource commands, never isolation.
|
||||
|
||||
8
agent/io-contracts/efficientvit_common.md
Normal file
8
agent/io-contracts/efficientvit_common.md
Normal file
@ -0,0 +1,8 @@
|
||||
## 输入输出约定(MIT EfficientViT 分类)
|
||||
评测时平台在主机上做预处理,把图喂给你的模型,再用平台自己的后处理解读输出。
|
||||
|
||||
**输入**:1 个,`1x3x224x224` float32。预处理在主机侧,图里不要再做(数值见 job.json 的 `model_spec.preprocess`):RGB,短边双三次缩放到 236,中心裁出 224,`/255` 后按 ImageNet 的 mean/std 归一化。
|
||||
|
||||
**输出**:1 个,`[1, 1000]`,是官方 `create_cls_model(...)(x)` 的 logits,类别顺序是 ImageNet-1K 的标准顺序。做不做 softmax 都可以,平台只按大小排序。
|
||||
|
||||
**平台后处理**:按分数从大到小排序,算 top-1 和 top-5。
|
||||
73
agent/io-contracts/index.json
Normal file
73
agent/io-contracts/index.json
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"atss_r50_fpn": "mmdet_dense_common.md",
|
||||
"bisenetv1_r18": "mmseg_common.md",
|
||||
"bisenetv2": "mmseg_common.md",
|
||||
"ddrnet_23": "mmseg_common.md",
|
||||
"ddrnet_23_slim": "mmseg_common.md",
|
||||
"deeplabv3_resnet101": "mmseg_common.md",
|
||||
"deeplabv3_resnet50": "mmseg_common.md",
|
||||
"deeplabv3plus_resnet101": "mmseg_common.md",
|
||||
"deeplabv3plus_resnet50": "mmseg_common.md",
|
||||
"efficientvit_b0": "efficientvit_common.md",
|
||||
"efficientvit_b1": "efficientvit_common.md",
|
||||
"efficientvit_b2": "efficientvit_common.md",
|
||||
"efficientvit_b3": "efficientvit_common.md",
|
||||
"fast_scnn": "mmseg_common.md",
|
||||
"fcn_resnet101": "mmseg_common.md",
|
||||
"fcn_resnet50": "mmseg_common.md",
|
||||
"fcos_r50_fpn": "mmdet_dense_common.md",
|
||||
"foveabox_r50_fpn": "mmdet_dense_common.md",
|
||||
"fsaf_r50_fpn": "mmdet_dense_common.md",
|
||||
"gfl_r50_fpn": "mmdet_dense_common.md",
|
||||
"hrnet_w18": "mmseg_common.md",
|
||||
"hrnet_w48": "mmseg_common.md",
|
||||
"litehrnet_18": "topdown_pose_batch8.md",
|
||||
"litehrnet_30": "topdown_pose_batch8.md",
|
||||
"ocrnet_hrnet_w18": "mmseg_common.md",
|
||||
"ocrnet_hrnet_w48": "mmseg_common.md",
|
||||
"pidnet_l": "mmseg_common.md",
|
||||
"pidnet_m": "mmseg_common.md",
|
||||
"pidnet_s": "mmseg_common.md",
|
||||
"pspnet_resnet101": "mmseg_common.md",
|
||||
"pspnet_resnet50": "mmseg_common.md",
|
||||
"reppoints_r50_fpn": "mmdet_dense_common.md",
|
||||
"retinanet_r101_fpn": "mmdet_dense_common.md",
|
||||
"retinanet_r50_fpn": "mmdet_dense_common.md",
|
||||
"rtmdet_l": "rtmdet_common.md",
|
||||
"rtmdet_m": "rtmdet_common.md",
|
||||
"rtmdet_s": "rtmdet_common.md",
|
||||
"rtmdet_tiny": "rtmdet_common.md",
|
||||
"rtmdet_x": "rtmdet_common.md",
|
||||
"rtmpose_l": "rtmpose_common.md",
|
||||
"rtmpose_m": "rtmpose_common.md",
|
||||
"rtmpose_s": "rtmpose_common.md",
|
||||
"rtmpose_tiny": "rtmpose_common.md",
|
||||
"rtmpose_x": "rtmpose_common.md",
|
||||
"segformer_b0": "mmseg_common.md",
|
||||
"segformer_b1": "mmseg_common.md",
|
||||
"segformer_b2": "mmseg_common.md",
|
||||
"segformer_b3": "mmseg_common.md",
|
||||
"segformer_b4": "mmseg_common.md",
|
||||
"segformer_b5": "mmseg_common.md",
|
||||
"segnext_base": "mmseg_common.md",
|
||||
"segnext_large": "mmseg_common.md",
|
||||
"segnext_small": "mmseg_common.md",
|
||||
"segnext_tiny": "mmseg_common.md",
|
||||
"simplebaseline_r101": "topdown_pose_batch8.md",
|
||||
"simplebaseline_r152": "topdown_pose_batch8.md",
|
||||
"simplebaseline_r50": "topdown_pose_batch8.md",
|
||||
"ssdlite320_mobilenetv3_large": "ssdlite_common.md",
|
||||
"stdc1_seg": "mmseg_common.md",
|
||||
"stdc2_seg": "mmseg_common.md",
|
||||
"upernet_resnet50": "mmseg_common.md",
|
||||
"upernet_swin_b": "mmseg_common.md",
|
||||
"upernet_swin_s": "mmseg_common.md",
|
||||
"upernet_swin_t": "mmseg_common.md",
|
||||
"vfnet_r50_fpn": "mmdet_dense_common.md",
|
||||
"xfeat": "xfeat.md",
|
||||
"yolox_l": "yolox_common.md",
|
||||
"yolox_m": "yolox_common.md",
|
||||
"yolox_s": "yolox_common.md",
|
||||
"yolox_tiny": "yolox_common.md",
|
||||
"yolox_x": "yolox_common.md"
|
||||
}
|
||||
25
agent/io-contracts/mmdet_dense_common.md
Normal file
25
agent/io-contracts/mmdet_dense_common.md
Normal file
@ -0,0 +1,25 @@
|
||||
## 输入输出约定(MMDetection 单阶段密集检测头:RetinaNet / FCOS / ATSS / GFL / VFNet / FoveaBox / FSAF / RepPoints)
|
||||
评测时平台在主机上做预处理,把图喂给你的模型,再用 MMDetection 官方的后处理(`predict_by_feat`)解读输出。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,`1x3x640x640` float32。预处理在主机侧,图里不要再做(具体数值见 job.json 的 `model_spec.preprocess`):
|
||||
- 等比缩放到长边 640(`int(边长*比例+0.5)`,cv2 双线性);
|
||||
- 按官方 data_preprocessor 的通道顺序和 mean/std 归一化;
|
||||
- 归一化之后在右侧和下方补 0,补到 640×640。
|
||||
|
||||
**输出**:官方 bbox head 的原始输出,也就是 `model._forward(x)` 返回的各组张量,**按组、再按层展开**成一串:
|
||||
- 先 5 个分类:`cls_s8, cls_s16, cls_s32, cls_s64, cls_s128`;
|
||||
- 再 5 个回归:`bbox_s8 … bbox_s128`;
|
||||
- FCOS 和 ATSS 还有 5 个 centerness:`centerness_s8 … centerness_s128`。
|
||||
|
||||
每个张量的形状是 `[1, C, 640/s, 640/s]`,s 是该层的 stride(8, 16, 32, 64, 128):
|
||||
|
||||
| 模型 | 分类 C | 回归 C | centerness C |
|
||||
|---|---|---|---|
|
||||
| retinanet | 720(9 个锚 × 80 类) | 36 | 无 |
|
||||
| fcos、atss | 80 | 4 | 1 |
|
||||
| gfl | 80 | 68(4 × 17 个分布 bin) | 无 |
|
||||
| vfnet、foveabox、fsaf、reppoints | 80 | 4 | 无 |
|
||||
|
||||
全部是原始值:分类和 centerness 不过 sigmoid,回归不解码,图里也不做 NMS。
|
||||
|
||||
**平台后处理**:MMDetection 官方 `predict_by_feat`,包括先验框/点、框解码、sigmoid、分数阈值 0.05、每层前 1000、NMS 0.5(atss/gfl/vfnet 为 0.6)、每张图最多 100 个框,再还原到原图。
|
||||
13
agent/io-contracts/mmseg_common.md
Normal file
13
agent/io-contracts/mmseg_common.md
Normal file
@ -0,0 +1,13 @@
|
||||
## 输入输出约定(MMSegmentation 语义分割)
|
||||
评测时平台在主机上做预处理,把图喂给你的模型,再用平台自己的后处理解读输出。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,形状见 job.json 的 `input_spec`。预处理在主机侧,图里不要再做(数值见 job.json 的 `model_spec.preprocess`):
|
||||
- 直接拉伸到输入大小(不保持比例,cv2 双线性);
|
||||
- 按官方 data_preprocessor 的通道顺序和 mean/std 归一化。
|
||||
|
||||
**输出**:1 个,`[1, C, h, w]` float32,是官方 `model._forward(x)` 返回的 decode head 原始 logits:
|
||||
- C 是类别数:ADE20K 是 150,Cityscapes 是 19,类别顺序同官方数据集定义;
|
||||
- `h, w` 可以是 head 自己的分辨率(通常是输入的 1/4 或 1/8),不必在图里放大;
|
||||
- 不做 softmax,也不在图里 argmax。
|
||||
|
||||
**平台后处理**:双线性插值(align_corners=False),先放大到输入大小,再放大到原图,然后取 argmax。
|
||||
13
agent/io-contracts/rtmdet_common.md
Normal file
13
agent/io-contracts/rtmdet_common.md
Normal file
@ -0,0 +1,13 @@
|
||||
## 输入输出约定(MMDetection RTMDet)
|
||||
评测时平台在主机上做预处理,把图喂给你的模型,再用平台自己的后处理解读输出。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,`1x3x640x640` float32。预处理在主机侧,图里不要再做(数值见 job.json 的 `model_spec.preprocess`):
|
||||
- **BGR** 通道顺序,不转 RGB;
|
||||
- 等比缩放到长边 640(`int(边长*比例+0.5)`,cv2 双线性),右侧和下方用 114 补到 640×640(在归一化之前补);
|
||||
- 再按 mean/std 归一化。
|
||||
|
||||
**输出**:6 个,是官方 `model._forward(x)` 返回的 `(cls_scores, bbox_preds)` 按组展开:
|
||||
1. `cls_s8` `[1,80,80,80]`、`cls_s16` `[1,80,40,40]`、`cls_s32` `[1,80,20,20]`:分类 logits,不过 sigmoid;
|
||||
2. `reg_s8` `[1,4,80,80]`、`reg_s16` `[1,4,40,40]`、`reg_s32` `[1,4,20,20]`:每个格点到框四边的距离(左、上、右、下),单位是 640 输入图上的像素。这和官方 `RTMDetSepBNHead` 的输出一致,已经乘过 stride。格点位置是 `(x*stride, y*stride)`,offset 为 0。
|
||||
|
||||
**平台后处理**:sigmoid、分数阈值 0.001、前 30000、按距离解码、NMS 0.65、每张图最多 300 个框,再还原到原图。
|
||||
14
agent/io-contracts/rtmpose_common.md
Normal file
14
agent/io-contracts/rtmpose_common.md
Normal file
@ -0,0 +1,14 @@
|
||||
## 输入输出约定(MMPose RTMPose,SimCC 头)
|
||||
这是自顶向下的姿态估计:平台用固定的官方人体检测框(HRNet 在 val2017 上的检测结果)从原图裁出每个人,喂给你的模型,再用平台自己的后处理解读输出。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,`1x3x256x192` float32(rtmpose.x 是 `1x3x384x288`),也就是一个人的裁剪图。预处理在主机侧,图里不要再做(数值见 job.json 的 `model_spec.preprocess`):
|
||||
- 用检测框算中心和尺度(padding 1.25,宽高比固定为输入的比例),做仿射变换,不旋转、不用 UDP,边界补 0;
|
||||
- RGB,再按 mean/std 归一化。
|
||||
|
||||
**输出**:2 个,是官方 `model._forward(x)` 返回的 `(pred_x, pred_y)`,顺序是先 x 后 y:
|
||||
- `simcc_x` `[1, 17, 2W]`:256×192 输入时是 `[1,17,384]`;
|
||||
- `simcc_y` `[1, 17, 2H]`:256×192 输入时是 `[1,17,512]`。
|
||||
|
||||
两个都是 SimCC 头的**原始 logits,不要加 softmax**。平台取最大值的位置当坐标,取最大值本身当关键点分数,而这个分数会参与实例打分和 0.2 的关键点阈值,所以数值的尺度会影响精度。
|
||||
|
||||
**平台后处理**:翻转测试(另跑一张水平翻转的裁剪图,结果取平均),argmax ÷ 2(split ratio)得到坐标,映射回原图,再做 OKS NMS(阈值 0.9)。
|
||||
10
agent/io-contracts/ssdlite_common.md
Normal file
10
agent/io-contracts/ssdlite_common.md
Normal file
@ -0,0 +1,10 @@
|
||||
## 输入输出约定(Torchvision SSDLite320)
|
||||
评测时平台在主机上做预处理,把图喂给你的模型,再用平台自己的后处理解读输出。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,`1x3x320x320` float32。预处理在主机侧,图里不要再做:RGB,先 `/255` 再 `(x-0.5)/0.5`,然后双线性(align_corners=False,无抗锯齿)拉伸到 320×320,不保持比例。
|
||||
|
||||
**输出**:1 个,`[1, 3234, 95]` float32,每行对应一个官方锚框(顺序同 torchvision `anchor_generator` 在 320×320 上生成的锚框):
|
||||
- 前 4 维:用官方 `box_coder.decode_single(bbox_regression, anchors)` 解码出的框 `[x1, y1, x2, y2]`,单位是 320×320 输入图上的像素;
|
||||
- 后 91 维:`softmax(cls_logits)` 后的概率。下标 0 是背景,1–90 是 COCO 的 category id(中间有空号),和官方 91 类头一致。
|
||||
|
||||
**平台后处理**:逐类阈值 0.001,每类取前 300,NMS 0.55,每张图最多 300 个框,再按宽高分别缩放回原图。
|
||||
10
agent/io-contracts/topdown_pose_batch8.md
Normal file
10
agent/io-contracts/topdown_pose_batch8.md
Normal file
@ -0,0 +1,10 @@
|
||||
## 输入输出约定(MMPose 自顶向下热力图头:SimpleBaseline / LiteHRNet)
|
||||
这是自顶向下的姿态估计:平台用固定的官方人体检测框(HRNet 在 val2017 上的检测结果)从原图裁出每个人,喂给你的模型,再用平台自己的后处理解读输出。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,`1x3x256x192` float32,也就是一个人的裁剪图。预处理在主机侧,图里不要再做(数值见 job.json 的 `model_spec.preprocess`):
|
||||
- 用检测框算中心和尺度(padding 1.25,宽高比固定为 192:256),做仿射变换,不旋转、不用 UDP,边界补 0;
|
||||
- RGB,再按 mean/std 归一化。
|
||||
|
||||
**输出**:1 个,`[1, 17, 64, 48]`,是官方 `model._forward(x)` 返回的热力图:17 个 COCO 关键点,顺序同官方;原始值,不过 sigmoid,也不在图里取 argmax。
|
||||
|
||||
**平台后处理**:翻转测试(另跑一张水平翻转的裁剪图,热力图按官方方式翻转、平移后取平均),MSRAHeatmap 解码(argmax 加四分之一像素偏移),分数取热力图最大值,映射回原图,再做 OKS NMS(阈值 0.9)。
|
||||
11
agent/io-contracts/xfeat.md
Normal file
11
agent/io-contracts/xfeat.md
Normal file
@ -0,0 +1,11 @@
|
||||
## 输入输出约定(XFeat 稀疏特征)
|
||||
评测时平台在主机上做预处理,把图喂给你的模型,再用官方 XFeat 的稀疏后处理解读输出,在 HPatches 上评测匹配效果。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,`1x1x480x640` float32。预处理在主机侧,图里不要再做:RGB 用 cv2 线性插值缩放到 640×480,`/255`,再对 3 个通道求平均,得到灰度图。官方网络内部自带的 InstanceNorm 等仍然留在图里。
|
||||
|
||||
**输出**:3 个,和官方 `XFeatModel.forward`(`modules/model.py`)的返回值完全一致,顺序如下:
|
||||
1. `feats` `[1, 64, 60, 80]`:稠密描述子,原始值,不做 L2 归一化;
|
||||
2. `keypoints` `[1, 65, 60, 80]`:关键点 logits(每个格子 8×8=64 个位置,加 1 个 dustbin),不做 softmax;
|
||||
3. `heatmap` `[1, 1, 60, 80]`:可靠性图,就是官方 heatmap head 的输出。
|
||||
|
||||
**平台后处理**:官方 `detectAndCompute`(top_k 1024,detection_threshold 0.05),包括 softmax、上采样 8 倍、NMS、乘以可靠性、取前 1024 个点、采样描述子并做 L2 归一化。
|
||||
15
agent/io-contracts/yolox_common.md
Normal file
15
agent/io-contracts/yolox_common.md
Normal file
@ -0,0 +1,15 @@
|
||||
## 输入输出约定(YOLOX)
|
||||
评测时平台在主机上做预处理,把图喂给你的模型,再用平台自己的后处理解读输出。图的输入输出必须严格按下面的约定,形状对、含义错,精度会直接崩,而且没有任何报错。
|
||||
|
||||
**输入**:1 个,`1x3xSxS` float32(S 见 job.json 的 `input_spec`,tiny 是 416,其余 640)。预处理在主机侧,图里不要再做:
|
||||
- BGR 通道顺序,像素值 0–255,不减均值、不除方差;
|
||||
- 等比缩放到长边 S,放在左上角,其余用 114 填充(官方 `ValTransform(legacy=False)`)。
|
||||
|
||||
**输出**:1 个,`[1, N, 85]` float32,N = (S/8)² + (S/16)² + (S/32)²(640 时是 8400)。
|
||||
- 行的顺序:先 stride 8 的所有格子,再 16,再 32;每层内按行优先(先 y 后 x)。
|
||||
- 每行:`[cx, cy, w, h, obj, cls_0 … cls_79]`。
|
||||
- `cx, cy, w, h` 是已经解码好的框,单位是输入图(S×S)上的像素:`cx = (tx + grid_x) * stride`,`w = exp(tw) * stride`。
|
||||
- `obj` 和 80 个类别分数都已经过 sigmoid,是 0–1 的概率。
|
||||
- 这和官方 YOLOX 在 `model.head.decode_in_inference = True` 时 `model(x)` 的输出一致。
|
||||
|
||||
**平台后处理**:分数 = obj × 类别概率,阈值 0.01,NMS 0.65,再按缩放比例还原到原图。
|
||||
@ -9,6 +9,10 @@ job.json:`{job_json}`(只读) 数据:`{data_dir}`(只读) 你的
|
||||
3. G3 任务精度:板上 T1 子集({t1_n} 张)的 {g3_metric} 与同一子集的 FP32 基线比较,容差 {g3_tol}({g3_kind})
|
||||
4. G4 速度:不比平台默认量化配置(compile.yaml 只写两项必填)编出的模型慢 1.5 倍以上。参考在 `$BENCH_ROOT/agent/speed_ref/{job_id}.json`:`latency_ms_est` 是默认配置的编译器静态估计,不含落到 CPU 的算子;文件还没有表示还在算,值为 null 表示默认配置没编出来、本题没有参考。
|
||||
|
||||
两条硬规定,违反任何一条都不算通过:
|
||||
- 本题是 int8 量化。`all_node_type`,或者整类计算算子(Conv、MatMul、Gemm 等;用 op_config,或者逐节点列出超过同类节点的一半)设成 int16、float16 或 float32,都判不通过。只把少数敏感节点设成 int16 可以。
|
||||
- 板上实测延迟超过同题默认 int8 配置板上实测的 1.5 倍,判不通过(G4 参考文件里是默认配置的编译器静态估计,可以当量级参考)。
|
||||
|
||||
缺少板上精度结果不能报完整 PASS;缺权重、工具或材料时如实保留实际错误。
|
||||
|
||||
## 输入和可复用缓存
|
||||
|
||||
@ -39,6 +39,14 @@ def _render(tmpl: str, **kw) -> str:
|
||||
return out
|
||||
|
||||
|
||||
def _io_contract(model: str) -> str | None:
|
||||
"""The evaluator feeds the graph and decodes its outputs with the platform's own code (harness/adapters), which
|
||||
the agent no longer sees; agent/io-contracts states what those inputs and outputs mean, per model family."""
|
||||
index = json.loads((paths.AGENT / "io-contracts" / "index.json").read_text())
|
||||
name = index.get(model.replace(".", "_").replace("-", "_"))
|
||||
return (paths.AGENT / "io-contracts" / name).read_text().strip() if name else None
|
||||
|
||||
|
||||
def _recipe_prompt(tmpl: str, job: dict) -> str:
|
||||
"""Describe tool inputs, not an exploration order, for a task-local submission."""
|
||||
before, marker, remainder = tmpl.partition("## 输入和可复用缓存\n")
|
||||
@ -47,7 +55,7 @@ def _recipe_prompt(tmpl: str, job: dict) -> str:
|
||||
raise ValueError("recipe prompt requires the standard input/workflow and budget sections")
|
||||
policy = json.dumps(job["model_recipe"]["reference"], indent=2, ensure_ascii=False)
|
||||
body = """## 工作区与提交
|
||||
你可以复用只读的 `harness/adapters/`,复制到 workspace 修改,也可以自行实现模型接入、修改导出代码或直接修改 ONNX。由你决定探索顺序和重试方法;配方只用于提交这一版实际需要的文件,不是开始工作的前置条件。
|
||||
你可以自行实现模型接入、修改导出代码或直接修改 ONNX。由你决定探索顺序和重试方法;配方只用于提交这一版实际需要的文件,不是开始工作的前置条件。
|
||||
|
||||
任务、数据、验收标准以 job.json 为准。以下官方参考由平台固定,执行参考基线时核对源码和权重摘要,不能用候选代码代替:
|
||||
```json
|
||||
@ -191,6 +199,8 @@ def prepare(run_id: str, job_id: str, kk: int, mode: str, policy: str, dry_run:
|
||||
# Insert the fixed policy after placeholder expansion so literal braces
|
||||
# inside its file names/metadata are never interpreted as template keys.
|
||||
prompt = _recipe_prompt(prompt, job)
|
||||
if contract := _io_contract(job["model"]):
|
||||
prompt += "\n\n" + contract + "\n"
|
||||
if dry_run:
|
||||
return rd, job, prompt
|
||||
(rd / "agent" / "prompt.md").write_text(prompt)
|
||||
|
||||
@ -91,10 +91,9 @@ def bundle(path: Path, ws: Path, uploads: list, request: dict) -> None:
|
||||
tar.addfile(info, io.BytesIO(data))
|
||||
for rel in uploads:
|
||||
tar.add(ws / rel, 'ws/' + rel, recursive=False)
|
||||
for name in salty_remote.CODE_DIRS: # harness tools (export_onnx, adapters) for the agent to reuse
|
||||
if (paths.BENCH_ROOT / name).is_dir():
|
||||
tar.add(paths.BENCH_ROOT / name, f'code/{name}',
|
||||
filter=lambda m: None if '__pycache__' in m.name or m.name.endswith('.pyc') else m)
|
||||
# Only what the sandbox itself needs (onnxruntime thread cap): platform code (adapters, export tools, the
|
||||
# evaluator and gates) would do the model-specific half of the task for the agent.
|
||||
tar.add(paths.BENCH_ROOT / 'harness/container_site/sitecustomize.py', 'code/harness/container_site/sitecustomize.py')
|
||||
|
||||
|
||||
def install(ws: Path, archive: Path, result: dict) -> list:
|
||||
|
||||
@ -125,7 +125,6 @@ def main():
|
||||
real = (bench / name).resolve()
|
||||
if real != bench / name:
|
||||
save(real)
|
||||
save(bench / 'harness/adapters')
|
||||
save(bench.parent / '.horizon')
|
||||
save(jd / 'job.json')
|
||||
if not natural:
|
||||
|
||||
@ -97,6 +97,16 @@ class AgentFirst(unittest.TestCase):
|
||||
self.assertFalse((self.jd/'preparation').exists())
|
||||
self.assertFalse((self.jd/'rollouts').exists())
|
||||
|
||||
def test_e2e_prompt_ends_with_the_model_familys_io_contract(self):
|
||||
self.test_agent_prompt_starts_without_export_or_baseline_and_does_not_run_them()
|
||||
_, _, prompt = rollout.prepare("run", "model", 0, "e2e", "teacher", dry_run=True)
|
||||
self.assertNotIn("输入输出约定", prompt) # no contract written for this model
|
||||
self.job["model"] = "yolox.s"
|
||||
self.save_job()
|
||||
_, _, prompt = rollout.prepare("run", "model", 0, "e2e", "teacher", dry_run=True)
|
||||
self.assertIn("## 输入输出约定(YOLOX)", prompt)
|
||||
self.assertIn("decode_in_inference = True", prompt)
|
||||
|
||||
def test_e2e_prompt_ignores_missing_and_corrupt_oracle_results(self):
|
||||
self.test_agent_prompt_starts_without_export_or_baseline_and_does_not_run_them()
|
||||
_, _, expected = rollout.prepare("run", "model", 0, "e2e", "teacher", dry_run=True)
|
||||
|
||||
@ -93,6 +93,7 @@ def main():
|
||||
usage_log_check()
|
||||
memory_escalation_check()
|
||||
dev_memory_check()
|
||||
dev_bundle_check()
|
||||
partial_describe_check()
|
||||
async_cleanup_check()
|
||||
cleanup_result_check()
|
||||
@ -260,6 +261,19 @@ def dev_memory_check():
|
||||
assert list(salty_dev.local_files(ws)) == ["a.py"]
|
||||
|
||||
|
||||
def dev_bundle_check():
|
||||
"""bench dev carries only the sandbox's own sitecustomize: no adapters, export tools, evaluator or gates."""
|
||||
from harness import salty_dev
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
ws = Path(tmp) / "ws"
|
||||
ws.mkdir()
|
||||
(ws / "a.py").write_text("x")
|
||||
salty_dev.bundle(Path(tmp) / "b.tar", ws, ["a.py"], {"dev": {}})
|
||||
with tarfile.open(Path(tmp) / "b.tar") as tar:
|
||||
names = sorted(tar.getnames())
|
||||
assert names == ["code/harness/container_site/sitecustomize.py", "request.json", "ws/a.py"], names
|
||||
|
||||
|
||||
def usage_log_check():
|
||||
import threading, time
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user