PR #483 — Conventions and duplication lens
Head ab9a432 (branch rickybrent:core/gemma4-image-frontend), base main 27716185, 38 files, +2490/−251.
Verdict: clean in this lens. No blocking or should-fix findings; 8 nits, each with a concrete fix.
Key findings
- No blocking or should-fix convention or duplication violations remain at this head. The findings I raised in earlier passes are closed in the code (not only in the reply): per-condition load errors, the
patch_features()authority, thebracketed_patch_features()legacy-default rule on the contract type, the single actionableBracketedwidth error in bootstrap, the Qwen-scoped README paragraph, the consumed fixturemodelblock, and an unconditional legacy-core load test. - Eight nits remain, all low-risk: the per-profile patch width is still authored twice over two different enums; the soft-token allowlist exists in two languages with nothing tying them; the shared
Envelopetype is homed in a single profile module;max_patchesis computed twice;Gemma4ImageSettingsvalidation accepts ranges where neighbouring profiles pin their one legal value and where const-based modules would suggest a const; the settings literal is repeated in six tests despite an existing shared-fixture module; and the new fixture generator copies two helpers verbatim from the GLM generator (which every generator in that directory does).
What governs the judgment
AGENTS.md:188-199: rejects unsupported abstractions and churn; refactoring must support the requested behaviour.docs/design-review.md:31-52(principle 3): canonical semantics and shared mechanisms must be preserved; "Native transport, scheduling, cache ownership, input packing, frontend processing, and request handling stay shared; use prepared metadata and frontend assets to express model-dependent behavior"; "Reject per-model boolean policy flags … Enums, callbacks, schema names, and metadata fields cannot serve as alternative model allowlists. Review each member and its consumers for a concrete meaning independent of model identity."- Charter line 12: "Keep the runtime small and model-agnostic."
- Against those rules the new metadata is typed prepared data with model-independent consumers (patch width, merge stride, envelope bounds) rather than branches on model identity, so the profile does not violate the shared-mechanism rule. The nits below are where the same value is nevertheless authored more than once, or where a shared helper already exists.
Nits (all with fixes)
1. Per-profile patch width still authored twice, over different enums
helios/src/frontend/images/packing.rs:31-93 maps ImageLayoutKind → float width inside tensor_layout (Qwen|Mimo → 1536, Radio → 768, Glm → 1176, ClassToken → 1200, Deepseek*|Moonvit|Step → 588, Bracketed → vision.bracketed_patch_features()), while helios/src/frontend/images/mod.rs:459-471 (ImageProcessor::patch_features) maps Profile → the same numbers (PatchMerge/Gemma4 delegate to their processors, PaddedGrid uses padded_grid::FEATURES). The PR's stated goal was to unify widths behind ImageProcessor::patch_features(); the layout side keeps its own copy. The two are linked only by the test processor_patch_features_match_tensor_layout_for_every_profile (packing.rs:685-814), which is exactly the kind of runtime-only coupling a compiler can own.
Fix: have tensor_layout take the processor's width (or the VisionCapabilities plus a patch_features argument already supplied at the call site, helios/src/model/packing.rs Inputs::new → tensor_layout(…, &config.contract.vision, …)), so Profile remains the single authoring point.
2. Soft-token allowlist duplicated across languages, nothing ties them
helios/src/frontend/images/gemma4.rs:13 const SUPPORTED_SOFT_TOKENS: [usize; 5] = [70, 140, 280, 560, 1120]; and ignition/preparation/frontend.py:132 max_soft_tokens not in (70, 140, 280, 560, 1120). The Rust comment at gemma4.rs:11-12 documents the duplication as deliberate ("wire-level defense-in-depth alongside Ignition's checkpoint gate"), which is a legitimate pattern, but no test asserts the two sets agree.
Fix: either accept with a comment cross-referencing frontend.py:132/gemma4.rs:13 in both directions, or carry the allowed set in Gemma4ImageSettings so Helios validates prepared metadata instead of a hardcoded literal.
3. Envelope documented as shared but homed in patch_merge
helios/src/frontend/images/patch_merge.rs:10-17 declares pub(super) struct Envelope with the doc "shared by PatchMerge and Gemma4 image preparation profiles", and helios/src/frontend/images/gemma4.rs:8 imports it via use super::patch_merge::Envelope;. Extracting it was genuine de-duplication (Gemma 4 and MiniMax both need start/feature/end expansion), but a profile module is the wrong home for a shared type — the next image profile will import from patch_merge too.
Fix: move Envelope to helios/src/frontend/images/envelope.rs (not opened) (or beside ImageGeometry in mod.rs).
4. max_patches computed twice in gemma4.rs
gemma4.rs:61-64 computes settings.max_soft_tokens.checked_mul(pooling_area) for the load-time bound check against limits.max_patches_per_image, and gemma4.rs:98-100 (fn max_patches) recomputes self.max_soft_tokens * self.pooling * self.pooling for geometry (gemma4.rs:104). The checked and unchecked spellings of the same product can drift, and the load-time check is the only thing keeping the unchecked one safe.
Fix: have load call max_patches() on the constructed value (or store the computed budget) so there is one expression.
5. Validation style departs from its closest precedents
The two neighbouring fixed-geometry profiles pin their wire field to its single legal value in load: helios/src/frontend/images/patch_merge.rs:92 (settings.patch_size != 14) and helios/src/frontend/images/qwen.rs:22 (settings.position_side != 48). gemma4.rs:27-40 instead accepts ranges (1..=64 for patch_size, 1..=16 for pooling_kernel_size), while its own prepare-side gate already fixes those values (ignition/preparation/frontend.py:124-127,140-141 require patch_size: 16, pooling_kernel_size: 3) and the emitted settings are literals (frontend.py:168-173).
Fix: keep the fields (the PatchMergeImageSettings.patch_size precedent supports them) but pin 16 and 3, or cite the literal authors in a comment; ranges that no producer can emit are speculative tolerance.
6. Module-const precedent unused for derived geometry
Fixed-geometry image modules declare named consts: helios/src/frontend/images/glm.rs:13 (FACTOR = 28), padded_grid.rs:31-34 (PATCH = 20, MERGE, CELL, pub(super) FEATURES = PATCH*PATCH*3), deepseek4.rs:10-11 (not opened). gemma4.rs derives the same class of value inline at :86-88 (3 * self.patch_size * self.patch_size) and its prose spells 48 px and 768 literally (helios/README.md:714-716) with no named const in the module.
Fix: a FEATURES-style const in gemma4.rs (or leave to the ruling on nit 5, since a pinned patch_size makes the const trivial).
7. Gemma4ImageSettings literal repeated in six tests
Six test sites build the same settings by hand: helios/src/frontend/images/gemma4.rs:228,252,295, packing.rs:782, helios/src/model/prompt.rs:1181, helios/src/server/config.rs:972, helios/src/frontend/images/conditioned.rs:354 (+ the wire form at runtime_core/protobuf.rs:819). helios/src/frontend/mod.rs:104 (not opened) already provides pub mod test_support for shared fixtures and is used by these very tests (gemma4.rs:462, layouts/bracketed.rs:143, packing.rs:579).
Fix: one test_support::gemma4_settings() helper next to the existing fixture helpers.
8. Fixture generator copies helpers verbatim
tests/frontend/generate_gemma4_image_fixtures.py:17-24 (pattern, digest) is byte-identical to tests/frontend/generate_glm_image_fixtures.py:18-25 apart from the explanatory comment, and the same pair recurs in the other generators. Every generator in tests/frontend/ is deliberately standalone, so this follows convention rather than breaking it.
Fix: accept as-is, or add a shared tests/frontend/_fixture_support.py (not opened) if a third copy appears.
Precedents that hold (checked, no finding)
- Proto: tag 11
ImageSettings.profile+Gemma4ImageSettings(fields 1-6) mirrorPatchMergeImageSettings;VisionCapacity.patch_features = 6is additive;ImagePreparationKind::Gemma4 = 11is appended bycontract_enum!without renumbering (helios/src/model/contract.rs:68). #[serde(default)]on the newpatch_featuresfield is wired in the same builder chain as the other additive fields (helios/build.rs:53-56), so a pre-change contract deserializes with0(helios/src/model.rs:44-65), andvalidate()accepts0, rejecting only non-multiples of 3 (model.rs:82-99).describe.rs:451-452adds theProfile::Gemma4arm beside thePatchMergearm, and:466-468omitspatch_featureswhen zero so legacy describe JSON is byte-identical;protobuf.rs:168adds the matching JSON arm.ImageSettings::Gemma4/Profile::Gemma4arms (mod.rs:274-289, 358-…, 459-478) mirror thePaddedGridprecedent rather than introducing a new pattern;max_image_envelope_tokens()(mod.rs:473-478) is anOptioncapability, not a per-model boolean flag, which is whatdocs/design-review.md:49-52requires.layout-owned spans: movingdata.spansemission intolayouts/bracketed.rs::prepare_input(bracketed.rs:18-112,flush_spanat:57-65) copies thelayouts/deepseek.rsprecedent exactly, and deleting the generic fallback inmodel/prompt.rsremoves a duplicate mechanism rather than adding one.- Ignition: the
gemma4branch (ignition/preparation/frontend.py:114-173) mirrors theglmbranch (:174-189), including_expected(...)for required and filtered-optional fields, andcontract.pydefaultspatch_featuresin the same dict where the other vision defaults live. - The legacy path is preserved with real coverage rather than asserted:
legacy_bracketed_core_omitting_patch_features_loads_and_stages_1176_wide_pixels(helios/src/model/tests.rs:1277-1452) removespatch_featuresfrom a serialized contract, asserts0decodes, loads throughInputs::new, stages16*1176*4bytes, and requires rejection for a 768-wide buffer and a non-squarepatches_per_feature. client/servercall sites changed only by struct fills:flare-cli/tests/unverified_payload.rs(not opened),helios/tests/deepseek_requests.rs(not opened),helios/src/scheduler/*,helios/src/server/{models,protocol/decode,request,runtime}.rs— all mechanicalpatch_features: 0.
Open questions / not established
- Whether a maintainer approved landing the profile ahead of its companion Gemma 4 vision recipe (the PR itself says the recipe lands in
local-inference-lab/hyperflare-recipesand is tracked indocs/TODO.txt) — scope, another lens. - Whether any published
Bracketedcore declares a non-squarepatches_per_feature, which the newsquare_merge_sideguard (packing.rs:16-22) now rejects at load. Manifests live outside this repo; only a scan of published cores settles it. - This was a read-only pass: no
cargo testorpytestrun, so behavioural claims rest on code and callers. Numerical parity against Hugging Face, load cost, serving timing/memory and partial-span prefix-cache behaviour are outside this lens. - The pb2 header concern from an earlier pass is withdrawn:
ignition/preparation/runtime_core_pb2.py:5says7.36.1onmainas well, so regenerating preserves existing state.
Coverage
Every changed file was read in context (not only through the diff) at pr/483: helios/proto/runtime_core.proto (not opened); helios/build.rs; helios/src/model.rs; helios/src/model/{contract.rs,prompt.rs,packing.rs,tests.rs,testing.rs}; helios/src/frontend/images/{gemma4.rs (whole), mod.rs, packing.rs, patch_merge.rs, patches.rs, glm.rs, qwen.rs, conditioned.rs, padded_grid.rs, layouts/bracketed.rs (whole), layouts/deepseek.rs}; helios/src/runtime_core/{describe.rs,protobuf.rs}; helios/src/server/config.rs; helios/src/execution/tests.rs; helios/src/server/runtime/phase_tests.rs; ignition/preparation/{frontend.py,contract.py,runtime_core_pb2.py}; tests/frontend/{generate_gemma4_image_fixtures.py,generate_glm_image_fixtures.py,gemma4_images.json}; tests/preparation/test_frontend_gemma4.py; helios/README.md:700-812; helios/model-contract.md (not opened); docs/{runtime-core-design.md:175-250,TODO.txt}; helios/tests/support/contracts/gemma4_frontend.json; repo rules AGENTS.md:170-210,340-365 and docs/design-review.md:25-55. Files seen only via diff are the mechanical patch_features: 0 fills listed above and the descriptor blob of runtime_core_pb2.py, which I verified at the header, the runtime-version block, and the _globals offsets that shift for the new message.