Skip to content

feat(w5): 完整 Qwen3 token 生成、容器复现与专项验收 - #115

Open
yuki-328 wants to merge 9 commits into
ScratchV-Compiler:mainfrom
yuki-328:codex/w5-generation
Open

yuki-328 wants to merge 9 commits into
ScratchV-Compiler:mainfrom
yuki-328:codex/w5-generation

Conversation

@yuki-328

@yuki-328 yuki-328 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

W5 将 W4 的单次模型前向接成文本生成:本机 Python 处理提示词、逐步选 token 并校验,QEMU 中的 RISC-V 程序执行模型。三条冻结用例复用同一 ELF 和权重文件,支持命令行、多轮历史管理和干净容器部署。

阅读入口

链接均固定到本次提交 e72cd2d,不依赖本机 output 页面。

本次文档整理

原报告把结果、详细解释和环境准备交叉放置,读者需要来回寻找。本次仅修改两份 Markdown:

  • W5 README 按“改动与功能 → 实验结果 → 如何复现 → 其他”组织,先给实际生成文字、耗时、数值误差与停止原因。
  • 四项常用解释保留在实验结果表格下方并分别折叠:名称说明、8 次 QEMU 如何生成一条结果、最大绝对误差、三例合计耗时与内存。详细实现和历史材料放入“其他”,保留既有链接锚点。
  • LINUX_REPRODUCTION.md 集中 W5 的工具、固定资产、资源要求、容器镜像/挂载及完整独立复现流程;报告只保留准备指引、运行命令和结果检查。

本轮未改变运行代码、数值策略或 CI 配置,也未重跑模型。

W5 功能与默认行为

  • 原始文本补全、三条固定参考用例与官方模板多轮文本;成功后才保存整轮会话历史。
  • 逐步对比完整 logits、greedy token ID、最终文字和停止原因,支持 EOS、预算与上下文容量限制。
  • 默认 1 core,支持手动 1/2/4 和启动/构建时 auto,上限 4;不在 token 之间动态调核。W5 padding 始终为 none。
  • 统一使用 --cores / cores,兼容 --harts / harts、parse_args().harts、旧构建记录和 C 宏;asdict() 导出一致的双字段,replace() 更新任一名称时同步别名。
  • 保留超时、取消、进程清理及失败后复用。报告保存失败不掩盖原始错误;生成和 tee 日志退出码分别保存,任一失败均判失败。

已有完整模型结果

以下来自 2026-10-23、基线 8ad3474,不是本次提交的新测量:完整 28 层 Qwen3-0.6B、FP32、固定长度 256,显式 4 core / blocked_fma / 2×4 / column-panel / Mean two-four-lane-last-axis / nonlinear fp32-reference,padding 为 none。

用例 端到端生成与校验耗时(秒) QEMU 仿真总耗时(秒) 与本机 ORT 的最大绝对误差
France 3375.024 3199.695 0.000303983688
Germany 3668.852 3482.999 0.000262737274
Japan 3489.655 3315.397 0.000197887421

3/3 用例、24/24 步通过。 每条生成 8 个新 token,无 KV cache,每步都执行完整前向并启动新 QEMU,没有重复编译。全部输出有限且严格 max_abs < 0.001,逐步 token、最终文字与停止原因和冻结参考一致。

三条均因 max_new_tokens 结束,不能视为自然回答完毕;具体续写见 实际输出表。端到端生成与校验时间包含最终文字生成及核对,不含前置编译、最终报告保存或终端显示。QEMU 时间已包含在端到端时间中,不能相加。

干净容器单次前向和本机单次前向都生成 Paris,与 ORT 最大误差约 0.000172138,两边完整输出逐字节相同。本机内部计时 444.416 秒且复用构建;容器 547.454 秒,其中本次编译 93.868 秒。构建条件不同,不作为容器性能对比,也不代表容器三例完整生成已通过。

验证与普通 CI

**本轮文档检查:**现有 Linux 文档检查器通过(129 份文档、245 个 shell 代码块),两份修改文档的 84 个本地链接及相关锚点通过;折叠结构、四项说明的位置、预览一致性及 diff 格式检查通过。没有为文档修改重复执行模型或代码测试。

**既有代码验证:**提交 3782bf8 对应的相关验证为 631 passed,0 failed / error / skipped(18 项未选择)。真实 1/4 core 小图完整输出与 ORT 相同、最大误差为 0,超时/取消后的清理与复用通过;这不是本次文档提交重新运行的结果。main 013b3c7 已由此前合并提交整合。

当前文档提交 e72cd2d 的普通 CI #41068685444已完成,结果为 SUCCESS:14 个 job 成功、7 个按条件跳过,0 失败。

  • 通用测试 8501 passed、95 skipped;额外模拟器回归 7 passed。
  • W4/W5 单测与真实小图 1863 passed、4 skipped。
  • benchmark、Topic 06 benchmark、部署与前端检查、最终 CI 汇总均成功;各任务内部的详细测量以该次 Actions 报告为准。
  • 7 个跳过项为 6 项未显式请求的完整验证/生成任务 + 1 项 Pages 部署。没有因此执行完整 Qwen3 前向或 W5 三例容器生成,不能把普通 CI 通过当作完整专项通过。

以上是本次提交的远端 CI 结果;README“其他”中的旧 CI/benchmark 记录仍保留其历史版本标签。

未手动追加、请求或重跑 AI 审查;仓库随推送自动触发的审查按现有规则执行。

剩余范围

  • 现有报告仍未包含完整三例的独立容器实跑、第二人独立复现回传或完整 W5 专项成功记录。普通 PR CI 不自动执行这些完整任务。
  • 独立复现命令固定历史数值基线 8ad3474,不能用它宣称验证了后续兼容修复;作者测试或 CI 不能替代第二人执行。
  • 每 token 重启 QEMU、装载权重、重算完整前向仍是性能限制;KV cache、常驻运行和完整模型多轮聊天不在已有实跑结论内。
  • PR 中的审查脚本修复需进入可信 main 后,才会供后续 pull_request_target 使用。

本次不修改 WSL 配置,不合并 PR。

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🤖 AI Code Review

Head: e72cd2d
PR files: 63; fetched: 63; reviewed: 5; failed/missing: 58; unreviewable: 0.
Coverage: INCOMPLETE. Unreviewed files are listed below; green means no systemic failure, not full coverage. A completed AI response is not approval or proof of correctness.

Full per-file results and batch artifacts

Files without a review

  • ".github/workflows/ci.yml": failed — HTTP 429
  • ".github/workflows/llm-deploy.yml": failed — HTTP 429
  • ".github/workflows/w4-full-numeric.yml": failed — HTTP 429
  • "THIRD_PARTY_NOTICES.txt": failed — HTTP 429
  • "deployment/w5/Dockerfile": failed — HTTP 429
  • "deployment/w5/Dockerfile.dockerignore": failed — HTTP 429
  • "docs/INDEX.md": failed — HTTP 429
  • "docs/llm-deploy-v1.0/W4/reports/full-hart-comparison-2026-10-22.json": failed — HTTP 429
  • "docs/llm-deploy-v1.0/W4/runtime-contract.md": failed — HTTP 429
  • "docs/llm-deploy-v1.0/W4/softsim-optimization-2026-10-22.md": failed — HTTP 429
  • "docs/llm-deploy-v1.0/W4/validation.md": failed — HTTP 429
  • "docs/llm-deploy-v1.0/W5/README.md": failed — HTTP 429
  • "docs/llm-deploy-v1.0/W5/reports/validation-summary.json": failed — HTTP 429
  • "docs/llm-deploy-v1.0/开发计划.md": failed — HTTP 429
  • "probes/w4_qwen3_full/diagnostic.py": failed — HTTP 429
  • "probes/w4_qwen3_full/run.py": failed — HTTP 429
  • "probes/w5_generation/README.md": failed — HTTP 429
  • "probes/w5_generation/references.json": failed — HTTP 429
  • "probes/w5_generation/run.py": failed — HTTP 429
  • "pyproject.toml": failed — HTTP 429
  • "scratchv/backend/tensor_c_codegen.py": failed — HTTP 429
  • "scratchv/backend/tensor_c_nonlinear.py": failed — HTTP 429
  • "scratchv/runtime/conversation.py": failed — HTTP 429
  • "scratchv/runtime/generation.py": failed — HTTP 429
  • "scratchv/runtime/qemu_generation.py": failed — HTTP 429
  • "scratchv/runtime/riscv_external.py": failed — HTTP 429
  • "scratchv/runtime/riscv_harts.py": failed — HTTP 429
  • "scratchv/runtime/weight_bundle.py": failed — HTTP 429
  • "scripts/ai_code_review.py": failed — HTTP 429
  • "scripts/check_w5_ci.py": failed — HTTP 429
  • "scripts/ci_scopes.json": failed — HTTP 429
  • "scripts/deploy_w5.sh": failed — HTTP 429
  • "scripts/run_inference.py": failed — HTTP 429
  • "tests/llm-deploy/w5/README.md": failed — HTTP 429
  • "tests/llm-deploy/w5/conftest.py": failed — HTTP 429
  • "tests/llm-deploy/w5/test_docker_cancellation.py": failed — HTTP 429
  • "tests/llm-deploy/w5/test_report_persistence.py": failed — HTTP 429
  • "tests/test_ai_code_review.py": failed — HTTP 429
  • "tests/test_ci_routing.py": failed — HTTP 429
  • "tests/test_ci_workflows.py": failed — HTTP 429
  • "tests/test_conversation.py": failed — HTTP 429
  • "tests/test_generation.py": failed — HTTP 429
  • "tests/test_qemu_generation.py": failed — HTTP 429
  • "tests/test_riscv_external_contract.py": failed — HTTP 429
  • "tests/test_riscv_external_harts.py": failed — HTTP 429
  • "tests/test_riscv_mean_policy.py": failed — HTTP 429
  • "tests/test_tensor_c_external.py": failed — HTTP 429
  • "tests/test_tensor_c_mean_policy.py": failed — HTTP 429
  • "tests/test_tensor_c_nonlinear_policy.py": failed — HTTP 429
  • "tests/test_w3_workflows.py": failed — HTTP 429
  • "tests/test_w4_ci_summary.py": failed — HTTP 429
  • "tests/test_w4_diagnostic.py": failed — HTTP 429
  • "tests/test_w4_full_probe_contract.py": failed — HTTP 429
  • "tests/test_w4_workflows.py": failed — HTTP 429
  • "tests/test_w5_ci.py": failed — HTTP 429
  • "tests/test_w5_deployment.py": failed — HTTP 429
  • "tests/test_w5_generation_reference.py": failed — HTTP 429
  • "tests/test_w5_inference_cli.py": failed — HTTP 429

Preserve primary errors and signal exit codes when report persistence fails. Verify real Docker SIGINT/SIGTERM cleanup and executable reuse on 1/4-hart small graphs. Consolidate W5 development documentation and reproduction instructions.
Use cores consistently while retaining legacy CLI, Python and metadata aliases.
Cover argparse attributes, dataclass serialization/replacement and conflicting
configuration values without changing default single-core execution.

Publish the expanded W5 generation/report explanations and historical summary.
Separate reused builds, program elapsed time and container compilation time.

Validation: 591 relevant W4/W5 interface and small-QEMU tests, plus 40
instruction-counter tests after merging main. No full model or Docker rerun.
Organize the W5 report around changes, measured results and reproduction.
Keep timing and accuracy explanations below the results table, and move
Linux/container preparation into the shared reproduction guide.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants