Repository navigation
Conversation
Signed-off-by: psv666 <2693925048@qq.com>
Signed-off-by: psv666 <2693925048@qq.com>
Signed-off-by: psv666 <2693925048@qq.com>
|
@david6666666 @MrDongsls @Levius-Fubuki @zengchuang-hw @hsliuustc0106 Could you please review this Kev-4B export and FP32 pointer-head slice? The complete native Rust/CUDA worker is in #197 and remains a separate review. |
hsliuustc0106
left a comment
There was a problem hiding this comment.
First review: PR #170 — "Kev: add pinned CPU export and FP32 pointer-head validation"
Reviewer: first-pass review agent (State at review: OPEN, DRAFT (author states it stays draft; human checkboxes intentionally unchecked). Verdict below is therefore COMMENTED, not APPROVED/CHANGES_REQUESTED.
Head reviewed: 8f765fdbf9eb782ab6f9d731df359699b70398ba (3 commits). Merge-base with main: 22b7717c9; current main tip e573260cc is 4 commits ahead.
Authoritative diff vs merge-base: 20 files, +1801/−1 (matches GitHub API changed_files:20, additions:1801, deletions:1, mergeable_state:"clean"; the task brief's "37 files +1837/−698" reflects per-commit churn including the merge commit, not the cumulative diff).
Template gate status
- Four post-#138 answers: PRESENT. Outcome / highest-leverage variable / how the work moves it / customer and need, all four answered under "Required human contributor answers", attributed to the contributor's 2026-10-25 answers on the original #170.
- Necessity ("Is a PR needed?"): PRESENT and answered (contributor requested implementation PRs; export/head and worker slices kept separately reviewable).
- Checklist: PRESENT — all four boxes present and unchecked, consistent with draft state and the template's "keep in draft while incomplete".
- Other template sections: Purpose, Summary, Test Plan (with System1-Omni Version / Commit: base
22b7717c9, slice8f765fdbf), Test Result / Evidence, Demo / evidence (incl. video/perf N/A with reasons), Merge Danger (Door: two-way, Blast Radius: Kev), Self-review. Gate formality is satisfied for a future ready-flip; only the human boxes remain, which is correct for a draft.
Commit-by-commit
4be35df4— feat(kev): add pinned CPU export and FP32 pointer head. The whole slice in one commit (parentcd302b6e, an older main): exporter, nativeomni-kev-nativecrate (head + postprocess), committed oracletests/kev/data/head.json, generator, Python export tests, recipe/model docs, CI job, workspace member, Apache-2.0LICENSE.kev. 20 files, +1764.76b764ae— Merge current main (22b7717c9) into the branch. Resolution diff vs first parent is additive (picks up main's workspace/docs additions); no Kev content lost — cumulative diff vs22b7717c9equals the sum of the two non-merge commits. Clean merge; no conflict markers.8f765fdb— fix(kev): validate every pinned LoRA projection target. Replaces the count-only check (len(pairs) != 248) inrecipe/kev/export.pywith a full expected-name-set comparison (expected_targets()/validate_targets()) and adds a test that also rejects a same-count/wrong-target inventory. Exactly the fix the PR body advertises.
Hygiene: linear intent, merge commit is a plain main-sync. Both git merge-tree --write-tree origin/main origin/pr/170 against current tip e573260cc and a file-overlap check with the 4 new main commits (cua_s1 prefix cache, qwen3_5 prefix states) show no overlap and no conflicts — a re-sync will be trivial but should happen before ready.
Contracts
Pinning — hash-pinned, not merely rev-pinned. recipe/kev/export.py pins SHA-256 for all 6 base files (config, tokenizer, tokenizer_config, index, both shards) and all 3 checkpoint files (adapter_config, adapter_model, head.pt) in BASE_FILES/CHECKPOINT_FILES; verify_files() runs before any parse. HF revisions (Qwen/Qwen3.5-4B-Base@1001bb4d, jaredpalmer/kev-4b@139fdd94, reference 2074cc44) are recorded and written into the output manifest. So identity is hash-pinned at file level and rev-pinned at repo level — the stronger of the two.
Atomic staging / no partial dirs — matches the #118 v2 export lesson and the #147 Valen precedent. export() refuses an existing output; stages into tempfile.mkdtemp inside out.parent; os.rename(staging, out) on success; finally: shutil.rmtree(staging) removes the stage on any failure (after a successful rename the stage no longer exists). This is the same discipline as recipe/valen/export_checkpoint.py (staging + os.replace + per-file sha256 manifest, from merged #147), and Kev is stricter on inputs: every input file is hash-verified, and head.pt is hashed before torch.load(..., weights_only=True) — with a dedicated test (test_wrong_hash_precedes_pickle_loading_and_output_creation) pinning that a wrong hash aborts before pickle deserialization and creates nothing on disk.
Manifest. kev_export.json records format kev-4b-merged/1, both revisions, dtypes, dimensions, calibration temperature, the five base tokenizer delimiter IDs, the sorted list of 248 merged targets, the hash-pinned inputs, and SHA-256 of every output file. (Standard self-exclusion: the manifest cannot hash itself.)
FP32 pointer-head validation — what against what.
- Oracle:
tests/kev/generate_head_fixture.pyverifies SHA-256 of the entire upstreamkev/model.py(2ff3b2e6…) andhead.pt(dd633435…), extracts only thePointerHeadclass via AST, execs it against torch, and runs deterministic hidden states ((i*37 + row*19) % 101rule) for 1/2/7/31/255 options. Output is committed astests/kev/data/head.json(638 lines, numeric oracle + provenance; no weights committed — artifact hygiene clean). - Subject: Rust
PointerHead(src/models/kev/native/src/head.rs) loads exactly four FP32 tensors from the exportedhead.safetensors, validates dtype/shape/finiteness, applies learned q/k biases and 1/sqrt(pointer) scaling. - The comparison test is
#[ignore]d (opt-in viaKEV_HEAD, CPU-only, by design — CI has no 8.5 GB export) with tolerances frozen in code: logits1e-4 + 1e-5·|ref|, probabilities1e-5absolute — exactly as the body claims. Author-reported observed maxima (3.129e-7 logit, 2.980e-8 prob) sit ~300× under tolerance. Two non-ignored Rust tests (biases/scaling/candidate-order; invalid-weight/input/calibration rejection incl. 256-option refusal, NaN, corrupt safetensors, bad temperatures) run in CI via a[[test]]target inomni-kev-native's Cargo.toml pointing attests/kev/head.rs. Inventory arithmetic verified independently: 96 MLP + 32 attention (8 layers × 4) + 120 GDN (24 layers × 5) = 248, matching the test.
Scope honesty. Docs/README/docs/supported-models.md rows all say preparation-only: no worker, no backbone parity, no GPU serving, native integration deferred to #27. No shared runtime/CUDA files touched. Claims match the code.
CI observed (exact head 8f765fdbf)
gh pr checks 170 + Actions API on both orgs (same runs): CI run 40649508417 — rust pass (3m12s), benchmarks pass, cuda-contract pass, cuda-compile pass (4m12s), kev-export pass (27s); Docs run 40649508669 pass, deploy skipped. All green. (CUDA compile is not GPU validation, as the body itself states; nothing here claims GPU inference.)
Local checks (no cargo/GPU; miniconda python 3.12)
PYTHONPATH=. python -m pytest tests/benchmarks -q→ 133 passed (wt170).python -m unittest discover -s tests/kev→ blocked locally: the host's miniconda torch is broken (dlopen ... libtorch_cpu.dylibnot loadable) and no other local python has torch. Not a PR defect; the CIkev-exportjob (torch 2.8.0 CPU, ubuntu) passed at this exact head, and the test file was reviewed statically (pure-torch arithmetic, gates consistent with the exporter).mkdocs build --strict→ exit 0 (wt170).
Findings
- P3 — base is stale; sync before ready. Merge-base
22b7717c9vs main tipe573260cc(4 commits, cua_s1/qwen3_5). No textual or file overlap;git merge-tree --write-treeclean. Trigger: main moves further. Consequence: none today; a routine sync keeps the future ready-check trivial. Files: (branch topology, not a file defect). - P3 — no automated end-to-end export-path test.
recipe/kev/export.py:169-241export()happy path (shard iteration → merge → index → manifest → rename) is exercised only by the author's real 8.5 GB run (248 merged projections, all hashes checked, per the body) and not by unit tests, which cover the components and guards. Trigger: a future refactor ofexport(). Consequence: CI (kev-export job) validates components/guards only; a full-path regression would land silently. Mitigation is inherent (CI cannot ship 9.5 GB inputs); an offline small-fixture end-to-end test with synthetic base shards would close most of the gap. File:recipe/kev/export.py:169. - P3 — oracle regeneration footgun (documented).
tests/kev/data/head.jsonembeds"torch": "2.8.0+cpu", sodiff -uregeneration with a different wheel fails on the provenance field even when numerics agree. The recipe explicitly warns about this (recipe/kev/README.md, "The fixture's Torch version includes the wheel's local suffix…"). Known and documented; consider noting it next to the diff command. Files:tests/kev/data/head.json:5,recipe/kev/README.md. - P3 —
expected_targets()hardcodes the 32-layer / layer%4==3 hybrid layout (recipe/kev/export.py:43-55). Safe because the base config is hash-pinned, so a different checkpoint cannot slip through; noting only so the follow-up worker slice knows the inventory check is Kev-4B-specific, not a general validator.
Not found
No unpinned inputs, no partial-output paths, no committed weights/binaries, no shared-runtime changes smuggled in, no claim in docs exceeding the validated slice, no discrepancy between body numbers and the tree (748 authored / 1802 changed / 20 files all reconcile with +1801/−1).
Verdict
COMMENTED (draft). The export discipline (hash-pinned inputs, hash-before-parse, atomic staging, full manifest, complete-target inventory with a same-count/wrong-target regression) matches or exceeds the Valen #147 / #118 v2 precedents, the FP32 head comparison has a hash-pinned oracle with frozen tolerances, and CI is green at the exact head. No blocking findings; the P3s are pre-ready polish (sync, optional end-to-end test, doc nits). Before ready: contributor/maintainer review, checklist ticks, sync to e573260cc, and the worker follow-up remains separately reviewable as promised.
…port-review Signed-off-by: psv666 <2693925048@qq.com>
Signed-off-by: psv666 <2693925048@qq.com>
|
In response to this review. Thanks for the review. Addressed on
Fresh validation on this slice: 395 workspace Rust tests pass / 91 ignored; 9 Python tests pass; fmt, Clippy, release, Ruff and strict docs pass. A freshly hash-verified released head passes the original oracle gates: max logit error The previous temporary directory and its raw export/worker evidence are currently unavailable. Historical results remain labeled as such; the updated PR body distinguishes them from this round's fresh tests. #197 retains the full-worker review and its separate remaining integration requirements. New-head |
Levius-Fubuki
left a comment
There was a problem hiding this comment.
2026-11-02 实测复核:PR #170 — 可以优先推进
PR: #170
Head: 85119d093fa3cb6ae5244b1d5c7eb2619084d9a2
Base: 5fa5179d57f9267bb0d20162004d8ce26352aa9d
结论:在该 PR 的 CPU 导出 / FP32 pointer-head 范围内,没有发现需要修复后才能推进的阻塞。优先于 #197;当前仍为 Draft,转为 Ready 是作者的后续操作。本次没有更改 PR 状态。
实测:
- 隔离 Cargo target 后的完整 workspace 测试:395 passed / 0 failed / 91 ignored;fmt、严格 Clippy、release build 全通过。ignored 不算通过;本 PR 所需真实 head 检查另行执行。
- Python 导出回归:9 passed。
- 固定 Qwen3.5-4B-Base / Kev-4B adapter/head 全部校验到固定 revision 的文件哈希。使用 Torch2.8.0+cpu、NumPy2.2.6、safetensors0.8.0,真实 CPU 导出成功,共248个 LoRA 投影;不是合成权重的替代实验。
- 发布版 head 的 opt-in Rust oracle 通过:最大 logit 误差3.12924385e-7,最大概率误差2.98023224e-8。
- 从固定官方 PointerHead 源码及真实发布版 head 重新生成 fixture,与提交的 head.json 逐字节一致。
- 转换后 head.safetensors SHA256:
65698f2568fc1b6ebb60a1c2a24c7bb6622dcc23e1c6d9efe8d3274ad918a9a7;temperature:2.406050072164233。
硬件:不需要GPU。配方要求约24GB主机内存、25GB空闲磁盘,软件环境另计;这是配方预算,不是本次测得的最低支持配置。
范围:CPU导出不能用于批准完整原生服务;#197还要求CUDA FP32合并及完整BF16默认服务验收。本次#197在SM120的数值失败不应倒推为#170的CPU导出失败。
证据与 review 范围
以上是2026-11-02本轮独立运行的结果,不是转述作者历史 benchmark。发出前已复核本条绑定的 head/base 未变。所有 Rust 计数均来自各 PR 隔离 Cargo target 后的重建;初版共享 target 的 Rust 结果已作废,ignored 未计为通过。
沿用可信 base 的 .agents/skills/system1-omni-review/SKILL.md,源提交 5fa5179d57f9267bb0d20162004d8ce26352aa9d,文件 SHA256 3a4b876162da14eee8db56af86664576aa5755b8f3e80b3072e944018647c3bc;已读取 contributor/architecture、repository contracts、artifact hygiene 及 CI/Docs 规范。本条补充当前提交的实测证据,不代表逐条关闭旧 head 上的全部 review 事项。
下列证据包保留原始成功/失败结果及环境、命令和输入 hash,已本地归档并核验 SHA256,尚未上传为公开附件;文件名与 hash 用于标识本次记录,不是公开下载链接。仅发布 COMMENT review;不代填人工清单、不变更 Draft、不执行合并。
归档:
cpu-and-baseline-evidence.tar.gz,SHA256308e1af84bfdf16f42d2ed638bbadb6bdd50bd3019b3f0e78d204f5d77e3f620:隔离构建测试、真实CPU导出及head oracle。provenance-and-cpu-extra.tar.gz,SHA25663ae1bc39de269be481402deb66f8f582660819b528fdf4faa5b8a621430b779:独立有效的Python9项、导出manifest和输入provenance。
Purpose
Add the pinned Kev-4B CPU exporter and Rust FP32 pointer head as an independently reviewable preparation slice for #27. The complete worker is in #197 and must merge after this prerequisite. This slice makes no full-model serving, GPU parity or performance claim.
Summary
The exporter covers 96 MLP, 32 attention and 120 GDN targets, rejects incomplete or wrong target inventories, and verifies input hashes before restricted pickle loading. Output publication occurs only after all shards and metadata are complete; failed exports remove staging files. Existing output directories are refused.
The Rust head preserves learned biases, scaling and candidate order. Projection and calibration remain separate. Tests include a real-I/O synthetic two-shard export, all 248 targets, manifest/index checks and cleanup after a late shard-write failure. NumPy is explicitly pinned because serialization requires it.
Required human contributor answers
Reused from the contributor's explicit answers in #170, supplied on 2026-10-25 (translated):
Is a PR needed? The contributor explicitly requested implementation PRs where appropriate and now requested the final self-review and push. The export/head and complete-worker slices remain separately reviewable.
Bug-fix evidence: New-model preparation plus defensive complete-target validation; no observed production bug is claimed. The maintained same-count/wrong-target regression demonstrates the inventory check.
Test Plan
System1-Omni Version / Commit: head
85119d093fa3cb6ae5244b1d5c7eb2619084d9a2; merge base5fa5179d57f9267bb0d20162004d8ce26352aa9d. Targetmainwas refreshed toaec15406909ccbf95a5478d39a72f44be7fc159don 2026-11-04: its intervening changes touch none of this PR's files, and a local merge simulation found no conflicts. Source is unchanged.Scope: 20 files, 1,942 total changed lines; 879 authored-code changed lines, including tests. Reproduction and pinned model/source revisions are in the Kev recipe.
Pinned CPU qualification stack: Python 3.12, Torch 2.8.0+cpu, NumPy 2.2.6 and safetensors 0.8.0. From the repository root, with the recipe environment active:
Test Result
Independent validation by Levius-Fubuki on 2026-11-02, at this exact head:
3.12924385e-7, probability error2.98023224e-8. Original gates remain1e-4 + 1e-5*abs(reference)for logits and1e-5for probabilities, over 1/2/7/31/255 options.Focused local readiness checks on 2026-11-04: 9 Python export tests and 2 Rust head tests passed; the real-head opt-in test was ignored in this run. Workspace formatting and
cargo clippy --locked --offline -p omni-kev-native --all-targets -- -D warningspassed. Rust tests used an isolated build target. Python was 3.12.13 with Torch 2.8.0+cpu, safetensors 0.8.0 and NumPy 2.5.4; this supplementary run does not replace the pinned NumPy 2.2.6 qualification above. No source changes, full-weight export, oracle regeneration or GPU execution were performed in this readiness pass.Exact-head CI and Docs remain successful: Rust, benchmarks, Kev exporter, CUDA contract, CUDA compilation and docs build passed; deployment was skipped. CUDA compilation is not GPU inference qualification.
Demo / evidence
Before: component tests did not cover full export serialization and directory publication. After: synthetic full export and late-write cleanup run in the CPU-only
kev-exportCI job without model downloads. The real export and head comparison are independently reported in the linked review.The original October raw archive was lost. The November independent review reports newly archived CPU/provenance bundles with SHA-256 identifiers, but no public download links; the review is an accessible result summary, not a raw-artifact download. No claim is made that the old archive was recovered. Video and performance charts are N/A for this preparation-only change.
Merge Danger
Door: two-way; ordinary revert, no deployed-state migration.
Blast Radius: Kev preparation/head and its Python dependencies. Shared Qwen/CUDA runtime and serving paths are unchanged. The target inventory is specific to the pinned 32-layer 4B checkpoint. CPU export/head validation does not establish full-model numerical parity; #197 separately requires CUDA-merged export and complete service acceptance.
Self-review
The complete diff and model/export boundaries have been checked; no blocking findings were identified in the local readiness pass or the linked independent CPU-slice validation. Maintainer approval is separate from the existing COMMENT reviews.