Review of PR #483 — simplicity lens (head ab9a432, base main 27716185)
Verdict: should-fix issues only. No blocking findings.
Rules applied, cited below: AGENTS.md:188-193 ("Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement… Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost"), AGENTS.md:194-199 (tests must exercise the affected behavior; no scaffolding presented as supported), docs/design-review.md:16 ("Keep Helios as simple as possible"), charter line 12 (runtime small and model-agnostic).
Scope: every changed file was read in context; the three findings below are the residue after the author's polish commit. Things I checked and found fine are listed at the end so they are not re-reviewed.
Key findings
- Gemma 4
patch_size/pooling_kernel_sizeare unreachable wire knobs (should fix). No producer can emit anything but 16/3, yet the code carries two proto fields, two struct fields, three validation arms that cannot fire, and a third spelling of the 768 patch width.AGENTS.md:188-193names configuration switches without a concrete requirement as a rejection reason. - The new geometry test repeats 7 of 9 rows a checked-in fixture already pins by hash (should fix). Only
(100,3000)and(3000,100)are unique. - The new legacy-core test hand-builds ~70 lines of manifest (should fix) because the shared test manifest builder cannot emit a
Visiongraph; the fix is three lines intesting.rsand unlocks future vision-core tests. - Three nits: a ~130-line table where four rows suffice, a precomputed boolean threaded across a module boundary, and a test that restates a fixture case by hand.
Should fix
S1. patch_size and pooling_kernel_size cannot vary; they only duplicate the 768 patch width
Files/lines: helios/proto/runtime_core.proto:599-600; helios/src/frontend/images/mod.rs:335-336; helios/src/frontend/images/gemma4.rs:18-19,27-40,52-60,86-88; ignition/preparation/frontend.py:124-127,140-141,168-173.
What is wrong. The wire/profile surface offers two tunables that no producer can ever set to anything but one value:
ignition/preparation/frontend.py:124-127requirespatch_size: 16, pooling_kernel_size: 3in the processor config and:140-141requires the same pair invision_config;:168-173then writespatch_size=16, pooling_kernel_size=3as literals into the settings dict. There is no snapshot for which any other pair reaches Helios.- Consequently
gemma4.rs:27-33(patch_sizein1..=64) and:34-40(pooling_kernel_sizein1..=16) are unreachable arms — dead code carrying two error messages and two format strings. - The
poolingfield is additionally redundant withlimits.patches_per_feature:gemma4.rs:48-60checkspooling_kernel_size² == limits.patches_per_feature, which is the same fact stated twice, and the rest of the file usesself.poolingonly wherepatches_per_feature's square root would serve (:95,99). - The number 768 — the whole reason
VisionCapacity.patch_featuresexists — is spelled three times: computed atgemma4.rs:86-88(3 * self.patch_size * self.patch_size), as the legacy fallback 1176's sibling inhelios/src/model.rs:72-80, and as the literal3 * 16 * 16in the test atgemma4.rs:412. SUPPORTED_SOFT_TOKENS(gemma4.rs:11-13) duplicates the allowlist atfrontend.py:132(not in (70, 140, 280, 560, 1120)) with no test tying the two lists together, so they can drift silently.
Why it matters. This is exactly the "configuration switches without a concrete requirement" and "speculative compatibility" that AGENTS.md:188-193 says to reject, and it is contrary in spirit to docs/design-review.md:16's instruction to express model differences through prepared layout metadata rather than native specialisation. A reader of Gemma4ImageSettings reasonably concludes patch geometry is configurable, then has to trace into Python to discover it is not. The duplicated 768 and duplicated soft-token list are two places a future change can rot.
The smaller version. Follow the precedent already in the tree — glm.rs (not opened)'s const FACTOR: usize = 28 — and express the fixed geometry as constants:
const PATCH: usize = 16;
const POOLING: usize = 3;
const FEATURES: usize = 3 * PATCH * PATCH; // 768
Then: reserve proto tags 1-2 in Gemma4ImageSettings; drop the two struct fields, their serde keys, the two serde/protobuf field mappings, both dead validation arms, and the two Python literals at frontend.py:169-170; keep the single pooling_area² == limits.patches_per_feature check as the remaining cross-profile invariant (it is a genuine prepared-contract check, not a duplicate of a knob); keep one soft-token allowlist — prefer the Python one, since preparation is where the checkpoint is actually rejected, and have Rust consume it through the prepared contract instead of a local copy.
Anticipated counter and why it does not hold. The author may point to PatchMergeImageSettings.patch_size, which patch_merge.rs:92 likewise pins to 14. That is the same defect in the neighbouring profile — precedent, not a requirement — and unlike PatchMerge these tags have never shipped, so no compatibility argument constrains them.
S2. geometry_matches_the_hugging_face_processor repeats 7 of its 9 rows
File/lines: helios/src/frontend/images/gemma4.rs:383-402.
What is wrong. The nine-row table at :386-396 asserts grid/tokens for (1,1), (672,672), (1008,672), (91,37), (1920,1080), (10,3000), (3000,10), (100,3000), (3000,100). The first seven are already pinned — grid, tokens, patches and resize SHA-256 — by canonical_processor_pixels_positions_and_resize (gemma4.rs:314-381) from tests/frontend/gemma4_images.json:126-256. Only (100,3000) → [1,273,9] and (3000,100) → [1,9,273] (:392-393) add coverage.
Why it matters. Two assertions on the same values with two different failure messages is the kind of parallel path that drifts: if the resize geometry changes, one test fails and the other may not, and a reader cannot tell which is authoritative. It is also per AGENTS.md:194-199 redundant validation rather than focused validation.
The smaller version. Keep the two tall/wide rows plus the tokens * 9 == patches invariant (:400), which is a real property the fixture does not assert, and delete the other seven rows (~10 lines). Alternatively delete the test entirely and add the invariant to the fixture loop at :378.
S3. The new legacy-core test hand-builds a manifest the shared builder could emit
Files/lines: helios/src/model/tests.rs:1277-1452, specifically build_manifest at :1343-1411; root cause helios/src/model/testing.rs:344-355.
What is wrong. testing::manifest cannot produce the graph this test needs: testing.rs:354 sends GraphOperation::Vision to _ => unreachable!(), so the test reimplements manifest construction locally. That local copy duplicates shared arithmetic — tests.rs:1355-1409 repeats the strides/address/offset computation of testing.rs:307-337 and the binding assembly of :368-377 — and it exists only because the shared builder also fixes every ImageTensor binding to width 1 (testing.rs:259-275) and to Dtype::Int64 unless listed (:276-293). There is also a redundant reconstruction at tests.rs:1450 (base_manifest = build_manifest(1176) immediately before use; base_manifest holds exactly that value from :1414).
Why it matters. ~70 lines of hand-maintained manifest arithmetic is a second source of truth for graph layout; when ExecutionManifest shape changes, this test breaks for reasons unrelated to the behaviour it checks (a legacy core without patch_features loads and stages 1176-wide pixels).
The smaller version. Map GraphOperation::Vision => GraphKind::Vision in testing::manifest (testing.rs:344-355) and let the test override the one vision_pixel_values buffer extent to (16, pixel_width); the shared builder then supplies strides, bindings and input_frame_bytes. That removes the local build_manifest closure entirely, removes the redundant :1450 rebuild, and makes future vision-core tests possible without another copy. This is squarely inside AGENTS.md:194-199's "tests must exercise the affected behavior" — the plumbing is not the behaviour.
Nits
helios/src/frontend/images/packing.rs:685-814(~130 lines).processor_patch_features_match_tensor_layout_for_every_profileassertsprocessor.patch_features() == tensor_layout(..)across ten rows, many of them carryingpatch_features: 0. Four rows cover every distinct outcome (Gemma 4 9/768, PatchMerge 4→1176, PaddedGrid 1200, plus one of 588 or 1536); the rest is repetition, ~100 lines removable.helios/src/model/prompt.rs:52-65. TheImageLayoutKind::Bracketedarm computes…image_tokens.span…is_some()as a barebooland passes it positionally;layouts/bracketed.rs:23,58consumes it, and the test call sites passfalseatbracketed.rs:175,199. PassingOption<&ImageSpan>puts the derivation next to its only use and removes an unlabelled boolean from a five-argument signature. (The span emission itself inbracketed.rs:51-88is the right design — one closure, one loop, matchingdeepseek— and replacing it would be worse.)helios/src/frontend/images/gemma4.rs:404-420.pixels_interleave_rgb_and_positions_are_xyrestates the 91×37 fixture case by hand (grid_thw [1,30,78],patches * 3 * 16 * 16at:411-412), which the fixture already pins by SHA-256. Keep only the assertion the hash cannot express — the(x, y)ordering check at:415-418(position_ids[grid_w] == [0,1]), which is genuinely worth keeping and should be noted as such if the rest goes.
Checked in context and found fine (do not re-raise)
Envelopeextraction (patch_merge.rs:11-136) is real de-duplication shared by Gemma 4 and the merge profiles, not a new abstraction layer.- Layout-owned atomic spans (
layouts/bracketed.rs:51-88, deletion of themodel/prompt.rsback-fill block) is the smaller design: one closure, one loop, and the prompt bounds are validated on both ends at:59-61. describe.rs:466-467(not opened) omitspatch_featureswhen 0, so legacy describe JSON is unchanged.server/config.rs:443-489validate_loaded_image_processoris one function with oneif Bracketed {…} else if patch_features != 0 {…}— one message per layout, no reachable overlap. The earlier duplicate-check finding is resolved.model.rs:89patch_features.is_multiple_of(3)is a single clause.packing.rs:39-46square_merge_side+bracketed_patch_featuresis the small version of the deleted lookup table.packing.rsgrid guard (h % merge_side != 0 || w % merge_side != 0) is not implied bytokens * patches_per_feature == patches—h=2, w=9, ppf=9satisfies the identity but is not a 3×3 tiling. My earlier nit was wrong; withdrawn.- Resolved this round: the superseded
native_pixels_and_positions_match_the_checkpoint_processortest is gone (gemma4.rsis now 505 lines); the ignored envelope test's temp Jinja file isDrop-guarded (gemma4.rs:443-458,drop(template)at:469) and the template is genuinely required (helios/src/frontend/mod.rs:1036-1043rejectsPromptEncoder::Jinjawithout one); the fixture'sprocessor/modelblocks are now consumed bytests/preparation/test_frontend_gemma4.py:187-225, including the three token ids at:193-195; the legacyBracketedcore-load test the earlier round asked for exists atmodel/tests.rs:1277-1452and does what was asked (stripspatch_features, accepts 1176, rejects 768 and a non-squarepatches_per_feature). runtime_core_pb2.py(not opened) regeneration is descriptor-only; no hand-written logic to simplify.
Open questions and what I could not verify
- Is per-model geometry configuration a stated roadmap goal? If Gemma 4 variants with different patch geometry are expected, S1 is wrong and the fields should stay — but then
frontend.py:124-127,140-141would need to accept the alternatives, and today it rejects all of them. What would settle it: a maintainer statement on whetherGemma4ImageSettings.patch_sizeis intended to be variable.docs/TODO.txt(changed by this PR) names E2B/E4B/26B-A4B serving qualification and a partial-span prefix-cache audit, not patch-geometry variation. - Whether the two soft-token allowlists can drift undetected. No test ties
SUPPORTED_SOFT_TOKENS(gemma4.rs:13) tofrontend.py:132; only a fixture generated at each of the five budgets would. The checked-intests/frontend/gemma4_images.jsoncoversmax_soft_tokens280 and 1120 only (:126-256). - Test counts and parity claims are the author's. This was a read-only review: I ran no
cargo testand nopytest, so the stated 47/55/28/3 passing counts and the bit-exact SHA-256 parity against HF'sGemma4ImageProcessorare unverified here. The live-checkpoint test (gemma4.rs:422-503,#[ignore], requiresFLARE_GEMMA4_TEST_SNAPSHOT) is outside CI by construction, per the author's own limitations section. PatchMergeImageSettings.patch_sizeatpatch_merge.rs:92is the same dead-knob pattern in a neighbouring profile. Out of scope for this PR, but worth a follow-up issue if S1 is accepted; I did not file one.