Skip to content

test: run one unattended Codex optimization and validate latency on Ascend A2 - #677

Open
zengchuang-hw wants to merge 4 commits into
mainfrom
codex/479-qwen-image-e2e-pytest
Open

zengchuang-hw wants to merge 4 commits into
mainfrom
codex/479-qwen-image-e2e-pytest

Conversation

@zengchuang-hw

@zengchuang-hw zengchuang-hw commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Refs #479

本 PR 增加一个 Ascend A2 上的黑盒 E2E 用例。测试者提供固定环境和一条自然语言请求,启动一次 pytest。用例独立检验 Codex 能否在无人值守的情况下恰好完成 3 轮并交付三轮中的最佳补丁,以及该补丁能否保持图像像素一致并降低生图耗时。

黑盒测试图

flowchart TB
    E["测试条件<br/>单卡 A2、固定基线和只读模型"]
    I["测试输入<br/>用户请求、固定生图负载"]
    T["黑盒入口<br/>启动一次 pytest,无人值守完成 3 轮"]
    O["可观察输出<br/>最终回复、补丁、图像和原始耗时"]
    V["验收校验<br/>交付可重建、像素一致、耗时下降"]
    R["PASS / FAIL / INCONCLUSIVE"]
    E --> T
    I --> T
    T --> O --> V --> R
Loading

测试条件与输入

  • 环境。 Linux Ascend A2,进程只看见一张空闲的 Ascend 910B。预先准备已登录的 Codex CLI、可用的 InferRSI、与固定基线匹配的 vLLM-Omni 昇腾依赖,以及同一份本地只读 Qwen-Image-2.1-Turbo 权重。vLLM-Omni 固定为 f69b1f2b19cece03f6736c7da093ea25de0e24fd(见 task: 设计首个 Codex 用户使用 InferRSI 的端到端用例 #479)。基线与候选均从这个提交开始,QWEN_E2E_REVISION 使用该完整 SHA。
  • 用户输入。「请用 InferRSI 优化当前 vLLM-Omni 项目的 Qwen-Image-2.1-Turbo,在 Ascend A2 单卡上生成 1280×704 图片,保持出图质量,把单张生图耗时降到尽可能低。请完成 3 轮优化迭代,再复测这 3 轮中表现最好的方案,并交付补丁、优化前后的单张生图耗时和降幅。」用例自动附上模型、测量程序和本次 campaign 的位置。启动后无需人工答复、审批、补录记录或挑选候选。
  • 固定负载。 workload.json 固定 2 次预热和 6 个测量输入(种子 42–47)。1280×704、BF16、请求 8 步、CFG=1、每请求 1 张图。基线与候选使用相同负载。从调用 Omni.generate 到取得解码图像计时,模型加载、预热和 PNG 写盘分别处理。
python -m pytest -qs e2e/qwen_image/test_user_journey.py

启动前配置 QWEN_E2E_REPO、QWEN_E2E_REVISION 和 QWEN_E2E_CHECKPOINT。如 #479 约定最低降幅,用 QWEN_E2E_MIN_GAIN_PCT 在开跑前设定。完整运行说明

可观察输出与校验点

校验点 输出与检查
基线可重复 两个独立进程各跑一组基线。逐种子比较 6 张图的解码 RGBA 字节,并核对测量配置凭证。将两组中位耗时的相对差冻结为 A/A 噪声参考,保存在 frozen.json。
优化完成且交付一致 保留最终回复、会话日志和 InferRSI campaign 记录。核对回复非空、campaign 采用固定三轮预算、恰好完成 3 轮并完成 final,以及实际交付源码与 final 候选的摘要一致。
补丁可独立重建 提取并保留 candidate.patch。从另一份干净基线应用补丁,核对重建后的 vllm_omni/ Git 树与交付源码一致。
画质和耗时可复核 A 为基线,B 为重建候选,按 AB → BA → AB 复测。每侧每组使用新进程,保留图像和原始耗时。各组图像逐种子与最初的基线比较。汇总取每侧三个组中位数的中位数。

result.json 记录阶段、要求完成的轮数、实际完成轮数(campaign 校验通过后)、判定及错误原因。复测完成时还记录基线与候选耗时、节省毫秒数、降幅、加速比和像素不一致的种子。降幅按 100 × (基线耗时 − 候选耗时) / 基线耗时 计算。

通过与失败

判定 条件
PASS 全部校验完成,候选在每组、每个种子上与基线逐像素一致,降幅为正、达到预设最低降幅,并且严格超过 A/A 噪声。
FAIL Codex 完成却交付空补丁,或重建后的 Git 树与交付源码不符。完成复测后,任一种子的候选像素变化、耗时持平或变慢、降幅低于最低门槛,均判失败。
INCONCLUSIVE 基线不稳定、环境不一致、执行中断或交付证据不足。正向降幅达到最低门槛但未超过 A/A 噪声时也归此类。

FAIL 和 INCONCLUSIVE 都使 pytest 返回非零,具体原因以 result.json 为准。

当前验证状态

  • pytest 收集到 1 个用例,Ruff、编译检查和 8 项本地冒烟测试通过。7 个 CPU 模拟场景得到预期判定,覆盖补丁提取与重建、像素变化、无收益、低于门槛、噪声内收益、基线漂移和空补丁。
  • 三轮用例已在 A2 实机复跑。两组基线各完成 6 张测量图,逐种子 RGBA 全部一致。本次试跑使用了可写的模型挂载,测量进程仅读取权重。Codex 连接模型服务反复超时,campaign 尚未创建。停止卡住的进程后,result.json 记录为 INCONCLUSIVE(stage=codex)。暂无候选独立复测数据或三轮优化幅度。
  • 新提交的 5 项轮数校验均通过,覆盖恰好三轮、少于三轮、多于三轮及预算配置不符。
  • 采样条件校验的当前覆盖范围是请求传入的 sample_sigmas。本地模拟实际步数从 8 减到 7 时,凭证仍一致,实际执行的网格和步数仍待校验。

Exercise the natural-language entry point, recompute round decisions and independent results, and verify the delivered source against the measured candidate. Keep historical replay and the real Codex/A2 run opt-in.

Agent-assisted-by: Codex (implementation and verification)
Signed-off-by: zengchuang <zengchuang3@huawei.com>
Agent-assisted-by: Codex (implementation and verification)
Signed-off-by: zengchuang <zengchuang3@huawei.com>
@Dong1017 Dong1017 added kind:task Bounded delivery task with a delegated slice area:harness Harness module: profile, A/B loop, quality gates, evidence reports labels Nov 25, 2026

@david6666666 david6666666 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 @david6666666 under delegated PR review.

Static review of the opt-in test and audit; no live Codex or Ascend run.

Comment thread e2e/qwen_image/test_user_journey.py Outdated
plan, _ = seal(options["project"], options["baseline_revision"], campaign,
options["patch"], output / "independent", submission=submission)
execute(output / "independent", plan, options["timeout_seconds"])
report = audit(campaign, options["observer"], host_reply=output / "final-reply.txt")

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 @david6666666 under delegated PR review.

The local-retest path writes the new receipt to output / "independent", but audit() then reads observer["independent_directory"] relative to the observer directory. If the observer and output are separate, the audit can ignore the just-run attempt and use a different receipt for the same patch, or report missing evidence even after the retest succeeded. Please bind the live audit to the directory it just created and add a local-mode regression with a different observer receipt and separate directories.

… on A2

Agent-assisted-by: Codex (implementation and verification)
Signed-off-by: zengchuang <zengchuang3@huawei.com>
@zengchuang-hw zengchuang-hw changed the title test: add end-to-end pytest coverage for the Codex Qwen-Image workflow test: run one unattended Codex optimization and validate latency on Ascend A2 Nov 25, 2026

@david6666666 david6666666 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 @david6666666 under delegated PR review.

Static review of the rewritten unattended A2 path; no live Codex or NPU run.

Comment thread e2e/qwen_image/measure.py
"model_index_sha256": hashlib.sha256(model_bytes).hexdigest(), "sample_sigmas": sigmas,
"seeds": [case["seed"] for case in workload["requests"]],
"warmup_ms": warmup_ms, "latencies_ms": latencies_ms, "median_ms": median(latencies_ms),
}

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 @david6666666 under delegated PR review.

sample_sigmas here records the requested values from workload.json, not the grid the scheduler actually executed. A candidate can change how those values are handled and this receipt still matches the baseline. #479 requires the effective grid to be retained for the compared runs. Capture the effective timestep/sigma sequence and step count at the runtime boundary and reject a mismatch; add a regression that keeps the requested values unchanged while the effective grid differs.

Freeze the exact round budget in the user journey and verify it against the completed campaign before independent retest.

Agent-assisted-by: Codex (implementation and verification)
Signed-off-by: zengchuang <zengchuang3@huawei.com>

@david6666666 david6666666 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 @david6666666 under delegated PR review.

The new exact-three assertion still permits three submissions of the same unchanged candidate. I verified this in isolation with the exact optimize function and controlled campaign records; no live Codex or A2 run.

# The campaign and final reply must both belong to this fresh invocation.
plan = json.loads((campaign / "plan.json").read_bytes())
state = json.loads((campaign / "state.json").read_bytes())
completed_rounds = len(state["rounds"])

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.

This counts records, not effective optimization iterations. I ran the current optimize() with a synthetic completed campaign whose three rounds and final all held the same candidate digest; it returned 3. The governing #479 contract explicitly excludes an unchanged repeat from the optimization-candidate count. Validate retained round identities/evidence (source and declared candidate configuration), and add a negative fixture with three records but only one real change. A real distinct candidate may still count if its measured result is rejected.

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

Labels

area:harness Harness module: profile, A/B loop, quality gates, evidence reports kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants