Conventions report · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/32ae4487-dbf6-4b75-9d42-6f9cd9fbc680.md

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

What governs the judgment

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)

Open questions / not established

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.