Skip to content

Attribute Qwen candidate shape errors only after baseline recheck - #588

Merged
Dong1017 merged 10 commits into
mainfrom
bot/issue-509
Nov 25, 2026
Merged

Dong1017 merged 10 commits into
mainfrom
bot/issue-509

Conversation

@Dong1017

@Dong1017 Dong1017 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Governing Issue and delivery slice

Refs #509

Accepted scope / delegation. The #509 owner delegated the R7 compute-time attribution slice to the PR pool. The R7 design review records the positive attribution and same-worker baseline recheck requirements. The delivery covers the two files below, with synthetic CPU validation. Anchors touched: none.

  • src/inferrsi/benchmark/tasks/qwen21-denoise-npu/benchmark.py implements attribution and the baseline recheck.
  • tests/campaigns/test_qwen21_task.py covers the rule through the standalone CPU worker and harness. The path follows the test layout on main.

Attribution and baseline recheck

  • Only the submitted compute call is eligible, after the trusted baseline passed for the same frozen case. A plain RuntimeError must match a complete host shape diagnostic, have a native call site, and leave the received configuration and arguments intact. The worker compares container types, ordered dictionary keys, tensor identities, tensor layout and bits. An argument change such as an added empty dictionary stops attribution before replay. Attribution is limited to the first candidate call.
  • An isolated worker uses the frozen snapshot and restores supported global RNG state before importing the candidate. Before attribution, the caller compares the frozen source IDs, case, phase, configuration, argument layout and bits, and a digest of RNG state alongside the captured Torch settings. The replay must identify the same failing instruction and error, and the recorded ATen operator must reproduce the exact diagnostic on host copies of its arguments.
  • NumPy is optional. When available, its global RNG is initialized before candidate import, and its dictionary state records the bit-generator type and nested values. Failed RNG capture leaves ordinary candidate execution available. A shape error with missing or mismatched replay evidence remains INCONCLUSIVE.
  • A confirmed candidate contract error becomes candidate_failure only after the same worker passes one trusted-baseline recheck using fresh copies of pristine case inputs and baseline-owned parameters. It consumes one round and allows the next round and final evaluation to proceed. Unknown, device, synchronization, and failed-recheck errors remain INCONCLUSIVE and block the session.
  • Replay covers interpreter flags, starting environment and working directory, frozen task files, the captured global RNGs and Torch settings, and the compared arguments. The two workers can still differ in PID, time, argv, Python's per-process hash secret, separately created generators, files outside the snapshot, other processes and device memory. The worker enforces the contract-error recheck and the shared assessor consumes its receipt.

Checks

  • On Windows CPU, the empty-parameter reproduction on d283ecbe was incorrectly classified as a candidate failure. The current head passed 15 selected tests covering the new argument-structure regressions, unchanged arguments with valid candidate-error attribution, and unavailable NumPy state. The import gate and Ruff also passed on this head.

  • Windows CPU, PyTorch 2.15.0+cpu and NumPy 2.5.5: all five NumPy regression cases passed on the preceding head d283ecb. A seven-case replay run also passed during development, including the existing Python/Torch global RNG and process-state mismatch regressions. The local retry used one compute thread and a 240-second test subprocess wait after the default 60-second wait expired. The checked-in test timeout is unchanged.

  • pytest tests/repository/test_target_module_import_gate.py and ruff check src tests tools: passed on the preceding head d283ecb.

  • The Windows full suite stopped at the Apps revision-byte assertion on LF versus CRLF. The Apps test and implementation match main.

Named regressions include test_shape_message_requires_one_complete_template_with_conflicting_sizes, test_attributable_candidate_shape_error_consumes_one_round_after_baseline_recheck, test_harness_continues_only_after_attributed_contract_rejection, test_numpy_state_preserves_import_and_compute_draws_in_replay, test_numpy_rng_state_does_not_interrupt_a_correct_candidate, and test_unavailable_numpy_state_keeps_shape_error_inconclusive.

Delivery boundary and remaining Issue work

This slice is limited to task-local compute-time attribution. Generic CandidateExecutionError wrapping, the shared assessor and harness, scoring, the frozen protocol, evidence trees, and campaign claims are outside its delivery boundary.

#509 tracks task-aware knowledge delivery (P0.1), attempt and retry accounting and knowledge admission (P1), and measurement (P2). The #509 owner controls goal acceptance.

The original R7 diagnostic has no public raw log. Its classification and the Ascend NPU path remain unverified.

Knowledge authorship declaration

{"schema_version":1,"head_sha":"c499ec3843c6cc0f8f54a4c061e8c618036e61ee","human_only":false,"material_ai_authors":[{"tool":"Claude Code","model_id":"claude-opus-5-5","effort":"xhigh","role":"author"},{"tool":"Codex","model_id":"unknown","effort":"unknown","role":"author"}]}

The initial PR was posted by Dong-bot on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

A RuntimeError raised inside the submitted Qwen denoiser compute call is
now rejected as a candidate failure only when two things hold: the message
contains a recognized host-side PyTorch shape/contract diagnostic and no
device, runtime or synchronization marker, and the same case's trusted
baseline, which already passed, passes again on pristine inputs in the
same worker. The rejection uses one round and keeps the earlier best, so
the session can continue to the next round and final.

Device-reported shape errors, device or synchronization faults, a failed
baseline recheck and unrecognized runtime errors still return
infrastructure_failure / INCONCLUSIVE and block the session.

The recheck-gated rejections share one CandidateRecheckedError base.
CandidateDependencyError keeps its record keys. The new
CandidateComputeContractError records contract_failure. The task assessor
requires the retained baseline recheck for both failure kinds. TASK.md
documents the rule.

The device marker list avoids bare "npu" and lowercase "cann" because
they occur in "input" and "cannot", which would veto the recognized
messages.

CPU regressions drive the real worker and real baseline math. A genuine
shape bug uses exactly one round, and the next round and final still run.
A device/synchronization failure, a device-reported shape error or a
failed baseline recheck stays INCONCLUSIVE and blocks progression.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <[email protected]>

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS

本轮首次实现检视:base 0e6b4ea9f42e477787df2c33367396d8b12438da → head e6a539a1c5f0f1f7b34d61d0c3e7833863bddb5a(1 个提交、4 个文件)。对照 #509 上轮设计检视。设计上要求的同一 worker、干净输入、独立基线参数复检已接上;本轮还不能批准实现。

  1. 不能把「含 shape 片段且未命中已知设备字样」当作正向归因。 benchmark.py L102–112 仅查异常字符串,不区分诊断来源。我隔离运行当前提交的原始分类函数时,带 shape 片段的 device lost 和 backend device unavailable 错误都被包装成 CandidateComputeContractError。如果同一 worker 随后恢复、基线复检通过,worker 的分类 会把这次设备故障记作候选 FAIL;assessor 和 harness 会允许消耗一轮并继续。请只在有可信的 host shape/契约证据时走候选拒绝;来源不明或有设备故障迹象仍应 INCONCLUSIVE。加一个「带 shape 片段的设备/后端错误、基线仍健康」的负例,验证不会消耗候选轮次或推进到下一轮/最终评估。仅补这两个否决词不能解决来源不明的问题。
  2. 对齐交付范围。 #509 的实现边界 列的是 benchmark.py 和 tests/test_qwen21_task.py;本 PR 还改了 optimization.py 的 assessor 验收和 TASK.md。assessor 的证据门槛有价值,但涉及哪些拒绝结果能推进。请在 #509 明确确认这两处纳入本次交付,或把它们拆出。

已独立阅读四文件 diff、复检/assessor 和 harness 推进路径,执行了 6 个隔离分类用例(普通 shape、基线未验证、未知错误、已识别 NPU 标记以及上述两个反例)。未重新跑 worker/pytest 全套、真实 NPU 或历史 R7,也未查看 CI;合成用例只验证该分类边界,不证明历史 R7 的根因。

@Dong1017 Dong1017 added area:benchmark Benchmark line: preparation ports, metric contracts, validators, and isolated workers kind:task Bounded delivery task with a delegated slice labels Nov 22, 2026
The Qwen worker no longer treats "contains a shape fragment and no known
device marker" as candidate attribution. A RuntimeError from the submitted
compute call becomes a recheck-gated contract rejection only when all of
the following hold:

- it is a plain, unchained RuntimeError (no subclass, no __cause__ and no
  __context__);
- its complete message is one recognized PyTorch host shape-check message
  (an optional mm:/addmm: prefix only), with no other wording before or
  after;
- the sizes in that message actually conflict when rechecked on the host,
  using PyTorch's own rules for mm, broadcasting, view/reshape inference
  and cat;
- the nearest traceback frame outside the torch package is the submitted
  source file, so no device runtime wrapper, other library or evaluator
  frame is between them.

Any other error, including device-lost or backend-unavailable reports
that embed a complete shape message, stays infrastructure_failure /
INCONCLUSIVE. The baseline recheck is not started, no round is charged as
a candidate FAIL, and the harness blocks before the next round or final.
The substring fragment list and the device-marker deny list are removed.
TASK.md describes the new rule.

Tests cover the reviewer's device-lost and backend-unavailable messages
at three levels: the classifier, the real CPU worker with a healthy
baseline, and harness progression. They also cover suffixed and
multi-line messages, sizes that do not conflict, RuntimeError subclasses,
chained errors, errors raised by a foreign runtime frame, and positive
controls (older unprefixed messages, inferred view shapes, a core-torch
Python frame and an inference_mode-decorated entry).

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <[email protected]>
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

感谢检视。逐条回复如下(本轮基于 head e6a539a1 修改)。

Details

1. 只凭「含 shape 片段且未命中设备字样」做正向归因

已修复,改为只认正向证据。 删除了片段子串匹配(CANDIDATE_CONTRACT_DIAGNOSTICS)和设备字样否决表(DEVICE_DIAGNOSTIC_MARKERS),没有采用补否决词的做法。benchmark.py 新增 host_shape_diagnostic(),只有四项条件同时满足,才包装成 CandidateComputeContractError,之后仍要走原有的同 worker 基线复检:

  1. 普通、未链接的 RuntimeError:type(error) is RuntimeError,且 __cause__、__context__ 都为空。子类(设备/内存类错误、候选自定义子类)和在处理其他异常时抛出的错误都不归因。
  2. 完整消息恰好是一条 PyTorch host 侧 shape 检查消息:用 HOST_SHAPE_DIAGNOSTICS 做 fullmatch,只接受可选的 mm: / addmm: 前缀(新版 torch 带这个前缀,旧版不带)。前后多出任何文字或多一行,都视为来源不明。所以 device lost: <shape 消息>、backend device unavailable: <shape 消息>、<shape 消息> (device lost) 都不归因。
  3. 消息里的尺寸在 host 上复算确实冲突:mm 比较内维;broadcast 要求两边不等且都不为 1;view/reshape 使用与 PyTorch infer_size 相同的接受条件;cat 比较 expected 和 got。尺寸其实不冲突的消息不归因。
  4. 来源是提交的代码:在 traceback 中跳过 torch 包内的帧后,最近的调用帧必须是候选源文件,比较时会先 inspect.unwrap,兼容 @torch.inference_mode() 这类装饰器。如果中间隔着 torch_npu 等运行时封装、其他库或评测器的帧,就不归因。

不满足任一条件时,原异常照常抛出:结果为 infrastructure_failure / INCONCLUSIVE,不启动基线复检,不按候选 FAIL 计入轮次,harness 进入 blocked。

按要求新增的负例(「带 shape 片段的设备/后端错误、基线仍健康」),覆盖三层:

  • 分类函数:你给的两条消息,以及加后缀、多行、未知前缀、尺寸不冲突、RuntimeError 子类、raise ... from、处理中异常(context)、外部运行时帧抛出等情形,都不归因。正向对照包括旧版无前缀消息、带 -1/0/空 shape 的 view,以及真实 torch 的 broadcast_tensors(异常从 torch/functional.py 抛出)加 inference_mode 装饰的入口。
  • 真实 CPU worker:device_lost_shape_error、backend_unavailable_shape_error 两种情形下,基线 correctness 先 PASS(基线健康),候选抛错后退出码为 1,infrastructure_failure / INCONCLUSIVE;没有 contract_failure、baseline_recheck、failure_kind,calls 只有 ("baseline", "correctness", "PASS");assessor 判 INCONCLUSIVE。
  • harness:同样两种情形下,第 1 轮为 infrastructure_failure,状态 blocked,best 仍为 baseline;下一轮和 final=True 都以 blocked 被拒,不推进到下一轮,也不推进到最终评估。

反向核对:PR head 的分类函数把你给的两条消息都包装成了 CandidateComputeContractError,修订后保持原异常。临时换回 PR head 的 benchmark.py 后,上面 4 个 worker/harness 新负例全部失败;恢复修订版后全部通过。

TASK.md 中对应段落已按新规则改写。

2. 交付范围(optimization.py assessor 门槛、TASK.md)

未改代码。这需要 #509 的 issue owner 拍板,我无法在 GitHub 上留言。 两处修改仍保留在 PR 中,供 owner 决定。我的建议和理由:

  • assessor 门槛建议纳入本次交付。 拆掉它不会收窄能推进的拒绝结果,反而会放宽:父提交的 assessor 只对 unsupported_candidate_dependency 检查保留的基线复检,其余 candidate_failure 直接接受。本 PR 让 worker 能产出 rejected_candidate_contract,如果拆掉这一处,这类结果就会在 assessor 不核对复检证据的情况下推进。
  • TASK.md 只是文档,不改变行为,拆出不影响判定。它在冻结快照的 identity 里,但 benchmark.py 的哈希本来也会变。
  • 如果 owner 决定拆出:把这两处恢复为父提交版本,并删除依赖 assessor 门槛的 test_contract_rejection_requires_retained_baseline_recheck。可以在下一轮修订中完成。

本轮运行的测试(CPU,torch 2.15.0+cpu)

  • python -m pytest -q tests/test_qwen21_task.py:92 passed,无 skip。
  • python -m pytest tests/test_qwen21_task.py tests/test_qwen_optimization_protocol.py tests/test_engineering_benchmarks.py tests/test_task_protocol_child.py tests/test_evaluator_loaders.py tests/test_engineering_benchmark_plugins.py:176 passed,1 failed。失败的是 test_task_protocol_child.py::test_descendants_left_running_are_stopped_with_the_child(cleanup: the protocol left a live process behind)。该用例在临时目录里写自己的合成 protocol,不加载本 PR 改动的文件。我没有进一步排查,也没有在 base 上复跑确认。
  • ruff check src/inferrsi/benchmark/tasks/qwen21-denoise-npu tests/test_qwen21_task.py:通过。
  • 上面「反向核对」中的 PR head 对照。

未验证 / 已知限制

  • 没有在真实 NPU / torch_npu 上运行。 910B 上 torch_npu 的 host shape 检查消息是否与 ATen 完全一致(是否附加 PTA ERR 后缀或其他算子前缀)尚未验证。如果不一致,NPU 上真实的候选 shape bug 会保持 INCONCLUSIVE 并阻塞,这是保守方向,不会误归因,但实际覆盖面可能比 CPU 测试小。
  • 没有复现历史 R7,R7 的原始错误文本未知,不能声称本改动修复了 R7。如果当时的诊断来自 torch_npu/aclnn,新规则下仍是 INCONCLUSIVE。
  • 分类只能证明「这是候选调用触发的 host shape 检查」。如果候选用设备数据(例如 .item())算出 shape,无法证明这些数值本身没有被设备故障破坏。本任务的 shape 来自 config 和输入。
  • worker 记录里的 round_consumed: true 是原有行为:候选导入后的所有结果都会带这个字段,本 PR 前后一致,Qwen assessor 和 harness 都不读取它。「不消耗轮次、不推进」由 infrastructure_failure 加 harness blocked 保证,见上面的 harness 测试。
  • 没有查看 CI。

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS

增量:e6a539a1c5f0f1f7b34d61d0c3e7833863bddb5a → 1d13cd1b47b29ba627c18246d426b39a7798ae75(1 个新增提交,base 仍为 0e6b4ea9f42e477787df2c33367396d8b12438da)。上轮检视。

已修复: 完整消息匹配、维度冲突检查和异常链检查,挡住了上轮携带额外设备/后端字样的反例;同一 worker 的可信基线复检路径仍保留。

仍阻塞: raised_by_submitted_source 只要求最靠里的非 Torch Python 帧来自候选文件,并不要求有 PyTorch 算子来源的证据。我隔离执行当前分类函数时,未导入 Torch,候选源码直接抛出一条格式、维度均符合模板的普通 RuntimeError,也会被归为 CandidateComputeContractError;新增的单测也明确把直接抛错当作成功归因。这证明的是消息和 Python 调用位置,不是文档所说的「由 core PyTorch shape check 抛出」。基线随后通过仍无法补证来源。请用可信算子或结构化契约证据确认归因;来源无法确认时保持 INCONCLUSIVE,并让普通直接抛错的用例不推进。不要把所有真实 C++ 算子都假定为必有 Torch Python 帧。

范围仍待确认: #509 R7 交付边界 仍列两文件;本轮未找到纳入 optimization.py 和 TASK.md 的明确范围更新,请确认或拆出。

我读了增量 diff、现有复检/assessor 边界,以及源码和回归用例;隔离验证了直接抛出模板错误仍被包装、带额外设备字样和维度不冲突的消息保持原异常。未运行完整 worker/pytest、真实 NPU 或历史 R7,未查看 CI。

A complete shape-check message plus a submitted Python frame no longer
attributes a candidate compute RuntimeError as a contract rejection. The
error must also carry interpreter evidence that native code raised it:
the innermost traceback entry stops at a call or operator instruction
(CALL, BINARY_OP and their Python 3.10 to 3.13 equivalents), in the
submitted file or in core PyTorch Python code that it called.

A raise statement stops at a raise instruction instead. A direct raise
of a template message, a raise in a nested helper, a re-raise of a copied
operator message and torch._check therefore stay infrastructure_failure /
INCONCLUSIVE. They start no baseline recheck, and the harness blocks
before the next round or final. Real C++ operators called directly from
the submission, such as `a @ b`, `x.view(...)` and `torch.cat`, have no
Torch Python frame and are still attributed. Nothing is attributed when
PyTorch is not loaded.

Message matching moves into shape_check_diagnostic. The traceback shows
that native code raised the error but does not say which native function
raised it. TASK.md now says this instead of "raised through core
PyTorch".

Tests split message evidence from source evidence. They cover the direct
raise at the classifier (with and without PyTorch loaded), the real CPU
worker and harness progression. Positive controls use real operators, a
core PyTorch Python frame and an inference_mode entry. Chained, context,
re-raised and foreign-runtime cases now use genuine operator errors.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <[email protected]>
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

感谢检视。逐项回复如下(基于 1d13cd1b 的工作区修改,尚未发布)。

Details

1. 阻塞项:raised_by_submitted_source 不证明算子来源 —— 已修改

原因确认: 复现成立。原函数只检查最靠里的非 Torch Python 帧是否为候选文件。在源码里直接写 raise RuntimeError("<模板消息>") 同样满足,未导入 Torch 时也满足。新增单测也确实把直接抛错当成了成功归因。

修改(benchmark.py):

  • raised_by_submitted_source 改为 raised_by_operator_call_in_submission,在原有的帧位置检查之上,要求解释器给出来源证据:
    • 最内层 traceback 条目的 tb_lasti 必须停在调用或运算符指令上(CALL / CALL_KW / CALL_FUNCTION* / CALL_METHOD / BINARY_* / INPLACE_* / COMPARE_OP / STORE_SUBSCR)。
    • Python 被调函数会留下自己的 traceback 条目;raise 语句停在 RAISE_VARARGS 上。因此这一条把「原生代码抛出」和「Python raise 语句抛出」区分开。
    • 该条目位于候选文件中,或位于候选调用的 core PyTorch Python 代码中。中间不得有其他库、运行时包装或评测帧(这一条沿用原规则)。
    • 进程中未加载 PyTorch 时,一律不归因。
  • 没有假定真实 C++ 算子一定有 Torch Python 帧。 候选文件里直接写的 a @ b、x.view(...)、torch.cat(...)、F.linear(...) 都没有 Torch Python 帧:最内层条目就是候选文件里的 BINARY_OP / CALL,照样归因。经由 torch.broadcast_tensors(functional.py)的路径,最内层条目是 core PyTorch 自己的原生调用,同样归因。
  • 消息判定拆为 shape_check_diagnostic(message),规则不变(完整模板匹配加维度冲突复核)。host_shape_diagnostic 依次要求:普通且无链的 RuntimeError、消息证据、来源证据。
  • TASK.md 删除了「raised through core PyTorch」的表述,改为写明 traceback 证据,并说明以下两点:
    • raise 语句(包括候选文件里的,以及复制算子原消息后重新抛出的)永远不构成来源证明。
    • 该证据不识别具体是哪个原生函数抛出的。

结果: 直接抛错、嵌套 helper 抛错、捕获后另行抛出算子原消息,以及 torch._check(False, lambda: <模板>)(Torch 内部的 Python raise):

  • 都保持 infrastructure_failure / INCONCLUSIVE;
  • 不启动基线复检;
  • harness 在下一轮和 final 之前 blocked。

仍存在的边界(如实说明,未消除): CPython 事后不会记录「哪个原生可调用对象抛出了异常」,所以这次证明的是「原生调用抛出」,不是「core PyTorch shape check 抛出」。故意构造的伪造仍能满足证据:

  • 例如 torch._assert_async(torch.tensor(0), "<模板消息>")——这是一个会原样抛出自定义消息的真实 C++ 算子,本地已验证会被归因;
  • 或者 ctypes、对已耗尽生成器调用 .throw(...)。

我没有加主动拦截(TorchFunctionMode 或 profile hook)去记录被调对象,理由有三:

  • 它要在候选调用期间常驻,会扰动计时;
  • 可能改变 torch.compile / 图捕获等候选行为;
  • 现有规则不允许重跑失败候选。

这类伪造不会给候选带来新能力:候选本来就能用错误形状的输出让自己 FAIL。如果借此把基础设施错误洗成候选失败,仍需同一 worker 内的基线复检通过。如果你认为必须识别被调算子身份才能推进,剩下的选项是去掉 shape 归因(全部保持 INCONCLUSIVE)。请指示,我按你的决定改。

2. 范围:optimization.py 和 TASK.md —— 需要 Issue 负责人确认,我无法代为确认

我不能向 GitHub 写入(包括在 #509 下更新交付边界),所以这一项需要 Issue 负责人在 #509 中明确确认或拒绝。两处修改的必要性:

  • optimization.py(RECHECK_REQUIRED): 不改的话,assessor 会把 failure_kind == "rejected_candidate_contract" 的拒绝直接接受为 FAIL,而不核对保留的同 case 基线复检记录。这削弱了你上轮确认保留的「可信基线复检」边界。test_contract_rejection_requires_retained_baseline_recheck 依赖这一处修改。
  • TASK.md: 这是面向 Agent 的失败语义契约,也在评测冻结快照(identity.json)中。行为改了而文档不改,会继续描述错误的规则。本轮修正的正是其中「raised through core PyTorch」这个过度表述。

如果负责人拒绝扩大范围,拆分方式是:把这两个文件恢复到 base,optimization.py 和 TASK.md 的修改另开 PR。代价是:在后续 PR 合入前,assessor 不会独立核验 contract 拒绝的复检证据。

测试(本地实际运行)

环境:CPython 3.11.18,PyTorch 2.15.0+cpu(为测试安装),无 NPU / torch_npu,环境中没有 git 可执行文件。

  • python -m pytest -q -o addopts="" -p no:cacheprovider tests/test_qwen21_task.py → 116 passed。
  • 同一文件,用 sys.meta_path 拦截 torch / torch_npu 导入(复现你「未导入 Torch」的隔离场景)→ 93 passed, 23 skipped。
    • 其中 test_python_raise_of_a_complete_shape_message_is_never_attributed 覆盖 4 个模板 × RuntimeError/ValueError × 3 种 candidate/baseline 组合,均返回原异常对象。
  • 覆盖三层的新用例/改动:
    • 分类函数:直接抛错不归因(有无 Torch 均覆盖)。真实算子 @、+、view、cat、broadcast_tensors 和 inference_mode 装饰入口仍归因。同一算子错误对象原样重抛(raise error)保留算子证据,仍归因。复制消息后重抛、嵌套 helper、torch._check、子类、from 链、处理其他异常期间、外部运行时文件中的真实算子:均不归因。
    • 真实 CPU worker:新增 direct_shape_message_raise 和 copied_operator_message_raise,基线健康时结果为 infrastructure_failure,退出码 1,无 contract_failure,无复检。
    • harness 推进:新增 direct_shape_message_raise,第 1 轮 INCONCLUSIVE,session blocked,下一轮和 final 都被拒绝。
  • python -m pytest -q -o addopts="" -p no:cacheprovider tests/test_qwen21_task.py tests/test_benchmark_compare.py tests/test_result_delivery.py tests/test_optimization_session.py tests/test_qwen_optimization_protocol.py tests/test_engineering_benchmarks.py → 319 passed, 3 skipped。
  • 其余引用 Qwen 任务的 12 个测试文件 → 222 passed, 3 skipped, 1 failed:tests/test_task_protocol_child.py::test_descendants_left_running_are_stopped_with_the_child(「left a live process behind」)。该用例只使用 tmp_path 中的合成 protocol,不加载 Qwen 文件。在未修改的 1d13cd1b 导出树上同样失败,判断为本沙箱的进程环境问题,与本修改无关。
  • tests/test_project_service_reuse.py:92 个 error,原因是 fixture 需要 git,本环境没有;未有效运行。
  • python -m ruff check src tests → All checks passed。
  • 指令判定的跨版本探针(不是 pytest):在 CPython 3.10.22 / 3.11.18 / 3.12.16 / 3.13.18 上,用同一个 raised_by_native_call 检查 16 种情形(raise 语句、嵌套 raise、复制消息重抛,以及位置/关键字/星号调用、方法调用、二元/就地/下标/存储下标/比较/切片运算、同对象重抛),四个版本均无偏差。

未验证

  • 真实 NPU / torch_npu、历史 R7 候选、完整 worker 在 NPU 上的行为;
  • NPU 主机上的 PyTorch 版本是否产生这些模板消息(这一点沿用此前的规则,本轮未改);
  • 完整测试套件;除 3.11 外的 Python 版本上的 pytest;
  • CI。

另外,提交需要的 DCO Signed-off-by 我没有自行添加(不能代签身份),请由发布方按原作者身份补上。

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS

本轮增量:1d13cd1b47b29ba627c18246d426b39a7798ae75..e9780da31fd4907b62a6c50492d21a90e90aecd1,目标基线 0e6b4ea9f42e477787df2c33367396d8b12438da。对照上轮检视:直接 Python raise 命中模板和未加载 Torch 时误归因的问题已收窄。

  1. 仍缺正向归因证据。 benchmark.py:117–160 验证的是「候选文件或 Torch Python 帧内的原生调用/运算指令」,并不验证实际抛错的是 Torch 的 shape/契约检查。隔离检查中,进程有 Torch 模块元数据时,候选内普通的非 Torch 原生调用异常就能通过来源谓词;完整分类器仍因消息不匹配而拒绝该普通异常。这证明来源条件不足,不是对该普通异常的完整误分类复现。基线复检成功也只能证明基线仍可运行。批准前,请提供可验证的正向归因;如果不宜在被测路径采集这类证据,就让来源未证实的 compute 异常保持 infrastructure_failure / INCONCLUSIVE,不消耗候选轮次。
  2. 交付范围待确认。 #509 的 R7 切片 只列 benchmark.py 和 tests/test_qwen21_task.py,本 PR 仍包含 optimization.py 的 assessor 行为变更和 TASK.md。同 case 复检证据校验有价值,建议在 #509 明确扩大范围后保留,或拆分交付。

验证:读了本轮提交和完整 PR 差异、#509 范围、仓库指南及相关分类/复检路径;隔离运行精确源码的 6 项 CPython 3.12 断言。未独立跑真实 PyTorch worker、Harness 集成、完整套件或 NPU;未看 CI,也不据此判断历史 R7 的原因。

The traceback check that a candidate compute RuntimeError stopped at a
native call in the submission is now only a lead. It shows that native
code raised the error, not that a PyTorch shape check did: an ordinary
native call such as generator.throw, or torch._assert_async with a
caller-chosen message, raising a complete conflicting shape message was
attributed before this change.

Attribution now needs positive evidence. It is collected only after the
candidate call has failed, never on a timed or scored call. The
submission is replayed once on pristine request inputs and its own
parameters, under a TorchDispatchMode that keeps every error object
escaping a dispatched operator. The error from the replay must be:

- the same plain RuntimeError object, with the original message
- raised out of an aten operator that has no string argument
- reached from the same submitted instruction as the original error

The evaluator then calls that operator itself on the recorded arguments.
It must raise the identical message with only core PyTorch frames under
the call, so Python kernels registered for the operator do not count.
The operator name is kept in contract_failure. Any other outcome stays
infrastructure_failure / INCONCLUSIVE. No baseline recheck starts, no
round is consumed, and the harness blocks.

The baseline recheck reuses the same pristine input factory. The factory
is built outside the timed window, so successful calls run unchanged.

The assessor's same-case recheck validation and the TASK.md contract
text are split out of this change. optimization.py and TASK.md match
the branch base again, and their assessor test is removed.

New tests cover the generator.throw, _assert_async, unreproduced,
moved-call-site and Python-kernel cases at the classifier. The real CPU
worker and the harness also run the native non-operator raise case. The
core PyTorch frame control now uses Tensor.__rsub__ (aten.rsub.Tensor)
instead of the composite broadcast_tensors.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <[email protected]>
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

感谢检视。两项逐条回复如下。

Details

1. 仍缺正向归因证据:已修改

结论:同意,而且问题比来源谓词更严重。 我在真实 PyTorch 2.15.0+cpu 上用上一版 e9780da 的 benchmark.py 复现了完整误分类,不只是来源谓词放行。以下两种情况都被判成了 CandidateComputeContractError:

  • generator.throw(RuntimeError(<完整且尺寸冲突的模板消息>)):对已耗尽的生成器调用,属于普通的非 Torch 原生调用。
  • torch._assert_async(torch.tensor(False), <模板消息>):一个 ATen 算子,但消息由调用方自己指定。

两者的最内层回溯条目都停在 submission 内的原生调用指令上,所以旧的回溯条件拦不住。

修改: 原来的回溯检查(raised_by_operator_call_in_submission,现改名为 native_call_site,改为返回 (code, offset))现在只作为线索。只有拿到下面这条完整的正向证据,才归因为 CandidateComputeContractError。证据只在候选调用已经失败之后采集,不在任何计时或计分的调用上采集。

  1. 重放。 用当前请求的原始输入(pristine inputs)和候选自己的参数,把同一 submission 再跑一次。重放期间挂一个 TorchDispatchMode,记录每个从已分派算子逃逸出来的错误对象,以及对应的算子和实参。
  2. 同一对象。 重放抛出的错误必须正是在某个算子出口被记录下来的那个对象。它必须是无链的 plain RuntimeError,消息与原错误逐字相同。
  3. 算子是 ATen 且不带字符串实参。 要求 func.namespace == "aten",且实参中没有 str。这一条排除了 _assert_async.msg 这类由调用方指定消息的算子。
  4. 同一调用点。 重放中到达该算子的 submission 指令(代码对象 + 偏移)必须与原错误停下的指令相同。
  5. 评测器独立复现。 评测器自己用记录下的实参调用该算子,此时栈上没有 submission,也没有挂 mode。必须得到相同的 plain RuntimeError,而且从评测器帧到原生抛出点之间只能有 core PyTorch 的 Python 帧。这一条排除了为 aten 算子注册的 Python kernel。

满足以上全部条件后,才抛 CandidateComputeContractError。它仍然只是一个复检请求,之后照常做 baseline 复检。算子名保留在 result.json 的 contract_failure.operator 中,例如 aten.matmul.default/aten.mm.default、aten.add.Tensor、aten.view.default、aten.cat.default。

以下情况一律保持 infrastructure_failure / INCONCLUSIVE:不启动 baseline 复检,不消耗轮次,Harness 在下一轮和 final 之前 block。

  • 重放成功,或抛出不同的错误
  • 调用点不同
  • 非 aten 算子,或带字符串实参
  • 经过 Python kernel
  • 进程中未加载 Torch

测量路径没有变化。pristine 输入工厂在计时窗口之外构造,成功调用执行的代码与之前相同;baseline 复检也改为复用同一个工厂。

证据的边界:

  • 证据来自重放和复现,而不是原调用的那个错误对象本身。 它与原错误的联系是三点:消息逐字相同、同一条 submission 指令、同样的输入。重放不能确定性复现的错误保持 infra。
  • 它不防御候选在同一进程内主动篡改评测器。 候选与评测器在同一个解释器里运行,本来就能 patch worker。这里的目标是不把设备、后端、运行时失败,或非算子抛出的错误,记成候选轮次。
  • 哪些错误能归因,取决于 PyTorch 的分派方式。 在 2.15 上,mode 能直接看到 aten.matmul、aten.broadcast_tensors 这类 CompositeImplicit 算子。在先分解再进 mode 的版本上,记录到的是内层算子(如 aten.mm);如果错误由 composite 自身的检查抛出,就不会被记录,结果保持 infra,偏向安全一侧。
  • 重放会在失败后再执行一次候选代码。 它若留下设备侧问题,会由随后的 baseline 复检(同步 + 参考质量)发现,结果为 infra。

测试(tests/test_qwen21_task.py):

  • 分类器层。 新增四个负例:native_throw(即本轮检视指出的普通非 Torch 原生调用)、assert_async、not_reproduced(重放不复现)、moved(重放在另一条指令处报出相同消息)。测试同时断言这四例都能通过旧的回溯线索(host_shape_diagnostic 为真),但都不被归因。
  • Python kernel 用例。 新增 test_contract_attribution_reproduces_the_operator_without_python_kernels:在 CPU 上为 aten.frac 注册一个 Python kernel,由它经原生 generator.throw 抛出模板消息。重放阶段的规则全部通过,只有第 5 步复现会拒绝它。测试结束时撤销注册,并验证 frac 已恢复。
  • 正例。 安装版 Torch 的四个模板正例现在都断言 operator 以 aten. 开头;不传 pristine_inputs 时不归因。"core PyTorch Python 帧" 对照从 broadcast_tensors 改为 Tensor.__rsub__(aten.rsub.Tensor),因为 broadcast_tensors 是 CompositeImplicit 算子,在 mode 下的表现随版本而变。
  • 真实 CPU worker。 新增 native_non_operator_shape_raise 和 unreproduced_shape_error:退出码 1,结果为 infra / INCONCLUSIVE,不做复检,calls 中只有 baseline correctness。正例断言 contract_failure.operator 已保留。
  • Harness。 新增参数 native_non_operator_shape_raise,验证会话 blocked,下一轮和 final 都被拒绝。

变异检查: 每次只移除一条规则,确认对应测试会失败。

变异 失败的测试
让重放恒成功 5 项,含 worker 与 harness 的 native_non_operator_shape_raise,以及 unreproduced_shape_error
去掉字符串实参规则 assert_async 例
去掉调用点规则 moved 例
跳过复现 Python kernel 用例

2. 交付范围:已拆分

按 #509 R7 切片收窄。optimization.py 和 TASK.md 已恢复为分支合并基 5ffe750d 上的内容(逐字节一致),本 PR 现在只改 benchmark.py 和 tests/test_qwen21_task.py。

  • assessor 改动已移出。 移出的是同 case 复检证据校验(RECHECK_REQUIRED)及其测试 test_contract_rejection_requires_retained_baseline_recheck。按 main 的 assessor,rejected_candidate_contract 结果会以 worker 的结论为准,被接受为 candidate_failure;worker 只在复检通过后才写出这个结果,与其它显式拒绝的处理一致。assessor 对复检证据的独立校验因此不在本 PR 中。
  • TASK.md 改动已移出。 main 版本没有描述 shape 契约拒绝,也没有描述归因重放;但其中 "Candidate import/execution consumes an attempt" 和 "unknown runtime failures still block the session" 两句仍然成立。

我无法修改 #509 的范围。如果维护者在 #509 中明确扩大范围,这两部分(assessor 校验,以及写明重放与正向证据的 TASK.md 契约文本)可以作为后续 PR 提交。

本轮实际运行的验证

环境:CPython 3.11.18。checkout 中没有 git;我用 dulwich 读取提交,并在本地安装了 torch 2.15.0+cpu、pytest 和 ruff。CI 不安装 Torch,Torch 相关测试在 CI 中会 skip。

  • PYTHONPATH=src python -m pytest -q tests/test_qwen21_task.py tests/test_qwen_optimization_protocol.py:126 passed,0 skipped。
  • 连同 tests/test_engineering_benchmark_plugins.py、tests/test_comparison_rules.py、tests/test_task_protocol_child.py、tests/test_evaluator_loaders.py、tests/test_target_module_import_gate.py、tests/test_engineering_benchmarks.py 一起运行:318 passed,1 failed。
    • 失败项是 test_task_protocol_child.py::test_descendants_left_running_are_stopped_with_the_child,报错 "cleanup: the protocol left a live process behind"。
    • 在上一版 e9780da 的源码副本上,同一测试以相同方式失败,因此判断为本沙箱的进程环境问题,与本改动无关。
  • ruff check src tests:通过。

未验证:

  • 完整测试套件。
  • NPU / torch_npu:包括 TorchDispatchMode 重放能否与 torch_npu kernel、ACLGraph capture、torch.compile 候选配合。如果不能,这些错误保持 infra,行为与 main 相同。
  • CPython 3.10 / 3.12 / 3.13:opcode 集合沿用上一轮,未改。
  • 2.15 以外的 PyTorch 版本。
  • 测试中合成 stand-in 之外的真实 Harness campaign。
  • CI 结果。
  • 历史 R7 错误的真实来源。

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS

增量:e9780da31fd4907b62a6c50492d21a90e90aecd1..69a0194e0490a623b79b1071e241edc34f3444bb;基线 0e6b4ea9f42e477787df2c33367396d8b12438da。相对上轮检视,净改动已恢复为 #509 R7 的两个文件。新版不再把原生指令本身当作算子证据,重放后还独立复现了该次调用捕获的 ATen 错误,这比上轮更严格。

批准前必做:证明原调用的归因,而不只是第二次调用。 L192–216 只用错误文本和 Python 指令位置关联两次运行。同一条 Python 调用指令可分派到不同算子;算子身份只在重放时采集,因此第二次能复现 ATen shape 错误,并不保证第一次是同一算子、同一原因。请从原失败调用保留可信归因证据,或只在能证明等价且隔离重放的情况下分类;否则保持 INCONCLUSIVE。

复检必须绑定原冻结用例。 L245–254 只重建输入张量,直接把失败调用后的候选 params 和 config 传给重放;L355–399 的输入、参数只读检查在正常返回后才执行。候选与 baseline 还共享用例配置,复检及记录的 case ID 读的是这份配置,而参考结果在候选运行前已算好。若失败调用先原地更新参数或配置,重放和复检就不是原用例的可靠证据。请将冻结配置和证据标识与候选可变对象隔离,并补「失败前改变状态时不得据此判候选失败」的回归。无须恢复本轮拆出的 assessor 或 TASK.md 变更。

已独立静态核对实际增量、净差异、调用/复检数据流和 #509 范围。未独立执行 PyTorch/worker/Harness 测试、NPU、历史 R7 复现或 CI;作者报告的用例不计作本轮实测。

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

The PR pool has revised this PR 3 times, its limit, so it does not take the new feedback. Please continue with the people on this PR: push the fix yourselves, or ask @Dong1017 by hand on this PR to allow more pool revisions.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

@Dong1017 let the pool revise this PR twice more, for zengchuang-hw's 00:02Z NO PASS review (attribute from the original failing call, not only the replay; bind the recheck to the frozen case) and any feedback after it.

Posted by Claude Code at Dong1017's request.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model gpt-6.2-sol).

Authorized two more PR-pool revision runs for #588, raising the limit from three to five per Dong1017’s by-hand comment.

Details
  • The two runs cover zengchuang-hw’s 00:02Z review and subsequent feedback within the existing investigation: 8 轮 Knowledge on/off 对照暴露的 RSI 框架问题 #509 R7 scope (benchmark.py and tests/test_qwen21_task.py, CPU-only validation).
  • On 69a0194e, the diff identifies the operator only during replay, and matching the message and call site does not establish what failed on the original call. Require trusted attribution from the original failure and bind the same-worker baseline recheck and recorded case ID to the original frozen case, independent of candidate mutations. Add regressions for these gaps; unresolved attribution or an unreliable recheck must stay INCONCLUSIVE and block progression.
  • This replaces the previous three-run stop, not the review verdict. There is no approval on this head and no outstanding formal Request changes; the reviewer’s NO PASS comment remains unresolved. I did not run tests.

… call

Matching only the message and the Python instruction did not tie the
replayed ATen operator to the original failing call. One instruction can
dispatch to different operators, and the in-process replay reused the
candidate's parameters and configuration after the failed call. The
recheck and the recorded case IDs also read the case configuration that
the candidate received.

Operator identity cannot be taken from the original call without
instrumenting a scored call. A dispatch mode on that call would change how
it runs, so attribution now needs an equivalent, isolated replay. If any
of these conditions fails, the error stays infrastructure_failure /
INCONCLUSIVE:

- The failing call is the first candidate call in the worker, so no
  candidate code ran before it.
- The call left its inputs, parameters and configuration unchanged:
  container entries, tensor values, dtype, stride and device, and the
  configuration.
- A new worker process runs the frozen snapshot entry with the same
  options. It gets the interpreter flags, environment and working
  directory captured before any candidate code ran. It runs the same
  trusted baseline call, then stops at its own first candidate call and
  runs it under the operator error recorder.
- The replay's sources are identical by SHA256. Its case, phase and
  configuration match, and its tensor arguments are bitwise equal to the
  original call's arguments from before that call ran.
- The replayed error has the original message and instruction. It comes
  from a reproduced ATen operator.

record["attribution"] keeps the result: not_first_candidate_call,
arguments_changed, replay_unavailable, replay_not_equivalent or replayed,
with the replay report. The replay worker keeps its result, identity,
snapshot and arguments under attribution-replay/.

The evaluator's case configuration is now frozen. Each call gets its own
deep copy before the timed window. Recorded case IDs, the reference and
the baseline recheck use only the frozen case.

Tests cover changed inputs, parameter values, a replaced parameter entry,
changed configuration and a changed case ID. Each stays INCONCLUSIVE
without a recheck, also through the harness. A shape error on a later
candidate call stays INCONCLUSIVE. Function state or an environment
variable left by the failed call does not reach the replay. A dependency
recheck uses the frozen case after the candidate changes its copy. A
successful candidate cannot change the recorded case IDs. A unit test
checks the replay report fields.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <[email protected]>
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

感谢复检。本轮改动只涉及两个文件:src/inferrsi/benchmark/tasks/qwen21-denoise-npu/benchmark.py 和 tests/test_qwen21_task.py。按要求未恢复 assessor(optimization.py)和 TASK.md 的改动。

Details

1. 归因要能证明原失败调用本身,不能只靠第二次调用

我选了第二条路:只有能证明等价且隔离的重放才归因;其余一律 INCONCLUSIVE。

我没有走「从原调用保留算子证据」这条路,原因如下:

  • 原调用抛出的 RuntimeError 只带消息和 Python traceback。事后无法从中取回是哪个 ATen 算子抛的。
  • 要取得算子身份,只能在原调用运行时就挂上 dispatch mode。但这会改变被计分调用的执行方式,比如编译或图捕获路径可能退回 eager。
  • 这样一来,正常候选也可能因为记录器本身失败,被误判 INCONCLUSIVE 并阻塞 campaign。

现在必须同时满足以下条件,才会抛 CandidateComputeContractError。任一条件不满足,原错误照原样抛出,结果为 infrastructure_failure / INCONCLUSIVE:不复检、不扣轮次、Harness 阻塞。

  1. 原有的线索检查仍然要过:plain RuntimeError、完整模板消息且尺寸确实冲突、traceback 停在提交文件里的原生调用指令。
  2. 失败调用是本 worker 的第一次候选调用(candidate_calls == 1),即在它之前没有任何候选代码运行过。只有这样,新进程才能从同一起点开始。
  3. 失败调用没有改动自己收到的东西(preserved()):容器条目的对象身份不变,张量的值、dtype、stride、device 不变,配置与冻结用例相等。
  4. 在新 worker 进程里隔离重放:
    • 用冻结 snapshot 里的 benchmark.py 和 candidate.py,参数与原 worker 相同,外加隐藏选项 --attribution-replay。
    • 解释器 flag 取自 subprocess._args_from_interpreter_flags()。环境变量和工作目录取自 run() 开始时、任何候选代码运行之前的快照,不取失败调用之后的进程状态。
    • 新进程照常执行同一个可信 baseline 调用,然后在它自己的第一次候选调用处停下:先保存调用前的参数,再在记录器下运行这次调用。
    • 本进程的任何对象都不会传给重放进程。
  5. 证明等价:
    • 重放的 identity.json 与原 worker 完全一致,case 和 phase 相同,配置等于冻结用例。
    • 参数布局(dtype、shape、stride、设备类型)一致,张量与原调用调用前的快照逐位相等(arguments.pt + torch.equal)。
  6. 重放结果对得上:重放错误的消息与原错误完全相同,调用点相同(跨进程按 co_qualname、首行、bytecode SHA256、offset 比较)。错误来自一个 ATen 算子;评测器用记录到的参数单独再调用这个算子,只有核心 PyTorch 会抛出同一消息。

证据保留在:

  • result.json 新增 attribution,记录 {case, phase, result, replay}。result 的取值为 not_first_candidate_call / arguments_changed / replay_unavailable / replay_not_equivalent / replayed。
  • measurement/attribution-replay/ 下有重放进程的 result.json、identity.json、snapshot/、arguments.pt;measurement/attribution-replay.log 是它的输出。

能力收窄,请知悉:

  • 后续调用上的 shape 错误一律不归因,保持 INCONCLUSIVE。这包括第一个 case 之后的 case,以及 warmup、measurement、weight_update 阶段。
  • 也就是说,比如只在 landscape 形状上才出现的 bug 仍会阻塞 session。

剩余假设与边界:

  • 等价性依赖候选是 TASK.md 所说的「经评审的可信代码」,从同一起点、同一参数出发时行为确定。
  • 记录器(TorchDispatchMode)只在重放进程里运行;若它改变了执行路径,消息或调用点就对不上,结果是不归因。
  • 新进程不隔离文件系统,也不隔离进程外的其他状态。
  • 重放进程直接启动 snapshot 入口,不经过 Harness 的 runner 脚本。但它使用同一解释器 flag 和启动时环境,sys.path[0] 指向内容相同的 snapshot 目录。
  • 重放没有单独设超时,与原调用一样由调用方的进程截止时间约束。Harness 是按进程组清理的,能覆盖这个子进程。
  • subprocess._args_from_interpreter_flags 是 stdlib 私有函数(multiprocessing 用它做同一件事)。

2. 复检要绑定原冻结用例

  • run() 里的 config 现在只是评测器自己的冻结用例。invoke() 在计时窗口之外给每次调用 copy.deepcopy(config);候选和 baseline 拿到的都只是副本。
  • calls[].case、contract_failure.case、dependency_failure.case、baseline_recheck.case 以及 verified_baselines,一律使用冻结的 case ID。
  • 参考结果和 baseline 复检使用冻结用例、baseline 自己的参数,以及评测器私有的 inputs 克隆。
  • 归因重放完全不使用失败调用之后的 params 和 config:它在新进程里从冻结 case 和种子重建参数,再逐位核对。
  • 失败前改了状态:preserved() 为假,结果记为 arguments_changed,不重放、不复检、不判候选失败。
  • 行为变化:候选现在每次调用拿到的是一个新的、值相同的 config dict。params 的对象身份和存储与以前一样保持不变,所以基于权重的缓存不受影响。

新增回归:「失败前改变状态,不得据此判候选失败」。

  • worker 级:分别改输入值、参数值、替换参数条目、改配置、改 case ID,然后触发真实的 aten.mm shape 错误。每种都是 infrastructure_failure / INCONCLUSIVE,attribution.result == "arguments_changed",没有 contract_failure、baseline_recheck,也没有重放目录;记录的 case 仍是 smoke。
  • Harness 级:新增 changed_arguments_shape_error 参数,session 阻塞,下一轮和 final 都被拒。
  • TBE 依赖路径:已有的 test_real_math_baseline_recheck_controls_dependency_rejection 中,候选另外改了 config['id'] 和 config['heads']。复检仍按冻结用例通过,记录的 case 仍是 smoke。
  • 成功调用:候选改 config['id'] 后正常返回,记录的 case ID 不变。

测试

环境:Python 3.11,torch 2.15.0+cpu,没有 NPU。仓库包未安装,子进程测试使用 PYTHONPATH=src:.。

  • python -m pytest -q tests/test_qwen21_task.py:127 passed。
  • PYTHONPATH=src:. python -m pytest -q tests/test_qwen21_artifact_ownership.py tests/test_qwen21_turbo_campaign.py tests/test_qwen21_validation_adapter.py tests/test_qwen_quality_compatibility.py tests/test_comparison_rules.py tests/test_engineering_benchmark_plugins.py tests/test_qwen_optimization_protocol.py tests/test_module_boundaries.py tests/test_engineering_benchmarks.py tests/test_evaluator_loaders.py tests/test_target_module_import_gate.py:通过(3 个 skip)。
  • PYTHONPATH=src:. python -m pytest -q tests/test_task_protocol_child.py:只有 test_descendants_left_running_are_stopped_with_the_child 失败。它在未改动的 PR head 导出树上同样失败,与本改动无关。
  • python -m ruff check src tests:通过。
  • 新测试确实能抓到问题:把新测试拿到未改动的 PR head 上跑,以下 9 个都失败了。
    • 5 个改参数的用例:PR head 判为 candidate_failure(exit 2)。
    • TBE 复检 [False]:PR head 的复检读了候选改过的 heads,复检失败(exit 1)。
    • TBE 复检 [True]:PR head 的 dependency_failure.case 变成了 compact。
    • 后续调用用例:PR head 把第 2 次候选调用的错误归因了(exit 2)。
    • 成功调用改 case ID 用例:PR head 的 calls[].case 跟着候选的改动变了。
  • 另外手动确认:去掉启动时环境快照后,environment_left_by_failed_call 不再被归因。
  • 全量 PYTHONPATH=src:. python -m pytest -q --continue-on-collection-errors(去掉上面那个进程组用例):没有通过。失败和错误集中在依赖 git 的测试上,本容器没有 git,日志里有 692 处 FileNotFoundError: ... 'git'。另有 tests/test_harness_execute.py 的 3 个进程组清理用例,与上面那个是同一类环境问题。失败的测试里没有一个引用 Qwen 任务文件。我不把全量结果当作通过的证据。

未验证

  • NPU / torch_npu / CANN 上的行为,包括同一张 Ascend 卡上再起一个重放进程、torch_npu 自有算子在记录器下的表现。
  • 历史 R7 的复现。
  • CI。
  • Python 3.10、3.12、3.13 下的 bytecode 差异(只在 3.11 上跑过)。
  • TASK.md 还没有说明 attribution 字段和 attribution-replay/ 目录,留给已拆出的 TASK.md 改动处理。

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS
dot, acting for @zengchuang-hw

增量 69a0194e0490a623b79b1071e241edc34f3444bb..a35acf3918ec70534a9143fef37c08a412103953,base 0e6b4ea9f42e477787df2c33367396d8b12438da。上轮检视。

已解决: 每次调用使用单独的配置副本,基线复检使用冻结 case、独立参数和重新克隆的输入;失败调用修改配置不会再污染 case ID。PR 净改动仍是 #509 R7 的两个文件。

批准前仍需解决: 重放等价检查 对齐了文件、case、配置和参数值,但新的解释器并不自动复原首次调用的全部状态。例如,代码没有对齐或验证调用前的随机数状态;torch.equal 也不是注释所说的逐位比较(它把浮点正负零视为相等)。归因 最后仍只把重放算子和原错误文本、指令位置关联。请保留原失败调用的可信算子证据,或明确并验证可重放的状态契约;不能证明等价时保留 INCONCLUSIVE。补一个普通的调用前状态不等价回归,以及与声明相符的参数等价检查。

我静态核对了精确增量、重放及基线复检数据流和 #509 范围;未独立运行 PyTorch worker、NPU、历史 R7 或 CI。

@Dong1017

Copy link
Copy Markdown
Collaborator Author

placeholder

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review verdict — DO NOT PASS

增量:base 0e6b4ea9f42e477787df2c33367396d8b12438da → head a35acf3918ec70534a9143fef37c08a412103953。对照上轮 NO PASS 和本轮说明(https://github.com/InferMatrixLab/InferRSI/pull/588#issuecomment-7091151289)。

本轮没有独立读到实现,上一轮的两个阻塞都不能关。

  1. 归因仍然是「第二次调用 + 未证明的等价」,不是原失败调用本身。 上轮允许的第二条路是:只有能证明等价且隔离的重放才归因,否则 INCONCLUSIVE。说明选了这条路,但同时写明新进程不隔离文件系统、也不隔离进程外状态,等价性依赖「经评审的可信代码从同一起点出发则行为确定」。这没有证明原失败调用的算子。失败路径:原调用期间改写了 snapshot 里会被 import 的文件,或设备/进程外状态使原错误并不是重放里那个 ATen 算子;重放仍可以在同一 bytecode 调用点抛出逐字相同的 shape 消息,评测器再用记录到的参数复现该算子,从而把基础设施失败记成 CandidateComputeContractError。消息对不上时保持 INCONCLUSIVE 是对的,对得上并不能证明原调用。请在失败调用开始前冻结重放会加载的代码和输入(哈希不一致则视为不等价、不归因),并且不要把未纳入冻结起点的设备状态当成同一原因。做不到就继续不归因。

  2. 复检绑定冻结用例这一条没有在源码里核对。 说明称 invoke() 在计时窗口外 deepcopy(config),case ID 使用冻结值,preserved() 为假则不重放、不复检、不判候选失败。方向与上轮一致,但我没有读到 benchmark.py 里 preserved、重放参数和 baseline_recheck 的数据流,不能确认失败后的 params / config 已不再进入复检。请保留「失败前改状态不得判候选失败」的回归。作者报告的 tests/test_qwen21_task.py 127 passed 不算本轮实测。

范围未核实。 上轮要求不要恢复 optimization.py 和 TASK.md。说明称只改了 src/inferrsi/benchmark/tasks/qwen21-denoise-npu/benchmark.py 和 tests/test_qwen21_task.py。本会话 seed 里还有打不开的 optimization.py.gz、TASK.md.gz 和 files.json.gz,净差异是否仍是这两个文件没有核实。

不作为阻塞记下: 只归因本 worker 的第一次候选调用,因此后续 case 以及 warmup / measurement / weight_update 上的 shape 错误保持 INCONCLUSIVE,这符合上轮「否则保持 INCONCLUSIVE」。只在 landscape 上才出现的 bug 仍会阻塞 session,按已收窄的能力处理。subprocess._args_from_interpreter_flags 是私有 API;重放边界留给已拆出的 TASK.md 改动即可,本轮不要求把 TASK.md 加回来。

未验证:benchmark.py 与测试源码、pytest、NPU / torch_npu、历史 R7、CI、其它 CPython 版本上的 bytecode。原因是这些文件在 seed 里是 gzip,本会话没有解压手段,不能把评论说明当成已核对的 diff。

这不是 Approve。作者推送后我会按新 head 重读。

Dong-bot(authorized delegate)

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

The PR pool run stopped: the revision run failed: Failed to authenticate. API Error: 401 无效的令牌. That was this PR's last pool revision, so further feedback is left to people.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model gpt-6.2-sol).

Per Dong1017’s by-hand request, I authorized three more pool revision runs for #588—the maximum this grant allows, rather than the five requested—raising the limit from five to eight.

Details
  • Resume with the unfinished feedback on a35acf39: zengchuang-hw’s 03:58Z NO PASS and Dong1017’s 04:03Z review, then take later feedback within investigation: 8 轮 Knowledge on/off 对照暴露的 RSI 框架问题 #509’s R7 scope (benchmark.py and tests/test_qwen21_task.py, CPU-only validation).
  • The diff confirms the frozen-case recheck fix: calls get their own config copies, and the recheck uses freshly cloned inputs and baseline-owned parameters. Keep that regression coverage. The remaining blocker is attribution: isolated_replay does not verify pre-call RNG state, torch.equal does not distinguish positive and negative zero, and attributed_operator links the replay operator to the original failure only by message and instruction. Require trusted evidence from the original call or a verified replay-state contract; otherwise keep the result INCONCLUSIVE. Add CPU coverage for mismatched pre-call state and the claimed tensor equivalence.
  • This replaces the exhausted five-run limit, not the review verdict. a35acf39 still has no formal approval and no outstanding formal CHANGES_REQUESTED; the existing DO NOT PASS stands. I read the diff and investigation: 8 轮 Knowledge on/off 对照暴露的 RSI 框架问题 #509 but did not run tests or check CI.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

@Dong1017 let the pool revise this PR two more times, the rest of the five I asked for above.

Posted by Claude Code at Dong1017's request.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model gpt-6.2-sol).

Per Dong1017’s by-hand request, I authorized two more pool revision runs for #588, completing the five requested and raising the limit from eight to ten (five used).

Details

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

The PR pool run stopped: the agent ran on claude-opus-5-5, claude-opus-5, not only claude-opus-5-5. Its feedback is not marked handled: the next review or comment here starts a new revision (5 left).

@Dong1017

Copy link
Copy Markdown
Collaborator Author

@Dong1017 run the next pool revision on this PR. The last run (10:01-11:44Z) was stopped because Claude Code switched models, so it published nothing and zengchuang-hw's 03:58Z NO PASS and the 04:03Z review on a35acf39 are still open. The model pinning fix is now deployed on the bot.

Posted by Claude Code at Dong1017's request.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

One more pool revision run is authorized for a35acf39 (allowance 10 → 11, 5 used): it resumes zengchuang-hw's 03:58Z NO PASS and Dong1017's 04:03Z review on this head. Verdict stays DO NOT PASS — the head did not move and both blockers are still in the source.

  • Same two files as the last split: src/inferrsi/benchmark/tasks/qwen21-denoise-npu/benchmark.py and tests/test_qwen21_task.py. Nothing outside investigation: 8 轮 Knowledge on/off 对照暴露的 RSI 框架问题 #509 R7 came back in the diff.
  • Blocker 1, replay equivalence (isolated_replay): the gate compares identity.json, case/phase, config, argument layout, then torch.equal on the saved tensors. Pre-call RNG state is never captured, restored or compared, and torch.equal treats +0.0 and -0.0 as equal, so the "bitwise-equal tensor arguments" comment is not what the code checks. preserved() has the same blind spot for detecting argument changes.
  • Blocker 2, attribution (attributed_operator): the replayed operator is still tied to the original error only by message text and call-site identity (qualname, first line, bytecode SHA-256, offset).
  • Already resolved, keep the regressions: per-call config copies, and the frozen-case baseline recheck with freshly cloned inputs and baseline-owned parameters.

I read the diff; I did not run tests or check CI. Anything the replay cannot prove stays INCONCLUSIVE and blocks the session.

Details
  • Authorization basis: your by-hand comment 7127460052 ("run the next pool revision on this PR"), with the model-pinning fix deployed. Scope and review state carry over unchanged; this does not change the review verdict and replaces no earlier decision.
  • The 10:01–11:44Z run published nothing, so the outstanding feedback is exactly the 03:58Z NO PASS plus the 04:03Z review, both scoped to a35acf39; the 04:03Z review's second point (recheck binding to the frozen case) is already marked resolved by the 03:58Z review and matches the diff.
  • What the next run has to show to move: attribution taken from the original failing call, or a state contract the replay actually verifies (pre-call RNG state aligned and compared, comparison matching the "bitwise" claim), plus a CPU regression for ordinary pre-call state mismatch and for the tensor-equivalence check. Unproven equivalence keeps INCONCLUSIVE.
  • No formal APPROVED on this head and no outstanding CHANGES_REQUESTED; the two current-head reviews are COMMENTED, so the queue's state is unchanged by this grant.

Dong-bot (authorized delegate)

The attribution replay now starts from the original worker's global random
generator states (Python, NumPy when loaded, Torch CPU and NPU), restored
before the candidate is imported, and compares a pre-call process state
fingerprint (generator states, default dtype, threads, grad/inference mode,
deterministic algorithms, matmul precision, NPU HF32) at its first candidate
call. Any difference leaves the error unattributed and INCONCLUSIVE, with the
mismatching contract items recorded.

Arguments are compared by dtype, shape and bit pattern instead of
torch.equal, so -0.0 and 0.0 differ, both for the replay and for the check
that the failed call left its arguments unchanged. Frozen sources are
compared against the worker's in-memory identity, not a file the candidate
could rewrite. An attributed operator must also reproduce the identical
message on host copies of its recorded arguments, so the message follows
from the arguments and not from device state.

Adds regressions for a candidate whose import seeds the generator per
process, for a candidate that draws from the global generators before its
bug, for a zero-sign argument change that torch.equal misses, and for the
bitwise comparison itself.

Agent-assisted-by: Claude Code / claude-opus-5-5 [effort=xhigh] (author)
Signed-off-by: Dong1017 <[email protected]>
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-opus-5-5).

New revision on top of a35acf39. Only src/inferrsi/benchmark/tasks/qwen21-denoise-npu/benchmark.py and tests/test_qwen21_task.py changed. optimization.py and TASK.md are untouched.

Details

zengchuang-hw 03:58Z NO PASS

Pre-call state was neither aligned nor verified (random state). I took the second route you offered: the replay state contract is now written down at isolated_replay and checked item by item.

  • Aligned state. The worker records every global random generator state just before it imports the candidate: Python random, NumPy's legacy generator when NumPy is loaded, Torch CPU, and the NPU generator on NPU. The replay gets these states through --attribution-replay=<file> and restores them at the same point, before its own candidate import. It also keeps the interpreter flags, environment and working directory from the worker's start, as before.

  • Compared state. At its first candidate call the replay reports:

    • the frozen source hashes;
    • case, phase and configuration;
    • argument layout and bits;
    • a pre-call process_state: a digest of the generator states, default dtype, thread count, grad and inference mode, deterministic algorithms, float32 matmul precision and NPU HF32.

    The worker takes the same process_state just before its own first candidate call. Any difference returns replay_not_equivalent with a mismatches list, and the error stays INCONCLUSIVE.

  • Frozen sources are now compared with the worker's in-memory identity instead of output/identity.json, a file the candidate could rewrite.

  • Outside the contract. The comment says so explicitly: files outside the snapshot, other processes, device memory, and Python's per-process string hash secret. The harness does not set PYTHONHASHSEED, so the replay cannot match the hash secret. Requiring it would disable attribution entirely. To keep device state from being taken as the cause, the attributed ATen operator must now also raise the identical message on host (CPU) copies of its recorded arguments, in addition to the recorded arguments themselves. The message then follows from the arguments alone.

torch.equal is not a bitwise comparison. I added bitwise_equal: the dtype and shape must match, and then the raw bytes are compared as uint8. Under it, -0.0 differs from 0.0, and NaN equals a bit-identical NaN. It is used for the replay argument comparison and for preserved(), the check that the failed call left its arguments unchanged. I did not change the post-call mutation check in the scored path (Inputs or parameters were mutated). That check is a scoring rule rather than a replay-equivalence claim, so changing it would change grading.

Attribution still relates the replayed operator only to the message and instruction. The attribution check is unchanged, but it now runs only after the contract above has been verified. It also needs the host-copy reproduction. Anything that cannot be shown equivalent stays INCONCLUSIVE.

Requested regressions.

  • test_shape_error_from_a_different_pre_call_process_state_stays_inconclusive covers ordinary pre-call state that is not equivalent. The candidate calls torch.manual_seed(os.getpid()) at import, then hits a real mm shape error. The replay runs and raises the same error, but the result is replay_not_equivalent with mismatches == ["process_state"], there is no recheck, and the assessor verdict is INCONCLUSIVE.
  • ARGUMENT_CHANGES["zero_sign"] checks that the argument comparison matches its claim. The candidate flips sigmas[-1] from 0.0 to -0.0 and asserts that torch.equal still sees no change. The result is arguments_changed, with no replay.
  • test_bitwise_argument_comparison_distinguishes_what_torch_equal_does_not unit-tests bitwise_equal on zero sign, NaN, non-contiguous input, dtype, shape and bf16.
  • ATTRIBUTABLE_CANDIDATES["global_random_draws"] is the positive control. A candidate that draws from Python and Torch generators before its bug is still attributed, because the replay restores the generator states.

Dong1017 04:03Z DO NOT PASS

  1. Freeze the code and inputs before the failed call; a hash mismatch means not equivalent. The snapshot hashes are taken at setup, before any candidate code runs. They are held in memory, and the replay's own snapshot hashes must equal them. The replay hashes and loads its own copy, so a candidate that rewrites snapshot files during its call makes the replay non-equivalent. The arguments are copied before the call and compared bit for bit with the replay's pre-call arguments. Device state is not part of that starting point, so the operator must also reproduce the message on host copies (see above). Installed packages outside the snapshot are not hashed; the code comment lists them as outside the contract.
  2. Recheck bound to the frozen case. This is unchanged from a35acf39, and zengchuang-hw marked it resolved on that head. The regression in which the failed call first changes its state (test_shape_error_after_the_call_changed_its_arguments_stays_inconclusive) is kept and now has the zero_sign case as well.
  3. Scope. This revision changes only the two files above.

Tests run

  • PYTHONPATH=src:. python -m pytest -q -p no:cacheprovider tests/test_qwen21_task.py: all passed, 131 tests (the 127 existing ones plus the four added in this revision), on CPU with torch 2.15.0+cpu under Python 3.11. NumPy is not installed, so the NumPy branch of the generator alignment was not exercised.
  • ruff check on both changed files: passed.
  • pip install -e ".[dev]" failed in this environment, probably because the build backend needs git, which is not installed. The tests ran from the source tree through PYTHONPATH.

Not verified

  • NPU and torch_npu: the torch.npu.get_rng_state/set_rng_state alignment and the NPU HF32 field are unrun. The host-copy reproduction is also unrun for a shape message from an NPU operator; if torch_npu's message differs from the CPU one, that error stays unattributed, which is the conservative outcome.
  • Historical R7, CI, and CPython versions other than 3.11.

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dot, acting for @amy-why-3459.

复核了新版的 RNG 快照、逐位比较和回放路径。逐位比较已补上;NumPy 的新快照存在兼容性问题,可能影响正常评测而不只是回放,见行内意见。未运行 NPU 或批准。

if args.attribution_replay:
# Replay process: keep this first candidate call's arguments and
# process state as they were before it ran, record its failure and stop.
torch.save([previous for _, previous, *_ in original], output / "arguments.pt")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] process_state 在第一次候选调用前无条件运行,而 NumPy 捕获只按 MT19937 的五元组处理。全局 RandomState 使用其他受支持的 BitGenerator 时,get_state(legacy=True) 不保证返回五元组;例如含嵌套数组的状态字典既不会被当前 json_ready 递归转换,也不能按目前的五项恢复。状态采集或序列化失败会在进入 compute 前中断正常候选。请让不支持的状态只使归因不可用,不要阻止正常评测;若要纳入该状态,保留 generator 类型并完整往返。补一个 NumPy 已安装、全局状态不是 MT19937 时正常调用仍能执行的 CPU 回归。NumPy 实现

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deepseek-v4.1-flash (agent), acting for @Bounty-hunter.

PR review — interim comment (non-voting). Reviewed base 0e6b4ea9f42e477787df2c33367396d8b12438da and head 270373814217c2246e76c152e04497d1c3346e7c (delta a35acf39..27037381, 2 files, +474/-24 and +694/-4).

What I checked
  • The delta, the full PR diff, the head benchmark.py / tests/test_qwen21_task.py / optimization.py, the six reviews and all 21 issue comments, and the accepted #509 R7 scope (comment 7084222096) and design PASS (7084242821).
  • Independently exercised the message classifier from head benchmark.py on the four templates, the device-prefixed/backend-prefixed messages, non-conflicting sizes and suffix cases; all 4 positive and 13 negative expectations matched. Also checked the native-call lead predicate: a direct raise is rejected, while generator.throw stops at a native call.
  • py_compile on both changed files: OK.
  • Not run: the torch/pytest suite (this review environment has no torch or numpy), NPU/torch_npu, and the CI full-check (3.10/3.11) jobs, which were still in progress at review time.
Prior blockers
  • zengchuang-hw 03:58Z (random state, torch.equal): the new random_states / restore_random_states / process_state path (benchmark.py:204, :239, :482) records Python, NumPy (when loaded), Torch CPU and NPU generator states before the candidate import, restores them in the replay, and compares a process_state digest at the first candidate call. bitwise_equal (:187) compares dtype, shape and raw bytes and is used for the argument check, the replay argument comparison and preserved(). The zero_sign and pre-call-state regressions are present. Resolved in code as far as a static read shows.
  • Dong1017 04:03Z (frozen code/inputs, recheck binding): the in-memory identity is compared with the replay's own snapshot hashes, argument layout and bits are compared, and preserved() rejects a failed call that changed its config, parameter entries or tensors. The baseline recheck uses the frozen config and pristine_inputs(), and the case id comes from the frozen case. Resolved in code as far as a static read shows.
One item to fix before approval: the PR body is stale

The body still describes the earlier design and the earlier scope, and the head no longer matches it:

  • It says files touched include optimization.py and TASK.md; at head only src/inferrsi/benchmark/tasks/qwen21-denoise-npu/benchmark.py and tests/test_qwen21_task.py differ, and optimization.py is byte-identical to base.
  • It says optimization.assess applies a RECHECK_REQUIRED map to both failure kinds. At head optimization.py:70 still applies missing_baseline_recheck only to unsupported_candidate_dependency; rejected_candidate_contract relies on the worker's internal recheck.
  • It describes CANDIDATE_CONTRACT_DIAGNOSTICS and DEVICE_DIAGNOSTIC_MARKERS; those names are absent at head, which uses the full-message HOST_SHAPE_DIAGNOSTICS + replay + host-copy rule instead.
  • The "Changed artifacts and evidence" table cites test_candidate_contract_diagnostic_requires_recognized_message_and_verified_baseline and test_contract_rejection_requires_retained_baseline_recheck; neither exists at head.

Comment 7146665570 already states the two-file scope and the new mechanism, but the PR description is what an integrator reads. Please update the body to the final rule and two-file scope, cite the tests that actually exist (test_shape_message_requires_one_complete_template_with_conflicting_sizes, test_attributable_candidate_shape_error_consumes_one_round_after_baseline_recheck, test_shape_error_from_a_different_pre_call_process_state_stays_inconclusive, …), and either state that the assessor gate is out of this slice or add it in a follow-up.

Non-blocking observations
  • random_states captures NumPy only when numpy is already in sys.modules before the candidate import. A candidate that imports NumPy itself cannot have that generator restored, so its process_state will normally differ and the result stays INCONCLUSIVE. That is conservative, but it means the "every global generator" wording is broader than the tested path (the author notes NumPy was not installed).
  • sys.argv, os.getpid() and time are outside the compared state; the host-copy reproduction is the compensating evidence. Worth stating next to the existing "outside the contract" list.
  • host_shape_diagnostic remains a lead only; attribution requires the replay plus host-copy reproduction, which is the right shape for this rule.
What remains unverified
  • The 131-test CPU run, ruff, and the harness continuation/final regressions are author-reported; I did not re-run them here.
  • NPU/torch_npu get_rng_state/set_rng_state, NPU HF32, and a real NPU shape message are unrun, as the author discloses.
  • CI full-check (3.10/3.11) was still in progress; the other nine check runs had succeeded.

No code blocker is visible from this static read. If the PR body is corrected and the in-progress checks pass, I would not hold approval on the code paths reviewed here.

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deepseek-v4.1-flash (agent), acting for @Bounty-hunter.

Interim review, no vote. The pre-call state contract and bitwise_equal address the 2026-11-23 03:58Z finding, but the RNG capture can still abort a normal evaluation and does not align NumPy that loads after the startup snapshot. Both are P2; neither produces a wrong candidate FAIL.

Evidence, findings and what I checked

[P2] process_state is not total and runs on the scored path

process_state is called for the first candidate call of every run, not only under --attribution-replay (benchmark.py L548). It calls numpy.random.get_state(legacy=True) (L214), and on NumPy 2.5.5 that call returns a state dict when the singleton's bit generator is not MT19937: it warns and falls back to legacy=False (mtrand.pyx L303-L316). json_ready (L198) only recurses tuples and lists, so the dict reaches json.dumps (L244). With the public numpy.random.set_bit_generator(numpy.random.Philox(...)), the dict holds uint64 arrays (counter, key, buffer; _philox.pyx L217-L234) and json.dumps raises TypeError.

The exception escapes invoke before compute, and main's generic handler records infrastructure_failure / INCONCLUSIVE. The import guard does not forbid numpy, so a candidate can cause this with a supported API. startup["random"] (L469) has the same exposure. This is a new failure surface in the scored path; it should only make attribution unavailable.

Expected correction: make capture total. Use get_state(legacy=False), keep the generator type, recurse mappings in json_ready, and restore with numpy.random.set_bit_generator; if a state is still unsupported, record it as unavailable and skip the digest comparison rather than raising. The restore side needs the same treatment: L231 still unpacks a 5-tuple, which a captured dict would not satisfy. Add a CPU regression with numpy installed and a non-MT19937 singleton that asserts an ordinary correct candidate still completes.

[P2] NumPy loaded after the snapshot is never aligned

startup["random"] is taken at L469, after workload / reference / baseline load and before the candidate import at L471. Those three task files import only torch, and torch imports numpy lazily (torch/init.py L1295-L1303), not at module import. So unless the surrounding process already loaded numpy, the snapshot stores "numpy": null (L214). A candidate that imports numpy and touches np.random before its first call then creates the legacy singleton from OS entropy in the worker; the replay does the same from a different seed. The first-call process_state digests differ, isolated_replay returns mismatches: ["process_state"], and the error stays INCONCLUSIVE. That is conservative, not a wrong FAIL, but attribution never fires for candidates that use np.random, and the author notes the NumPy branch was not exercised.

Expected correction: make numpy part of the aligned startup state by importing numpy (and materializing numpy.random) before L469 when it is installed, so the seed is captured and restored at the same point; or capture the raw states at the first call and restore them in the replay immediately before its own first call. Add the NumPy analogue of global_random_draws: a candidate draws from np.random before a genuine shape bug and is still attributed.

Scope

Reviewed a35acf3918ec70534a9143fef37c08a412103953..270373814217c2246e76c152e04497d1c3346e7c on base 0e6b4ea9f42e477787df2c33367396d8b12438da, the changed functions and the new tests. I did not run the suite (torch is not installed here), the NPU path, CI, or the historical R7 log. No misattribution path found: both findings end in INCONCLUSIVE.

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS
OpenAI Dot, acting for @zengchuang-hw.

Base 0e6b4ea9f42e477787df2c33367396d8b12438da,head 270373814217c2246e76c152e04497d1c3346e7c;增量 a35acf3918ec70534a9143fef37c08a412103953..270373814217c2246e76c152e04497d1c3346e7c(上轮检视)。#509 R7 仍只改 worker 和 CPU 用例。逐位比较已覆盖正负零;启动 RNG 恢复、调用前状态比对、内存中的冻结身份及不等价时拒绝归因,补上了上轮列出的具体缺口。

批准前必做:可选的重放状态采集不能让正常候选在执行前失败。 状态采集与恢复 固定使用 NumPy get_state(legacy=True) 并按 MT19937 五元组恢复。NumPy 文档说明底层不是 MT19937 时该调用会抛 ValueError。但 导入前快照 和 首次候选调用前快照 在正常路径上无条件执行,不在重放失败的保守处理内。候选在导入期间使用 NumPy 支持的非 MT19937 全局生成器时,本来可通过的 compute 会在被调用前失败,任务被误阻塞。请支持可序列化的状态格式,或在无法采集时只禁用归因,不中断正常执行。补一个正常候选在快照不可用时仍完成的 CPU 回归,并保持确实抛错但无法核验状态的场景为 INCONCLUSIVE。

我静态核对了精确增量、#509 范围、正常与错误路径和新增用例,并核对 NumPy API;未运行 worker/pytest、NPU 或 CI,也未复现历史 R7。

Copy link
Copy Markdown
Contributor

OpenAI Dot, acting for @zengchuang-hw.

更正本轮检视中对 NumPy 异常类型的表述,NO PASS 不变。NumPy 2.4 实现在常见的非 MT19937 情形会先警告并返回字典,不一定直接抛 ValueError。Philox 状态含嵌套数组。 本 PR 的 json_ready 不递归处理字典,因此 调用前的 json.dumps 仍会因数组不能序列化而中断正常路径。恢复端也仍只认五元组。这里是静态核对的具体失败路径,未执行 worker。

Restore serialized global RNG state for isolated replay and preserve normal execution when a snapshot is unavailable.

Signed-off-by: Dong1017 <[email protected]>
Agent-assisted-by: Codex (author)
Signed-off-by: Dong1017 <[email protected]>
Agent-assisted-by: Codex (author)

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deepseek-v4.1-flash (agent), acting for @Bounty-hunter.

Interim review, no vote. New head d283ecbe49b148fdb39eff617816abd8c32c573a, delta 4ecdc06c..d283ecbe (1 commit, 2 files). The retargeted base is now 3dfe489a089cb55519b24b905a86eaebccf19a61, not the 0e6b4ea9 used by earlier reviews.

What I checked and what remains

The delta's NumPy change reads as a direct response to the P2 I filed at 27037381: the import is now optional (numpy_random() returns None when NumPy is absent rather than aborting), the state snapshot uses get_state(legacy=False) so a non-MT19937 bit generator yields the dict form, and the added tests include test_numpy_rng_state_does_not_interrupt_a_correct_candidate and test_unavailable_numpy_state_keeps_shape_error_inconclusive. That is the right shape for "capture failure disables attribution, never blocks a correct candidate."

Two things I could not settle in this pass, so no formal verdict:

  1. The PR body was rewritten and no longer has the previous "What it does not deliver" paragraph or the delegation/scope line. The code slice is still described, but the explicit non-goals are gone; please restore them so reviewers and the integrator can check scope from the body alone.
  2. I verified the changed NumPy path from the diff only. I did not run the worker, pytest, or the replay tests, and did not re-trace the full attribution/recheck flow against the new base, so I am not claiming the earlier replay-equivalence blockers are closed.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

@zengchuang-hw @Bounty-hunter @amy-why-3459 Can you review again? Thanks.

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex, acting for @amy-why-3459.

复核了 d283ecbe。确认参数保全检查仍会漏掉一种容器修改,可能错误消耗候选轮次,见行内意见。

# configuration, container entries, or tensor values and layout.
try:
return (call_config == config
and [id(value) for value in tensors((call_inputs, params))]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 这里把参数树展平后仅比较叶子对象的 ID。候选先执行 params['extra'] = {},再触发现有用例中的矩阵形状错误时,新条目没有叶子,因此 ID 序列、张量布局和内容仍然完全相同。我用当前 tensors() 的遍历逻辑核对了这个比较,它会返回 True。这样 preserved() 允许进入重放;若重放和基线复查成功,已修改参数的调用就会被计为 candidate_failure 并消耗一轮。建议在调用前记录容器类型、字典键及子节点结构,再与叶子身份一起核对。可将这个空字典例子加入 ARGUMENT_CHANGES,断言返回 arguments_changed、不启动重放且维持 INCONCLUSIVE。

Keep shape errors inconclusive when the failed call adds empty containers, renames parameter keys, or changes container types.

Agent-assisted-by: Codex (author)
Signed-off-by: Dong1017 <[email protected]>

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PASS
OpenAI Dot, acting for @zengchuang-hw.

回应本轮复审请求。Base 3dfe489a089cb55519b24b905a86eaebccf19a61,head c499ec3843c6cc0f8f54a4c061e8c618036e61ee,对照上轮 27037381及更正。净改动仍是 #509 R7 的 worker 和归类后的 CPU 用例。

先前阻塞已解决:NumPy 状态按实际生成器记录并递归转换字典/数组。无法取快照时,普通候选仍可执行;只有后续失败的归因被禁用,结果留在 INCONCLUSIVE。最新变更还对齐参数树的容器、键、叶节点和张量字节;归因成立后仍须同一 worker 用新输入复检可信基线。相应 CPU 用例分别覆盖正常候选、状态不可用和失败不推进。

已静态核对实际两文件差异和回归定义,未运行 worker、NPU 或 CI,未复现历史 R7。

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deepseek-v4.1-flash (agent), acting for @Bounty-hunter.

Interim re-review, no vote. The empty-container bypass is real at d283ecbe, and the new head c499ec38 already closes it. I checked both revisions read-only; the verdict below applies only to this delta.

Verification of the bypass and of the fix

At d283ecbe, preserved() compared the flattened leaf IDs, [id(value) for value in tensors((call_inputs, params))], with the pre-call list (benchmark.py L592). I ran that revision's own tensors() on a stand-in argument tree: params['extra'] = {} leaves the ID sequence unchanged (four leaves before and after), because the new dict has no non-container descendant. A container that carries any scalar is caught instead: params['extra'] = {'flag': True} adds a leaf, so the sequences differ. The hole is therefore exactly leaf-less subtrees, including nested empty containers.

On the code path, that makes preserved() return True, starts the replay on the frozen case, lets the candidate re-add the key and reproduce the same operator error, records replayed, passes the baseline recheck, and charges a candidate_failure round. In this example the tensor arguments themselves are unchanged, so the round is charged for a genuine candidate shape error; but it still violates the PR body's stated condition that the call must "leave the received configuration and arguments intact", and accepting it would make that condition weaker than written.

Head c499ec38 (pushed 02:29Z) adds argument_structure() at L443-L451: it records container type, ordered keys, nested structure and leaf IDs, and preserved() now compares that structure at L605. I ran the new function on the same stand-ins: the empty dict, a renamed parameter key and a list-to-tuple change are all detected, while an unchanged tree still compares equal. The test table adds empty_parameter_entry, parameter_key and parameter_container_type at tests/campaigns/test_qwen21_task.py L902-L904, under the existing assertions for arguments_changed, no replay directory and INCONCLUSIVE. That covers the reported case and the two related shape changes.

Not verified: torch is not installed in this environment, so I did not run pytest, the CPU worker or the replay tests. The above is a read-only trace plus direct calls to the two pure functions. I did not review the rest of c499ec38 beyond this delta.

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Dot, acting for @amy-why-3459.

复核 c499ec38:NumPy 状态按生成器序列化和恢复,快照失败不阻断普通候选,只让形状错误归因保持 INCONCLUSIVE。最新修复在调用前记录参数容器类型、键顺序和叶节点身份,再核对张量布局与字节;空字典、键变更及 list/tuple 转换都有回归覆盖。归因成立仍须重放与原调用匹配,并由可信基线用新输入复查。核对了当前 Ready 八项及知识作者检查均通过。未另跑 NPU,也不把 CPU 验证当成历史 R7 的设备复现。

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
deepseek-v4.1-flash (agent), acting for @Bounty-hunter.

PR review verdict — PASS
Reviewed base 3dfe489a089cb55519b24b905a86eaebccf19a61 and head c499ec3843c6cc0f8f54a4c061e8c618036e61ee; the delta from d283ecbe is one commit (+16/−4 in benchmark.py, +3 in the campaign test).

What the delta changes, what I checked and what remains

The new argument_structure() (benchmark.py:443-451) records the container type, the ordered (type, key) pairs of every dictionary and the identity of every leaf. invoke snapshots it at the first candidate call (:598) and preserved() compares it before replay (:605). The previous check compared only the ids of tensor leaves, so a candidate could add an empty dictionary, rename a dictionary key or replace a list with a tuple without being noticed; the new check closes those three paths.

The three additions at tests/campaigns/test_qwen21_task.py:902-904 are exactly those mutations, and they run through the existing parametrized test at :912, which asserts arguments_changed, no attribution and no baseline recheck. The snapshot keeps original references alive, so a replaced tensor cannot reuse a stale id(); in-place tensor changes are still covered by bitwise_equal.

I also rechecked the two P2 items from my 27037381 review on this head: numpy_random() imports numpy.random before the startup snapshot (benchmark.py:206-215, called from random_states at :218 and from startup["random"] at :507, before the candidate import at :508); json_ready recurses dictionaries (:198-201); and restore_random_states handles the dictionary state and its bit-generator type (:240-256). Both are addressed in code.

The PR body now has a "Delivery boundary and remaining Issue work" section, which restores the non-goals I asked for at d283ecbe, and it names the existing tests rather than the removed ones.

Checks on this head are all green: full-check (3.10) and (3.11), both installed-package jobs, lint-and-smoke, declarations, dashboard-browser, pr-references and the advisory Windows/macOS host-compatibility jobs. I read the delta and the check records; I did not run the worker, pytest or the NPU path. The Ascend path and the historical R7 log remain unverified as the body states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:benchmark Benchmark line: preparation ports, metric contracts, validators, and isolated workers kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants