Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/campaign-acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ body:
id: criteria_source
attributes:
label: Acceptance criteria source and derivation
description: Use user criteria when supplied; otherwise use performance-ceiling-analysis. Preserve partial requirements and identify derived fields and missing evidence.
description: Preserve supplied criteria. Review both supplied and derived performance goals against workload-matched baseline noise and attainable headroom using performance-ceiling-analysis.
value: |
Source: <user | ceiling-derived | mixed>
User request or accepted plan: <reference or none>
Derived fields: <fields or none; preserve supplied criteria>
Analysis: <skill revision, baseline, calibration, attainable range, uncertainty and target-selection rationale, or not needed>
Target feasibility: <skill revision, baseline samples, calibration, attainable range, uncertainty and whether the proposed gain is supported>
Evidence gaps and next measurements: <paths or none>
Freeze authority: <existing user or delegated authority>
validations:
Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Parameterized or manual acceptance runs are issue-scoped; they are not the defau
## RSI contract

- **Resolve acceptance criteria** — preserve user-supplied criteria; when absent, use [performance-ceiling-analysis](src/inferrsi/knowledge/data/skill_library/playbooks/measurement/performance-ceiling-analysis/references/acceptance-criteria.md) to derive evidence-backed campaign targets. Retain partial requirements and derive only missing fields; unresolved evidence stays explicit.
- **Check performance target feasibility** — review supplied and derived gains against repeated baseline measurements and calibrated attainable performance for the same workload. New project campaigns require the [target review](docs/guides/optimization-workflow-unification.md#performance-target-review) before freezing. Preserve the requested goal and report missing evidence or an unsupported target.
- **Freeze gates before search** — checklist and `validator/` locked in `plan/` before Phase 3 candidate experiments ([validation levels](docs/contributing.md#validation-levels)).
- **One plane per campaign step** — change only the declared SIAS plane of the target system per step: `harness` | `model` | `infra`. These planes are not InferRSI packages.
- **Emit RunSpec snapshots** — record repo × revision × backend × device × model × scenario (`contracts/runspec.py`, campaign `plan/`).
Expand Down
5 changes: 5 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ Record any hardware, external service or historical run that was not verified.

## Acceptance checklist

Assess the feasibility of every new project performance target, including a value
supplied by the requester. Record the actual target, its origin, comparable baseline noise and
the attainable gain supported by calibration before freezing. See the
[mandatory project target review](guides/optimization-workflow-unification.md#performance-target-review).

Use user-provided acceptance criteria, including those in a referenced accepted
plan. When none are supplied, use
[performance-ceiling-analysis](../src/inferrsi/knowledge/data/skill_library/playbooks/measurement/performance-ceiling-analysis/references/acceptance-criteria.md)
Expand Down
43 changes: 42 additions & 1 deletion docs/guides/optimization-workflow-unification.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,57 @@ Harness 没有常驻 Agent 驱动。Agent 逐次调用这些操作,代码在
```bash
inferrsi campaign start --directory <campaign-dir-outside-project> \
--repo <editable-project> --include <source-dir> --include <config-file> \
--protocol <acceptance-dir> --instructions <task.md> \
--protocol <acceptance-dir> --instructions <task.md> --target-review <review.json> \
--measure-command '"{python}" "{protocol}/measure.py" --project "{candidate}" --result "{result}"' \
--quality-command '"{python}" "{protocol}/quality.py" --project "{candidate}" --reference "{baseline}" --result "{result}"' \
--metric-key <json.field> --metric-unit <unit> --direction <maximize-or-minimize> \
--device-scope <device-model-and-topology> \
--quality-key <json.boolean-field> --scope <actual-validation-scope> \
--min-improvement-pct <agreed-gate> --warmups <count> --repetitions <count> \
--rounds <limit> --round-mode up_to --max-minutes <total-budget> \
--evaluation-timeout-seconds <per-evaluation-budget> --knowledge on
```

#### Performance target review

每个新项目在冻结前都要检查目标是否合理,包括用户明确给出的数值和准备实验时推导的数值。先按同一硬件、模型、请求、计时边界与质量约束运行基线多次,再根据同条件实测或经实测校准的关键路径估算,给出保守可达的端到端指标值。只测了单算子提速时,还要量出它在端到端关键路径上的占比。原始测量、假设和目标选择依据应可在引用的记录中复核。

目标声明与校准记录使用两个 JSON 文件。以下数值仅用于演示。命令行的目标、指标、单位、方向与声明必须一致。`review.json` 区分用户指定的门槛(`user`)和有依据的推导(`derived`)。

```json
{
"calibration": "calibration.json",
"objectives": {
"latency": {"source": "derived", "target": 3, "target_reference": "Synthetic plan, latency section"}
}
}
```

`calibration.json` 由基线测量和可达性分析产生。路径相对于 `review.json`。以下示例的 `baseline_snapshot` 需要替换为测量时实际源码的标识。可用 `inferrsi.harness.candidates.identity(Path(repo), includes)` 获取,`includes` 与 `--include` 相同。`scope` 与 `device_scope` 分别对应 `--scope` 和 `--device-scope`。

```json
{
"context": {
"baseline_snapshot": "<measured-source-identity>",
"scope": "single-image latency after warmup", "device_scope": "two synthetic accelerators"
},
"objectives": {
"latency": {
"metric": "latency", "unit": "s/image", "direction": "minimize",
"threshold_type": "relative_percent", "method": "calibrated_projection",
"baseline_samples": [50, 50.25, 50.5], "attainable_value": 47,
"calibration_evidence": "Synthetic trace T1 and matched component replay C1: removing 3.25 s of exposed work leaves 47 s at the median."
}
}
}
```

校准方法可选 `workload_measurement`(相同负载下的已知可达结果)或 `calibrated_projection`(用同负载实测校准的保守推算)。给出记录位置和假设。已达到的收益可以支持目标;更高的目标只说明当前证据不足以支持它。程序校验声明、来源匹配及算术,校准材料本身的真实性由实验记录和评审核实。

样本和可达值使用指标原单位。评估器根据指标方向,将基线最大值与最小值之差换算为观测波动,将基线中位数到可达值的变化换算为可达收益,两者与目标使用同一种改变量单位。观测波动用于准备实验,不提供置信区间。

缺少校准数据、目标高于可达收益、或正的观测波动大于等于目标时,启动失败且不会创建实验目录。零门槛只适用于观测波动为零且有正收益空间的情况。找不到合适目标时保留用户的原始要求,补齐证据或重新协商。通过时,启动输出和冻结计划保留 `target_review` 及每项目标的判断。实际收益和质量仍由 round 与独立 final 评估。

`{candidate}` 在基线步骤指向留存基线,在候选步骤指向本轮快照;`{baseline}` 始终是基线。`{protocol}` 指向冻结协议,`{result}` 是本步骤输出文件。脚本需从这些路径读取项目和条件;已有 editable 安装、绝对导入或外部服务不会被自动改成候选版本。Agent 必须验证脚本确实测到指定版本。

项目适配器先检查基线和候选质量,再做 warmup 和交替顺序的基线/候选测量;每轮和 final 使用相同协议。每步骤启动新进程,因此跨进程 warmup 只能预热可持久缓存;设备/进程内 warmup 必须在测量脚本内完成并说明。性能取声明指标的中位数,当前没有通用服务生命周期管理器或统计显著性判定。
Expand Down
17 changes: 15 additions & 2 deletions docs/guides/service-reuse-campaigns.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ supply `--evaluation-config <protocol.json>` and omit the AB/BA single-metric,
quality-command and sampling flags. Mixing both parameter sets is an error.

```text
inferrsi campaign start --evaluation-mode service_reuse --evaluation-config <protocol.json> ...
inferrsi campaign start --evaluation-mode service_reuse --evaluation-config <protocol.json> --target-review <review.json> ...
inferrsi campaign baseline --session <campaign>
inferrsi campaign diagnose --session <campaign> --bottleneck <description> --evidence <summary.txt>
inferrsi campaign knowledge --session <campaign> --query <cue> --context-bytes <bytes>
Expand Down Expand Up @@ -198,7 +198,20 @@ retry is inferred. `resume --reason <text>` records an advisory-pause or explici
abandonment decision; it does not make an incomplete attempt pass or satisfy an
exact-round policy.

If conditions change, use `refresh-references --conditions <json> --reason <text>`.
A new service campaign requires the [performance target review](optimization-workflow-unification.md#performance-target-review).
Use `context.conditions` for the complete effective conditions and `context.baseline_revision`
for the baseline Git commit. Copy the protocol’s full scenario list into `context.scenarios` so
a reused scenario ID cannot substitute another workload or request count. Key each gain objective by its ID in both files and include
its scenario, aggregate, metric key, unit, direction and threshold type in calibration.
The target declaration carries its exact gain threshold.
Baseline samples and the attainable value use the metric's units and domain. The review
uses the configured mean or median and the same relative-percent, absolute or percentage-point
change as the evaluator. It records every decision. At least one gain objective must be
supported, matching the service's any-gain rule. All runtime regression guards still apply.

If conditions change, supply a new review with
`refresh-references --conditions <json> --target-review <review.json> --reason <text>`.
An explicit retry reuses the failed attempt's review.
This requires room for a new candidate round; when the round budget is exhausted,
the command rejects the refresh before changing conditions or starting a service.
It measures the original baseline and comparison parent under the new conditions
Expand Down
7 changes: 7 additions & 0 deletions plugins/inferrsi/skills/inferrsi/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ Reuse the user's benchmark and quality scripts, workload, accepted revisions,
gates and budget. If they are missing, help prepare them and name the remaining
inputs. Do not turn CLI defaults into accepted campaign criteria.

Before freezing any project performance goal, apply the performance-ceiling-analysis
procedure to evaluate the proposed target against comparable baseline variation
and calibrated end-to-end headroom. Preserve the source of each target. Pass the
calibration and rationale to `campaign start --target-review <file>`; the Harness
computes the feasibility decision before freezing. Revisit unsupported goals or
collect missing evidence without silently relaxing a user requirement.

Use supplied acceptance criteria unchanged, including a referenced accepted
plan. When none are supplied, read
`inferrsi.common.skills.performance_ceiling_analysis` with `--material` through
Expand Down
7 changes: 7 additions & 0 deletions plugins/workswarm/inferrsi/skills/inferrsi/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ candidate within this workflow.

## Coordinate a comparison

Before freezing any project performance goal, apply the performance-ceiling-analysis
procedure to evaluate the proposed target against comparable baseline variation
and calibrated end-to-end headroom. Preserve the source of each target. Pass the
calibration and rationale to `campaign start --target-review <file>`; the Harness
computes the feasibility decision before freezing. Revisit unsupported goals or
collect missing evidence without silently relaxing a user requirement.

Use supplied acceptance criteria unchanged, including a referenced accepted
plan. When none are supplied, use the launcher to
`read inferrsi.common.skills.performance_ceiling_analysis --material`, then load
Expand Down
5 changes: 5 additions & 0 deletions src/inferrsi/apps/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,12 @@ def _optimization_actions(stages, *, project=False):
help="Project-relative input file/directory; repeat for dependencies")
start.add_argument("--protocol", type=Path, required=True)
start.add_argument("--instructions", type=Path, required=True)
start.add_argument("--target-review", type=Path, required=True,
help="JSON evidence for baseline noise and attainable gains")
for name in ("measure-command", "quality-command", "metric-key", "metric-unit",
"quality-key", "scope"):
start.add_argument("--" + name)
start.add_argument("--device-scope", help="AB/BA calibration device model and topology")
start.add_argument("--direction", choices=("minimize", "maximize"))
start.add_argument("--min-improvement-pct", type=float)
start.add_argument("--repetitions", type=int)
Expand Down Expand Up @@ -269,6 +272,8 @@ def _optimization_actions(stages, *, project=False):
)
if name == "refresh-references":
stage.add_argument("--conditions", type=Path, required=True)
stage.add_argument("--target-review", type=Path,
help="Calibration for the new conditions")
stage.add_argument("--reason", required=True)
if name == "resume":
stage.add_argument("--reason", required=True)
Expand Down
12 changes: 12 additions & 0 deletions src/inferrsi/harness/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,7 @@ def service_command(root, args, *, ranking_policy_for=None, knowledge_reader=Non
raise ValueError("Unknown service campaign action")
initial, parent = state["initial_reference"], state["comparison_parent"]
admission = None
refresh_review = None
if kind == "baseline":
if initial is not None:
raise ValueError("Initial baseline is already measured")
Expand Down Expand Up @@ -1591,6 +1592,11 @@ def service_command(root, args, *, ranking_policy_for=None, knowledge_reader=Non
raise ValueError("No changed conditions; reuse compatible retained references")
if conditions["id"] == state["conditions"]["id"]:
raise ValueError("Changed conditions require a new explicit ID")
if "target_review" in plan["evaluation_settings"]:
refresh_review = service.review_service_targets(
args.target_review, conditions, plan["baseline_revision"],
plan["evaluation_settings"],
)
state.update(
conditions=conditions,
reference_epoch=state["reference_epoch"] + 1,
Expand All @@ -1600,6 +1606,10 @@ def service_command(root, args, *, ranking_policy_for=None, knowledge_reader=Non
state["stagnation"].update(consecutive=0, notified=False)
elif conditions != old["conditions"]:
raise ValueError("Reference retry must retain its declared conditions")
elif args.target_review:
raise ValueError("Reference retry reuses the retained target review")
else:
refresh_review = old.get("target_review")
source, commit = root / plan["baseline_path"], plan["baseline_revision"]
candidate_id, number = "reference-refresh", None
else:
Expand Down Expand Up @@ -1675,6 +1685,8 @@ def service_command(root, args, *, ranking_policy_for=None, knowledge_reader=Non
pending.update(refresh_initial=initial, refresh_parent=parent)
if kind == "round":
pending.update(diagnosis)
if refresh_review is not None:
pending["target_review"] = refresh_review
state["pending"] = pending
atomic_write_json(root / "state.json", state)
try:
Expand Down
Loading
Loading