From 4f777ec0f55bedb3693c3b1b3e096df53ed6532b Mon Sep 17 00:00:00 2001 From: Ricky Brent Date: Sun, 22 Nov 2026 21:57:22 -0800 Subject: [PATCH] Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans Why: Gemma 4 multimodal checkpoints preprocess images into aspect-preserving 16x16 interleaved RGB patches (768 float32 elements per patch), 2D (x, y) patch coordinates, 3x3 spatial pooling (patches_per_feature = 9, up to 1,120 soft tokens per image), and an atomic envelope (start_token, repeated image_token features, end_token). Before this change, Helios had no Gemma 4 image preparation profile, ImageLayoutKind::Bracketed hardcoded 2x2 merge and 1,176 floats per patch, and Bracketed layouts did not emit atomic image spans. Without these changes, Gemma 4 cores cannot prepare or load native image inputs, Bracketed vision uploads cannot pack 3x3 / 768-float patches, and span-declaring Bracketed prompts fail per request at prompt validation instead of failing closed at server bootstrap. To keep shared packing independent of model identity without breaking MiniMax (the existing Bracketed user whose PatchMerge profile uses 2x temporal duplication: 3 * 2 * 14^2 = 1,176 floats per patch), prepared metadata declares per-patch float width via VisionCapacity.patch_features instead of hardcoding a lookup table or assuming 3 * patch_size^2. What changed: - Wire & contract metadata (helios/proto/runtime_core.proto, helios/build.rs, ignition/preparation/{runtime_core_pb2.py,contract.py}, helios/src/model.rs, helios/src/model/contract.rs, helios/src/runtime_core/{describe,protobuf}.rs, docs/runtime-core-design.md, helios/README.md, helios/model-contract.md, docs/TODO.txt): - Before: VisionCapacity carried no patch-width field, ImageSettings and ImagePreparationKind ended at tag 10 (PaddedGrid), and model_contract() omitted patch_features from its default vision map. - After: Added additive ImageSettings.profile tag 11 (Gemma4ImageSettings), ImagePreparationKind::Gemma4 (tag 11), and VisionCapacity.patch_features (tag 6, serde default 0) with VisionCapabilities::bracketed_patch_features() (where 0 inherits legacy width 1176) and non-zero validation requiring a positive multiple of 3. Defaulted vision["patch_features"] = 0 in ignition/preparation/contract.py, regenerated runtime_core_pb2.py with protoc 36.1 (Protobuf Python Version 7.36.1, descriptor-only diff), added a protobuf round-trip test for Gemma4ImageSettings, and documented the Gemma 4 profile, fixture provenance, patch_features field, and Bracketed spans. Updated docs/TODO.txt to reflect 31B NVFP4/BF16 serving verified on the combined Gemma 4 recipe stack with 26B-A4B, E2B/E4B vision parameterization, and partial-span prefix-cache audit still open. - Native image preparation, packing, and load validation (helios/src/frontend/images/{gemma4,mod,conditioned,packing,patch_merge}.rs, helios/src/model/packing.rs, helios/src/server/config.rs): - Before: No Gemma 4 preprocessor existed; Bracketed hardcoded 2x2 stride and width 1176 from a lookup branch; server bootstrap did not check patch width or maximum image envelope against prefill_chunk_size / span.max_tokens. - After: Added helios/src/frontend/images/gemma4.rs (area-bounded uint8 antialiased bicubic resize matching PyTorch/torchvision, 1/255 scaling, interleaved (y, x, channel) patches, (x, y) coordinates, shared patch_merge::Envelope, ProcessedImages::reserve_outputs for checked-mul overflow checks and single reserve_exact reservation matching glm.rs, and per-condition load errors). Updated Bracketed packing to derive merge stride from any positive-square patches_per_feature and read pixel width from VisionCapabilities::bracketed_patch_features(). Unified per-profile patch width behind ImageProcessor::patch_features() (via PatchProcessor::pixel_width() for Qwen/PatchMerge and conditioned.rs), and added server bootstrap checks enforcing patch width, patches_per_feature, per-image patch capacity, and max envelope <= prefill_chunk_size and span.max_tokens. - Layout-owned atomic spans (helios/src/frontend/images/layouts/bracketed.rs, helios/src/model/prompt.rs): - Before: Bracketed emitted no atomic spans and model/prompt.rs carried no Bracketed span path. - After: layouts::bracketed::prepare_input emits atomic spans when frontend.image_tokens.span is configured and validates prompt bounds on both ends. - Preparation wire validation & tests (ignition/preparation/frontend.py, tests/frontend/{generate_gemma4_image_fixtures.py,gemma4_images.json}, tests/preparation/{test_frontend_spec.py,test_frontend_gemma4.py}, helios/src/model/tests.rs): - Before: Core ignition.preparation.frontend accepted only the 8 prior profiles. - After: Added "gemma4" to IMAGE_PROFILES and _validate_image_payload in ignition/preparation/frontend.py, validating wire bounds (patch_size in 1..=64, pooling_kernel_size in 1..=16, max_soft_tokens in {70,140,280,560,1120}, and 3 distinct nonempty envelope tokens) for recipe-owned ImageProcessorSpec contracts. Added checked-in HF fixture generator and 8-case SHA-256 fixture JSON (max_soft_tokens 280 and 1120), unconditional Rust Envelope::expand, Bracketed span, legacy Bracketed Inputs::new core-load (1176-wide), cross-profile width, and bootstrap validation tests, an #[ignore] checkpoint envelope test, and recipe-free Python tests in test_frontend_gemma4.py covering _validate_image_payload, default_preprocessor, checked-in fixture verification, and pb2 round-trip. Benefit & compatibility: Helios natively decodes, resizes, rescales and packs, and validates Gemma 4 images with bit-exact SHA-256 parity against Hugging Face Gemma4ImageProcessor, while catching patch-width and chunk-bound mismatches at bootstrap. MiniMax and all non-Bracketed upstream cores remain loadable unchanged (missing patch_features decodes as 0 -> legacy 1176 for Bracketed; envelope bounds apply only to Gemma 4). Fail-closed narrowings: Bracketed now requires a positive-square patches_per_feature, and any legacy Gemma 4 core prepared before this change (with patch_features == 0) is rejected at load with an actionable re-export error (`bracketed image layout patch width (1176) differs from image processor (768); re-export the core with vision.patch_features`). Evidence & limitations (verified on origin/main 3d1614cc): - Release Rust test suites (`--locked --release`): - eos: 12 passed, 0 failed - selene (--features test-support): 553 passed, 0 failed - selene-manager (--features test-support): 425 passed, 0 failed, 1 ignored - helios (--features runtime-core,server with FLARE_TEST_TEMPLATE_DIR): 1,913 passed, 0 failed, 85 ignored (1,851 unit + 62 across integration targets) - helios (--features runtime-core,server,test-tools --lib): frontend::images 48 passed, 0 failed, 1 ignored; live ignored checkpoint envelope test on nvidia/Gemma-4-31B-IT-NVFP4@4135a98a (`-- --ignored --exact frontend::images::gemma4::tests::checkpoint_tokens_expand_the_image_envelope`): 1 passed, 0 failed; model:: 58 passed; runtime_core::protobuf 29 passed; server::config 3 passed - flare-cli: 246 passed, 0 failed, 3 ignored (including `cargo test --locked --release --manifest-path flare-cli/Cargo.toml --test unverified_payload`: 7 passed, 0 failed) - flare: 255 passed, 0 failed, 4 ignored - heliopause: 229 passed, 0 failed, 6 ignored - Rebuilt release `flare` binary (`flare-cli/target/release/flare`) and `flare-heliopause`, synced `.venv` (`flashinfer-python` `5a8ceed8`), and ran CI CPU Python suite (`CUDA_VISIBLE_DEVICES="" .venv/bin/python -m pytest tests/ -q`): 2,504 passed, 459 skipped, 0 failed (including 21 passed, 0 skipped across `tests/preparation/{test_core_boundary,test_source_identity, test_frontend_spec,test_frontend_gemma4}.py`). - Combined-stack E2E multimodal serving (evaluated on the companion 5-PR Gemma 4 recipe stack in `local-inference-lab/hyperflare-recipes` paired with this PR, RTX PRO 6000 Blackwell SM120 GPU 0, TP1, `--max-concurrency 4 --image-concurrency 2`, MTP enabled): - `nvidia/Gemma-4-31B-IT-NVFP4` (FP8 KV): 11/11 checks passed (short math `'391'`, 5,703-tok needle `'NEEDLE-7492-FALCON'`, 1/2/4-image, 2,564-tok wraparound+image, `810/810` Turn-1 multimodal prefix-cache replay, 2-concurrent images, 122.56 tok/s decode / 122.31 tok/s total, TTFT 0.0041s on a 37-tok prefix-cached prompt). - `google/gemma-4-31B-it` (BF16 KV): 11/11 checks passed (`810/810` Turn-1 multimodal replay, 2-concurrent images, 70.73 tok/s decode / 70.64 tok/s total, TTFT 0.0045s on cached prompt). - Backward-compat & fail-closed load checks with release `flare`: legacy pre-#483 Gemma 4 core `gb202-tp1-202611240119` fails load with `bracketed image layout patch width (1176) differs from image processor (768); re-export the core with vision.patch_features`; existing `GLM-5.3-Flash` core `gb202-tp2-202611090656` passes `flare inspect` (`signatures verified`). - Limitations: End-to-end multimodal serving requires the companion Gemma 4 recipe stack (`local-inference-lab/hyperflare-recipes`). On that combined stack, 31B NVFP4 (FP8 KV) and 31B BF16 (BF16 KV) serving are verified on SM120 TP1, whereas TP2/TP4, 26B-A4B vision serving, E2B/E4B (16-layer 768-dim clipped-linear tower not yet parameterized in the recipe), SM103/SM121 hardware, and partial-span prefix-cache hits remain unverified (tracked in `docs/TODO.txt`). Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b Signed-off-by: Ricky Brent --- docs/TODO.txt | 10 + docs/runtime-core-design.md | 19 +- flare-cli/tests/unverified_payload.rs | 1 + helios/README.md | 42 +- helios/build.rs | 4 + helios/model-contract.md | 2 +- helios/proto/runtime_core.proto | 12 + helios/src/frontend/images/conditioned.rs | 26 +- helios/src/frontend/images/gemma4.rs | 497 ++++++++++++++++++ .../src/frontend/images/layouts/bracketed.rs | 24 +- helios/src/frontend/images/mod.rs | 42 ++ helios/src/frontend/images/packing.rs | 281 +++++++++- helios/src/frontend/images/patch_merge.rs | 188 +++++-- helios/src/model.rs | 15 + helios/src/model/contract.rs | 2 +- helios/src/model/packing.rs | 1 + helios/src/model/prompt.rs | 127 ++++- helios/src/model/tests.rs | 178 +++++++ helios/src/runtime_core/describe.rs | 12 +- helios/src/runtime_core/protobuf.rs | 60 +++ helios/src/scheduler/boundary_tests.rs | 1 + helios/src/scheduler/cache_memory.rs | 1 + helios/src/scheduler/tests.rs | 4 + helios/src/scheduler/vision_window_tests.rs | 1 + helios/src/server/config.rs | 144 ++++- helios/src/server/models.rs | 2 + helios/src/server/protocol/decode.rs | 1 + helios/src/server/request.rs | 3 +- helios/src/server/request/tml_tests.rs | 1 + helios/src/server/runtime.rs | 2 + helios/src/server/runtime/phase_tests.rs | 7 + helios/tests/deepseek_requests.rs | 1 + ignition/preparation/contract.py | 8 +- ignition/preparation/frontend.py | 35 ++ ignition/preparation/runtime_core_pb2.py | 346 ++++++------ tests/frontend/gemma4_images.json | 256 +++++++++ .../generate_gemma4_image_fixtures.py | 94 ++++ tests/preparation/test_frontend_gemma4.py | 152 ++++++ tests/preparation/test_frontend_spec.py | 2 +- 39 files changed, 2349 insertions(+), 255 deletions(-) create mode 100644 helios/src/frontend/images/gemma4.rs create mode 100644 tests/frontend/gemma4_images.json create mode 100644 tests/frontend/generate_gemma4_image_fixtures.py create mode 100644 tests/preparation/test_frontend_gemma4.py diff --git a/docs/TODO.txt b/docs/TODO.txt index b5e1413f5..a19bf457a 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -377,3 +377,13 @@ [ ] Guard or stride the 65,535 * 1024 (~64 MiB/uint8 row) gridDim.y ceiling in ignition/components/state.py row kernels. + +[ ] Qualify remaining Gemma 4 vision configurations (`vision.patch_features = 768` + alongside `ImageLayoutKind::Bracketed` + `ImagePreparationKind::Gemma4`): + 31B NVFP4 (FP8 KV) and 31B BF16 (BF16 KV) multimodal export and serving are + verified on the combined Gemma 4 recipe stack; 26B-A4B multimodal serving, + E2B/E4B (requiring recipe vision-tower parameterization for their 16-layer + 768-dim `standardize=False` / `use_clipped_linears=True` tower; Gemma 4 12B + uses `gemma4_unified` and is outside this profile), and partial-span + prefix-cache audit (when a cached prefix ends inside an atomic image + envelope) remain open. diff --git a/docs/runtime-core-design.md b/docs/runtime-core-design.md index 97145ddb2..29400ce64 100644 --- a/docs/runtime-core-design.md +++ b/docs/runtime-core-design.md @@ -181,10 +181,17 @@ Two prepared-contract fields fail validation when absent or out of range. `vision` (Protobuf message `VisionCapacity`, Rust type `VisionCapabilities`) must decode to a well-formed value: a text-only core encodes the explicit all-zero value (`feature_slots`, -`features_per_request`, `max_images`, and `patches_per_feature` of 0 -with empty `patch_capacities`), and an absent or null `vision` fails -the contract decode (a null submessage raises `invalid type: null, -expected struct VisionCapabilities`). Every graph contract also carries +`features_per_request`, `max_images`, `patches_per_feature`, and +`patch_features` of 0 with empty `patch_capacities`), and an absent or null +`vision` fails the contract decode (a null submessage raises +`invalid type: null, expected struct VisionCapabilities`). For vision cores +using `ImageLayoutKind::Bracketed`, `patch_features` declares the per-patch +float width of `vision_pixel_values` (for example `768` for 16×16 RGB Gemma 4 +patches); `0` defaults to the legacy temporal-merge width (`1176`) for existing +cores. At server bootstrap, Helios also verifies that the loaded image +processor's patch width, `patches_per_feature`, per-image patch budget, and +maximum bracketed envelope span agree with the prepared contract and +`prefill_chunk_size`. Every graph contract also carries `embedding_tables`, whose entries index the core's embedding-table catalog and are validated against the catalog size at core validation: a core that ships no embedding-table resources must @@ -227,7 +234,9 @@ remains request-controlled. chat template, and optional image settings. Qwen image settings contain resize area limits, learned-position geometry, and image/video token IDs. MiMo image settings contain resize limits and channel normalization. DeepSeek's image profile -has fixed geometry validated by Ignition. Preparation reads and validates structural +has fixed geometry validated by Ignition. Gemma 4 image settings contain patch +and pooling geometry, the soft-token budget, and the validated envelope token +strings (`image_token`, `start_token`, `end_token`). Preparation reads and validates structural checkpoint config files, then exports only these consumed fields. The only frontend payload assets are `tokenizer.json` and the Jinja chat template; raw generation, tokenizer, processor, and model configuration files are not included. diff --git a/flare-cli/tests/unverified_payload.rs b/flare-cli/tests/unverified_payload.rs index 9b4646b24..9edaceceb 100644 --- a/flare-cli/tests/unverified_payload.rs +++ b/flare-cli/tests/unverified_payload.rs @@ -87,6 +87,7 @@ fn publish_configured( max_images: 4, patches_per_feature: 3, patch_capacities: vec![64, 128], + patch_features: 0, }), frontend: Some(runtime_wire::FrontendContract { tools: Some(runtime_wire::ToolParser { diff --git a/helios/README.md b/helios/README.md index d5fe1a76a..f45cc4018 100644 --- a/helios/README.md +++ b/helios/README.md @@ -742,19 +742,28 @@ The `images` feature adds `frontend::images::ImageProcessor` and PNG, JPEG, static WebP, and non-animated GIF decoding; it also enables `frontend`. Typed core metadata selects the preparation profile and token layout independently. Profiles cover Qwen, MiMo, patch-merge, DeepSeek, DeepSeek row-major, Moonvit, Step, RADIO, -and GLM inputs. +GLM, padded-grid, and Gemma 4 inputs. The Qwen processor uses an RGB8, bicubic-antialias profile with 16×16 patches, temporal duplication by two, spatial merge by two, a 48×48 learned position table, and fused normalization `(pixel - 127.5) / 127.5`. - -`process` produces packed `pixel_values[N,1536]` float32, image grids `[1,H,W]`, +The Gemma 4 processor uses area-bounded RGB8 bicubic-antialias resize to +multiples of `patch_size * pooling_kernel_size` (48 px for 16×16 patches and +3×3 pooling), packs interleaved `(y, x, channel)` float32 patch vectors of width +`3 * patch_size²` (768) scaled by `1/255`, emits `[x, y]` patch coordinates, and +reuses the bracketed start/feature/end token envelope; when the prepared +contract declares `image_tokens.span`, the bracketed layout emits atomic spans +covering each envelope. + +For Qwen, `process` produces packed `pixel_values[N,1536]` float32, image grids `[1,H,W]`, vision positions `[N,2]` int64, interpolation indices `[N,4]` int64 and weights -`[N,4]` float32, and per-image cumulative patch offsets int32. Patch features -are ordered by channel, temporal copy, pixel row, and pixel column; patches -are ordered by 2×2 spatial merge blocks. `expand_prompt` consumes the rendered -chat token IDs, expands only control-token image placeholders, and returns -modality IDs and four unpadded position rows `[text,T,H,W]` plus the mRoPE delta. -The model scheduler can transpose the last three rows into `[tokens,3]`. +`[N,4]` float32, and per-image cumulative patch offsets int32 (other profiles +report their own per-patch width via `ImageProcessor::patch_features()`). Qwen +patch features are ordered by channel, temporal copy, pixel row, and pixel +column; patches are ordered by 2×2 spatial merge blocks. `expand_prompt` +consumes the rendered chat token IDs, expands only control-token image +placeholders, and returns modality IDs and four unpadded position rows +`[text,T,H,W]` plus the mRoPE delta. The model scheduler can transpose the last +three rows into `[tokens,3]`. Prompt construction describes each image without building its tensors. The description includes geometry, semantic identity, token dependency span, and @@ -820,5 +829,18 @@ cargo run --manifest-path helios/Cargo.toml --features images,test-tools --offli The qualifier accepts an optional third argument for writing mismatching native tensor bytes. Fixtures contain fingerprints rather than the full 100 MiB largest patch tensor; the generator's `--binary-dir` records full -reference tensors for diagnosis. These checks qualify CPU preparation; vision +reference tensors for diagnosis. + +Gemma 4 fixtures in `tests/frontend/gemma4_images.json` pin Transformers +`5.23.0`, PyTorch `2.14.1+cu132`, Torchvision `0.29.1+cu132`, and +`google/gemma-4-31B-it` at revision `842da3794eaa0b77d5f08bae87a17459d91ff475` +across 8 bit-exact SHA256 cases (`max_soft_tokens` 280 and 1120), regenerated +with: + +```bash +.venv/bin/python tests/frontend/generate_gemma4_image_fixtures.py \ + "$SNAPSHOT" tests/frontend/gemma4_images.json +``` + +These checks qualify CPU preparation; vision graph execution and decoder consumption require separate model integration. diff --git a/helios/build.rs b/helios/build.rs index 3a2b941a8..70c3b7d93 100644 --- a/helios/build.rs +++ b/helios/build.rs @@ -53,6 +53,10 @@ fn main() { ) .field_attribute(".flare.runtime.ToolParser.open", "#[serde(default)]") .field_attribute(".flare.runtime.ToolParser.close", "#[serde(default)]") + .field_attribute( + ".flare.runtime.VisionCapacity.patch_features", + "#[serde(default)]", + ) .compile_protos(&["proto/runtime_core.proto"], &["proto"]) .expect("compile runtime core protobuf schema"); // The payload schema imports the execution schema and refers to the generated types diff --git a/helios/model-contract.md b/helios/model-contract.md index 3722a9e6d..cd1a4ef39 100644 --- a/helios/model-contract.md +++ b/helios/model-contract.md @@ -79,7 +79,7 @@ serving contract and replay path unchanged. | `version` | Semantic contract version, 1, 2, or 3; exporters write 3 | | `vocabulary` | Valid sampled token range and histogram/mask geometry | | `input_vocabulary` | Valid input range, including declared nonsampled image sentinels | -| `vision` | Feature-slot and per-window feature capacities, patch-to-feature ratio, and captured patch capacities | +| `vision` | Feature-slot and per-window feature capacities, patch-to-feature ratio, captured patch capacities, and per-patch feature width (`patch_features`, where `0` defaults to the legacy `Bracketed` width `1176`) | | `cache` | Logical page tokens, attention-history storage, and page-table views | | `graphs` | Per-program operation, value bindings, persistent-state accesses, and resource dependencies | | `frontend` | Independent parser and image implementation identifiers plus their syntax and layout data | diff --git a/helios/proto/runtime_core.proto b/helios/proto/runtime_core.proto index 54ad04c70..49b45bab2 100644 --- a/helios/proto/runtime_core.proto +++ b/helios/proto/runtime_core.proto @@ -290,6 +290,8 @@ message VisionCapacity { uint64 max_images = 2; uint64 patches_per_feature = 3; repeated uint64 patch_capacities = 4; + // Float32 elements per vision patch; zero inherits the layout's legacy width. + uint64 patch_features = 6; } enum HistoryKind { HISTORY_UNSPECIFIED = 0; @@ -485,6 +487,7 @@ enum ImagePreparationKind { GLM_IMAGE_PREPARATION = 8; PATCH_MERGE_IMAGE_PREPARATION = 9; PADDED_GRID_IMAGE_PREPARATION = 10; + GEMMA4_IMAGE_PREPARATION = 11; } enum ImageLayoutKind { IMAGE_LAYOUT_UNSPECIFIED = 0; @@ -622,6 +625,7 @@ message ImageSettings { Empty glm = 8; PatchMergeImageSettings patch_merge = 9; Empty padded_grid = 10; + Gemma4ImageSettings gemma4 = 11; } } message PatchMergeImageSettings { @@ -634,6 +638,14 @@ message PatchMergeImageSettings { string start_token = 7; string end_token = 8; } +message Gemma4ImageSettings { + uint32 patch_size = 1; + uint32 pooling_kernel_size = 2; + uint32 max_soft_tokens = 3; + string image_token = 4; + string start_token = 5; + string end_token = 6; +} message DeepseekRowMajorImageSettings { uint64 min_pixels = 1; uint64 max_tokens = 2; diff --git a/helios/src/frontend/images/conditioned.rs b/helios/src/frontend/images/conditioned.rs index 41a2ed467..202a821da 100644 --- a/helios/src/frontend/images/conditioned.rs +++ b/helios/src/frontend/images/conditioned.rs @@ -184,18 +184,7 @@ impl PreparedImageInput { fn valid_processed(&self, images: &ProcessedImages) -> bool { use super::Profile; - let pixel_width = match &self.processor.profile { - Profile::Qwen(profile) => profile.patches.pixel_width(), - Profile::MiMo(profile) => profile.pixel_width(), - Profile::PatchMerge(profile) => profile.patches.pixel_width(), - Profile::Radio => 768, - Profile::Glm => 1176, - Profile::PaddedGrid => super::padded_grid::FEATURES, - Profile::DeepSeek4 - | Profile::DeepseekRowMajor(_) - | Profile::Moonvit - | Profile::Step => 588, - }; + let pixel_width = self.processor.patch_features(); let patches = self.geometry.patches; let interpolation = matches!( self.processor.profile, @@ -373,16 +362,29 @@ mod tests { ImageSettings::Radio {}, ImageSettings::Glm {}, ImageSettings::PaddedGrid {}, + ImageSettings::Gemma4(crate::frontend::images::Gemma4ImageSettings { + patch_size: 16, + pooling_kernel_size: 3, + max_soft_tokens: 280, + image_token: "<|image|>".into(), + start_token: "<|image>".into(), + end_token: "".into(), + }), ] } fn processor(settings: ImageSettings) -> Arc { + let patches_per_feature = match &settings { + ImageSettings::Gemma4(gemma4) => gemma4.pooling_kernel_size * gemma4.pooling_kernel_size, + _ => 1, + }; Arc::new( ImageProcessor::load( settings, ImageLimits { max_patches_per_image: 65536, max_total_patches: 65536, + patches_per_feature, ..Default::default() }, ) diff --git a/helios/src/frontend/images/gemma4.rs b/helios/src/frontend/images/gemma4.rs new file mode 100644 index 000000000..c1b5a8892 --- /dev/null +++ b/helios/src/frontend/images/gemma4.rs @@ -0,0 +1,497 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2026 Flare community contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +//! Gemma 4 area-bounded resize, interleaved RGB patch packing, and envelopes. + +use super::patch_merge::Envelope; +use super::*; + +// Discrete budgets from Hugging Face's `image_processor.max_soft_tokens` +// (validated here as wire-level defense-in-depth alongside Ignition's checkpoint gate). +const SUPPORTED_SOFT_TOKENS: [usize; 5] = [70, 140, 280, 560, 1120]; + +#[derive(Clone)] +pub(super) struct Processor { + limits: ImageLimits, + patch_size: usize, + pooling: usize, + max_soft_tokens: usize, + envelope: Envelope, +} + +impl Processor { + pub(super) fn load(settings: Gemma4ImageSettings, limits: ImageLimits) -> Result { + // Defensive wire caps prevent pathological patch/pooling allocations from malformed payloads. + if settings.patch_size == 0 || settings.patch_size > 64 { + return Err(format!( + "Gemma 4 patch_size ({}) must be in 1..=64", + settings.patch_size + ) + .into()); + } + if settings.pooling_kernel_size == 0 || settings.pooling_kernel_size > 16 { + return Err(format!( + "Gemma 4 pooling_kernel_size ({}) must be in 1..=16", + settings.pooling_kernel_size + ) + .into()); + } + if !SUPPORTED_SOFT_TOKENS.contains(&settings.max_soft_tokens) { + return Err(format!( + "unsupported Gemma 4 max_soft_tokens ({}); expected one of {:?}", + settings.max_soft_tokens, SUPPORTED_SOFT_TOKENS + ) + .into()); + } + let pooling_area = settings + .pooling_kernel_size + .checked_mul(settings.pooling_kernel_size) + .ok_or("Gemma 4 pooling area overflow")?; + if pooling_area != limits.patches_per_feature { + return Err(format!( + "Gemma 4 pooling area ({}x{} = {pooling_area}) differs from prepared patches_per_feature ({})", + settings.pooling_kernel_size, + settings.pooling_kernel_size, + limits.patches_per_feature + ) + .into()); + } + let max_patches = settings + .max_soft_tokens + .checked_mul(pooling_area) + .ok_or("Gemma 4 max patch budget overflow")?; + if max_patches > limits.max_patches_per_image { + return Err(format!( + "Gemma 4 max patch budget ({} * {pooling_area} = {max_patches}) exceeds prepared max_patches_per_image ({})", + settings.max_soft_tokens, limits.max_patches_per_image + ) + .into()); + } + let envelope = Envelope::load( + settings.image_token, + settings.start_token, + settings.end_token, + )?; + Ok(Self { + limits, + patch_size: settings.patch_size, + pooling: settings.pooling_kernel_size, + max_soft_tokens: settings.max_soft_tokens, + envelope, + }) + } + + pub(super) fn patch_features(&self) -> usize { + 3 * self.patch_size * self.patch_size + } + + pub(super) fn max_envelope_tokens(&self) -> usize { + self.max_soft_tokens + 2 + } + + fn side_multiple(&self) -> usize { + self.patch_size * self.pooling + } + + fn max_patches(&self) -> usize { + self.max_soft_tokens * self.pooling * self.pooling + } + + pub(super) fn geometry(&self, width: usize, height: usize) -> Result { + check_input_extent(self.limits, width, height)?; + let patches_per_image = self.max_patches(); + let side = self.side_multiple(); + let target_pixels = (patches_per_image * self.patch_size * self.patch_size) as f64; + let source_pixels = (width as f64) * (height as f64); + let factor = (target_pixels / source_pixels).sqrt(); + let ideal_height = factor * height as f64; + let ideal_width = factor * width as f64; + let mut target_height = (ideal_height / side as f64).floor() as usize * side; + let mut target_width = (ideal_width / side as f64).floor() as usize * side; + if target_height == 0 && target_width == 0 { + return Err(Error::frontend(FrontendError::Input(Failure::new( + "image resizes below one Gemma 4 patch group", + )))); + } + if target_height == 0 { + target_height = side; + target_width = (width / height).min(self.max_soft_tokens) * side; + } else if target_width == 0 { + target_width = side; + target_height = (height / width).min(self.max_soft_tokens) * side; + } + if target_height * target_width > target_pixels as usize { + return Err(Error::frontend(FrontendError::Input(Failure::new( + "Gemma 4 resize exceeds the soft-token budget", + )))); + } + let grid_h = target_height / self.patch_size; + let grid_w = target_width / self.patch_size; + let patches = grid_h * grid_w; + check_image_patches(self.limits, patches)?; + Ok(ImageGeometry { + height: target_height, + width: target_width, + grid_thw: [1, grid_h as i64, grid_w as i64], + patches, + tokens: patches / (self.pooling * self.pooling), + }) + } + + pub(super) fn resized_rgb(&self, image: &RgbImage) -> Result<(ImageGeometry, Vec)> { + let geometry = self.geometry(image.width, image.height)?; + Ok(( + geometry, + resize::resize(image, geometry.width, geometry.height), + )) + } + + pub(super) fn process(&self, images: &[RgbImage]) -> Result { + self.limits.check_batch(images.len(), 0)?; + let geometry: Vec<_> = images + .iter() + .map(|image| self.geometry(image.width, image.height)) + .collect::>()?; + let total: usize = geometry + .iter() + .try_fold(0usize, |sum, image| sum.checked_add(image.patches)) + .ok_or_else(|| { + Error::frontend(FrontendError::Input(Failure::new("patch count overflow"))) + })?; + self.limits.check_batch(images.len(), total)?; + let patch_features = self.patch_features(); + let mut result = ProcessedImages { + geometry, + cu_seqlens: vec![0], + ..Default::default() + }; + result.reserve_outputs(total, patch_features, false, images.len(), images.len() + 1)?; + for (image, geometry) in images.iter().zip(&result.geometry) { + let pixels = resize::resize(image, geometry.width, geometry.height); + let grid_h = geometry.height / self.patch_size; + let grid_w = geometry.width / self.patch_size; + // Gemma 4 patch vectors interleave RGB per pixel: (y, x, channel). + for row in 0..grid_h { + for column in 0..grid_w { + result.position_ids.push([column as i64, row as i64]); + for y in 0..self.patch_size { + for x in 0..self.patch_size { + let offset = ((row * self.patch_size + y) * geometry.width + + column * self.patch_size + + x) + * 3; + for channel in 0..3 { + result + .pixel_values + .push(pixels[offset + channel] as f32 * (1.0 / 255.0)); + } + } + } + } + } + result + .cu_seqlens + .push(result.cu_seqlens.last().unwrap() + geometry.patches as i32); + } + Ok(result) + } + + pub(super) fn expand_prompt( + &self, + frontend: &Frontend, + prompt_token_ids: &[u32], + images: &ProcessedImages, + ) -> Result { + self.envelope.expand(frontend, prompt_token_ids, images) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::frontend::{Asset, FrontendAssets, images::ImageSettings}; + use sha2::{Digest, Sha256}; + use std::path::PathBuf; + + fn processor_with_budget(max_soft_tokens: usize) -> ImageProcessor { + let max_patches = max_soft_tokens * 9; + ImageProcessor::load( + ImageSettings::Gemma4(Gemma4ImageSettings { + patch_size: 16, + pooling_kernel_size: 3, + max_soft_tokens, + image_token: "<|image|>".into(), + start_token: "<|image>".into(), + end_token: "".into(), + }), + ImageLimits { + max_patches_per_image: max_patches, + max_total_patches: max_patches * 4, + patches_per_feature: 9, + ..ImageLimits::default() + }, + ) + .unwrap() + } + + fn processor() -> ImageProcessor { + processor_with_budget(280) + } + + #[test] + fn load_validates_pooling_and_patch_budget_limits() { + let settings = Gemma4ImageSettings { + patch_size: 16, + pooling_kernel_size: 3, + max_soft_tokens: 280, + image_token: "<|image|>".into(), + start_token: "<|image>".into(), + end_token: "".into(), + }; + let pooling_err = ImageProcessor::load( + ImageSettings::Gemma4(settings.clone()), + ImageLimits { + patches_per_feature: 4, + max_patches_per_image: 2520, + ..ImageLimits::default() + }, + ) + .err() + .unwrap() + .to_string(); + assert!( + pooling_err.contains("patches_per_feature") + && pooling_err.contains("9") + && pooling_err.contains("4"), + "{pooling_err}" + ); + let budget_err = ImageProcessor::load( + ImageSettings::Gemma4(settings.clone()), + ImageLimits { + patches_per_feature: 9, + max_patches_per_image: 2519, + ..ImageLimits::default() + }, + ) + .err() + .unwrap() + .to_string(); + assert!( + budget_err.contains("max_patches_per_image") + && budget_err.contains("2520") + && budget_err.contains("2519"), + "{budget_err}" + ); + let soft_err = ImageProcessor::load( + ImageSettings::Gemma4(Gemma4ImageSettings { + max_soft_tokens: 200, + ..settings + }), + ImageLimits { + patches_per_feature: 9, + max_patches_per_image: 2520, + ..ImageLimits::default() + }, + ) + .err() + .unwrap() + .to_string(); + assert!( + soft_err.contains("max_soft_tokens") && soft_err.contains("200"), + "{soft_err}" + ); + } + + #[test] + fn canonical_processor_pixels_positions_and_resize() { + use serde_json::{Value, json}; + let fixture: Value = + serde_json::from_str(include_str!("../../../../tests/frontend/gemma4_images.json")) + .unwrap(); + let hash = |bytes: &[u8]| format!("{:x}", Sha256::digest(bytes)); + for case in fixture["cases"].as_array().unwrap() { + let width = case["width"].as_u64().unwrap() as usize; + let height = case["height"].as_u64().unwrap() as usize; + let seed = case["seed"].as_u64().unwrap() as usize; + let max_soft_tokens = case["max_soft_tokens"].as_u64().unwrap() as usize; + let processor = processor_with_budget(max_soft_tokens); + let pixels: Vec = (0..height) + .flat_map(|y| { + (0..width).flat_map(move |x| { + [(x * 7 + seed * 31) as u8, (y * 11) as u8, (x + y * 3) as u8] + }) + }) + .collect(); + let image = RgbImage::new(width, height, pixels).unwrap(); + let (geometry, resized) = processor.resized_rgb(&image).unwrap(); + assert_eq!( + json!(geometry.grid_thw), + case["grid"], + "{width}x{height}@{max_soft_tokens}" + ); + assert_eq!( + geometry.tokens as u64, + case["tokens"].as_u64().unwrap(), + "{width}x{height}@{max_soft_tokens}" + ); + assert_eq!( + geometry.patches as u64, + case["patches"].as_u64().unwrap(), + "{width}x{height}@{max_soft_tokens}" + ); + assert_eq!( + hash(&resized), + case["resized"], + "resize {width}x{height}@{max_soft_tokens}" + ); + let processed = processor.process(&[image]).unwrap(); + let pixels: Vec = processed + .pixel_values + .iter() + .flat_map(|v| v.to_le_bytes()) + .collect(); + assert_eq!( + hash(&pixels), + case["pixels"], + "pixels {width}x{height}@{max_soft_tokens}" + ); + let positions: Vec = processed + .position_ids + .iter() + .flatten() + .flat_map(|v| v.to_le_bytes()) + .collect(); + assert_eq!( + hash(&positions), + case["positions"], + "positions {width}x{height}@{max_soft_tokens}" + ); + assert_eq!(processed.cu_seqlens, [0, geometry.patches as i32]); + assert!(processed.interpolation_indices.is_empty()); + } + } + + #[test] + fn geometry_matches_the_hugging_face_processor() { + let processor = processor(); + for (width, height, grid, tokens) in [ + (1, 1, [1, 48, 48], 256), + (672, 672, [1, 48, 48], 256), + (1008, 672, [1, 39, 60], 260), + (91, 37, [1, 30, 78], 260), + (1920, 1080, [1, 36, 66], 264), + (100, 3000, [1, 273, 9], 273), + (3000, 100, [1, 9, 273], 273), + (10, 3000, [1, 840, 3], 280), + (3000, 10, [1, 3, 840], 280), + ] { + let geometry = processor.geometry(width, height).unwrap(); + assert_eq!(geometry.grid_thw, grid, "{width}x{height}"); + assert_eq!(geometry.tokens, tokens, "{width}x{height}"); + assert_eq!(geometry.tokens * 9, geometry.patches, "{width}x{height}"); + } + } + + #[test] + fn pixels_interleave_rgb_and_positions_are_xy() { + let processor = processor(); + let pixels: Vec = (0..37 * 91 * 3).map(|x| (x % 256) as u8).collect(); + let image = RgbImage::new(91, 37, pixels).unwrap(); + let processed = processor.process(&[image]).unwrap(); + let geometry = processed.geometry[0]; + assert_eq!(geometry.grid_thw, [1, 30, 78]); + assert_eq!(processed.pixel_values.len(), geometry.patches * 3 * 16 * 16); + assert_eq!(processed.position_ids[0], [0, 0]); + assert_eq!(processed.position_ids[1], [1, 0]); + assert_eq!( + processed.position_ids[geometry.grid_thw[2] as usize], + [0, 1] + ); + assert_eq!(processed.cu_seqlens, [0, geometry.patches as i32]); + } + + #[test] + #[ignore = "requires FLARE_GEMMA4_TEST_SNAPSHOT"] + fn checkpoint_tokens_expand_the_image_envelope() { + let snapshot = PathBuf::from( + std::env::var_os("FLARE_GEMMA4_TEST_SNAPSHOT") + .expect("FLARE_GEMMA4_TEST_SNAPSHOT must be set"), + ); + assert!( + snapshot.join("tokenizer.json").is_file(), + "missing tokenizer.json under {}", + snapshot.display() + ); + let asset = |name: &str| { + let path = snapshot.join(name); + Asset { + sha256: format!("{:x}", Sha256::digest(std::fs::read(&path).unwrap())), + path, + range: None, + } + }; + // Frontend::load requires a chat template asset for PromptEncoder::Jinja (frontend/mod.rs). + struct TempFile(PathBuf); + impl Drop for TempFile { + fn drop(&mut self) { + let _ = std::fs::remove_file(&self.0); + } + } + let template = TempFile( + std::env::temp_dir().join(format!("gemma4-template-{}.jinja", std::process::id())), + ); + let template_bytes = b"{% mark %}{{ messages[0].content }}"; + std::fs::write(&template.0, template_bytes).unwrap(); + let chat_template = Asset { + sha256: format!("{:x}", Sha256::digest(template_bytes)), + path: template.0.clone(), + range: None, + }; + let frontend = Frontend::load( + FrontendAssets { + tokenizer: asset("tokenizer.json"), + tokens: crate::frontend::test_support::tokens(&asset("tokenizer_config.json")) + .unwrap(), + chat_template: Some(chat_template), + }, + Default::default(), + ) + .unwrap(); + drop(template); + let processed = ProcessedImages { + geometry: vec![ImageGeometry { + height: 480, + width: 1248, + grid_thw: [1, 30, 78], + patches: 2340, + tokens: 260, + }], + cu_seqlens: vec![0, 2340], + ..Default::default() + }; + let prompt_ids = frontend.encode("Look <|image|> now", false).unwrap(); + let expanded = processor() + .expand_prompt(&frontend, &prompt_ids, &processed) + .unwrap(); + let boi = frontend.encode("<|image>", false).unwrap()[0]; + let image = frontend.encode("<|image|>", false).unwrap()[0]; + let eoi = frontend.encode("", false).unwrap()[0]; + let start = expanded.token_ids.iter().position(|id| *id == boi).unwrap(); + assert_eq!(expanded.token_ids[start], boi); + assert_eq!(expanded.token_ids[start + 261], eoi); + assert!( + expanded.token_ids[start + 1..start + 261] + .iter() + .all(|id| *id == image) + ); + assert!( + expanded.mm_token_type_ids[start + 1..start + 261] + .iter() + .all(|kind| *kind == 1) + ); + assert_eq!(expanded.mm_token_type_ids[start], 0); + assert_eq!(expanded.mm_token_type_ids[start + 261], 0); + } +} diff --git a/helios/src/frontend/images/layouts/bracketed.rs b/helios/src/frontend/images/layouts/bracketed.rs index 2c208037e..3902f79d7 100644 --- a/helios/src/frontend/images/layouts/bracketed.rs +++ b/helios/src/frontend/images/layouts/bracketed.rs @@ -20,6 +20,7 @@ pub(crate) fn prepare_input( processor: Option<&ImageProcessor>, rendered: &RenderedPrompt, images: &[ImageDescription], + atomic_spans: bool, ) -> Result { if images.is_empty() { if let Some(processor) = processor { @@ -48,11 +49,25 @@ pub(crate) fn prepare_input( let processed = processor.describe_inputs(images)?; let expanded = processor.expand_prompt(frontend, &rendered.token_ids, &processed)?; let mut conditioning = Vec::new(); + let mut spans = Vec::new(); let mut image = 0; let mut feature = 0; + let mut run_start = None; let mut indices = Vec::with_capacity(expanded.token_ids.len()); + let mut flush_span = |start: usize, end: usize| -> Result<()> { + if atomic_spans { + if start == 0 || end >= expanded.token_ids.len() { + return Err("bracketed image feature run is outside the expanded prompt".into()); + } + spans.push(start - 1..end + 1); + } + Ok(()) + }; for (position, kind) in expanded.mm_token_type_ids.iter().enumerate() { if *kind == 0 { + if let Some(start) = run_start.take() { + flush_span(start, position)?; + } indices.push(-1); continue; } @@ -62,11 +77,15 @@ pub(crate) fn prepare_input( position: position as u64, identity: source.identity, }); + run_start = Some(position); image += 1; } indices.push(feature); feature += 1; } + if let Some(start) = run_start.take() { + flush_span(start, expanded.mm_token_type_ids.len())?; + } if image != images.len() || feature as usize != processed.geometry.iter().map(|g| g.tokens).sum::() { @@ -84,6 +103,7 @@ pub(crate) fn prepare_input( tokens: expanded.token_ids, data: PromptData { vision_token_indices: indices, + spans, ..Default::default() }, conditioning, @@ -152,7 +172,7 @@ mod tests { RgbImage::new(672, 672, vec![255; 672 * 672 * 3]).unwrap(), ]; let images = images.iter().map(|image| processor.describe_image(image).unwrap()).collect::>(); - let prepared = prepare_input(&frontend, Some(&processor), &rendered, &images).unwrap(); + let prepared = prepare_input(&frontend, Some(&processor), &rendered, &images, false).unwrap(); assert_eq!( prepared.tokens.iter().filter(|id| **id == 200025).count(), 580 @@ -176,6 +196,6 @@ mod tests { assert_eq!(prepared.tokens[p + count], end); assert!(prepared.tokens[p..p + count].iter().all(|id| *id == 200025)); } - assert!(prepare_input(&frontend, Some(&processor), &rendered, &[]).is_err()); + assert!(prepare_input(&frontend, Some(&processor), &rendered, &[], false).is_err()); } } diff --git a/helios/src/frontend/images/mod.rs b/helios/src/frontend/images/mod.rs index 03925031e..242d6324e 100644 --- a/helios/src/frontend/images/mod.rs +++ b/helios/src/frontend/images/mod.rs @@ -14,6 +14,7 @@ mod deepseek_row_major; pub(crate) mod layouts; mod mimo; mod glm; +mod gemma4; mod moonvit; mod orientation; mod conditioned; @@ -299,6 +300,7 @@ pub enum ImageSettings { Radio {}, Glm {}, PaddedGrid {}, + Gemma4(Gemma4ImageSettings), } /// The text that stands for an image in a RADIO prompt. @@ -325,6 +327,7 @@ impl ImageSettings { Self::Radio {} => ImagePreparationKind::Radio, Self::Glm {} => ImagePreparationKind::Glm, Self::PaddedGrid {} => ImagePreparationKind::PaddedGrid, + Self::Gemma4(_) => ImagePreparationKind::Gemma4, } } } @@ -369,6 +372,17 @@ pub struct PatchMergeImageSettings { pub end_token: String, } +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Gemma4ImageSettings { + pub patch_size: usize, + pub pooling_kernel_size: usize, + pub max_soft_tokens: usize, + pub image_token: String, + pub start_token: String, + pub end_token: String, +} + #[derive(Clone)] enum Profile { Qwen(qwen::QwenProcessor), @@ -381,6 +395,7 @@ enum Profile { Radio, Glm, PaddedGrid, + Gemma4(gemma4::Processor), } impl ImageProcessor { @@ -414,6 +429,7 @@ impl ImageProcessor { ImageSettings::Radio {} => Profile::Radio, ImageSettings::Glm {} => Profile::Glm, ImageSettings::PaddedGrid {} => Profile::PaddedGrid, + ImageSettings::Gemma4(settings) => Profile::Gemma4(gemma4::Processor::load(settings, limits)?), ImageSettings::Mimo(settings) => Profile::MiMo(mimo::load(&settings, limits)?), ImageSettings::PatchMerge(settings) => Profile::PatchMerge(patch_merge::Processor::load(settings, limits)?), ImageSettings::Qwen(settings) => { @@ -483,6 +499,28 @@ impl ImageProcessor { self.limits } + pub(crate) fn patch_features(&self) -> usize { + match &self.profile { + Profile::Qwen(profile) => profile.patches.pixel_width(), + Profile::MiMo(profile) => profile.pixel_width(), + Profile::PatchMerge(profile) => profile.patches.pixel_width(), + Profile::Radio => 768, + Profile::Glm => 1176, + Profile::PaddedGrid => padded_grid::FEATURES, + Profile::Gemma4(processor) => processor.patch_features(), + Profile::DeepSeek4 | Profile::DeepseekRowMajor(_) | Profile::Moonvit | Profile::Step => { + 588 + } + } + } + + pub(crate) fn max_image_envelope_tokens(&self) -> Option { + match &self.profile { + Profile::Gemma4(processor) => Some(processor.max_envelope_tokens()), + _ => None, + } + } + pub(crate) fn check_batch(&self, images: usize, patches: usize) -> Result<()> { self.limits.check_batch(images, patches) } @@ -886,6 +924,7 @@ impl ImageProcessor { Profile::Radio => radio::geometry(self.limits, width, height), Profile::Glm => glm::geometry(self.limits, width, height), Profile::PaddedGrid => padded_grid::geometry(self.limits, width, height), + Profile::Gemma4(profile) => profile.geometry(width, height), } } pub fn resized_rgb(&self, image: &RgbImage) -> Result<(ImageGeometry, Vec)> { @@ -900,6 +939,7 @@ impl ImageProcessor { Profile::Radio => Err("RADIO resizing produces float32 pixels; use process".into()), Profile::Glm => glm::resized_rgb(self.limits, image), Profile::PaddedGrid => Err("padded-grid preparation pads with values outside RGB8; use process".into()), + Profile::Gemma4(profile) => profile.resized_rgb(image), } } pub fn process(&self, images: &[RgbImage]) -> Result { @@ -919,6 +959,7 @@ impl ImageProcessor { Profile::Radio => radio::process(self.limits, images), Profile::Glm => glm::process(self.limits, images), Profile::PaddedGrid => padded_grid::process(self.limits, images), + Profile::Gemma4(profile) => profile.process(images), } } pub fn expand_prompt( @@ -939,6 +980,7 @@ impl ImageProcessor { Profile::Radio => Err("RADIO image expansion requires its model contract".into()), Profile::Glm => Err("GLM image expansion requires its prepared layout".into()), Profile::PaddedGrid => Err("padded-grid image expansion requires its prepared layout".into()), + Profile::Gemma4(profile) => profile.expand_prompt(frontend, prompt_token_ids, images), } } } diff --git a/helios/src/frontend/images/packing.rs b/helios/src/frontend/images/packing.rs index 827e55ca0..425e2c2d1 100644 --- a/helios/src/frontend/images/packing.rs +++ b/helios/src/frontend/images/packing.rs @@ -9,12 +9,21 @@ use super::ProcessedImages; use crate::{ Result, execution::Dtype, - model::{ModelConfig, contract::ImageLayoutKind, inputs::UploadBatch}, + model::{ModelConfig, VisionCapabilities, contract::ImageLayoutKind, inputs::UploadBatch}, scheduler::RequestHandle, }; +fn square_merge_side(patches_per_feature: usize) -> Result { + let side = patches_per_feature.isqrt(); + if side == 0 || side * side != patches_per_feature { + return Err("bracketed patches_per_feature must be a positive square".into()); + } + Ok(side as i64) +} + pub(crate) fn tensor_layout( kind: ImageLayoutKind, + vision: &VisionCapabilities, name: &str, patches: usize, ) -> Result<(Dtype, usize)> { @@ -27,7 +36,14 @@ pub(crate) fn tensor_layout( ImageLayoutKind::Deepseek | ImageLayoutKind::DeepseekRowMajor | ImageLayoutKind::Moonvit | ImageLayoutKind::Step, "vision_pixel_values", ) => (Float32, patches * 588), - (ImageLayoutKind::Bracketed, "vision_pixel_values") => (Float32, patches * 1176), + (ImageLayoutKind::Bracketed, "vision_pixel_values") => { + square_merge_side(vision.patches_per_feature)?; + let width = vision.bracketed_patch_features(); + let elements = patches + .checked_mul(width) + .ok_or("vision pixel buffer extent overflows")?; + (Float32, elements) + } (ImageLayoutKind::Radio, "vision_pixel_values") => (Float32, patches * 768), (ImageLayoutKind::Glm, "vision_pixel_values") => (Float32, patches * 1176), (ImageLayoutKind::ClassToken, "vision_pixel_values") => (Float32, patches * 1200), @@ -465,19 +481,24 @@ fn step( } fn bracketed(config: &ModelConfig, handle: RequestHandle, images: &ProcessedImages, image: usize, destination_feature_offset: usize) -> Result { + let patches_per_feature = config.contract.vision.patches_per_feature; + let merge_side = square_merge_side(patches_per_feature)?; + let patch_width = config.contract.vision.bracketed_patch_features(); let geometry = images.geometry.get(image).ok_or("missing scheduled image")?; let start: usize = images.geometry[..image].iter().map(|g| g.patches).sum(); let end = start + geometry.patches; let [t, h, w] = geometry.grid_thw; - if t != 1 || h <= 0 || w <= 0 || h%2 != 0 || w%2 != 0 + if t != 1 || h <= 0 || w <= 0 || h % merge_side != 0 || w % merge_side != 0 || (h as usize).checked_mul(w as usize) != Some(geometry.patches) - || geometry.tokens != geometry.patches/4 || config.contract.vision.patches_per_feature != 4 + || geometry.tokens.checked_mul(patches_per_feature) != Some(geometry.patches) || geometry.patches > *config.contract.vision.patch_capacities.last().ok_or("missing vision capacities")? || handle.slot as usize >= config.limits.max_active || handle.generation == 0 || handle.generation > i64::MAX as u64 { - return Err("invalid temporal patch-merge image extent".into()); + return Err("invalid bracketed image extent".into()); } + let pixel_start = start.checked_mul(patch_width).ok_or("vision pixel offset overflows")?; + let pixel_end = end.checked_mul(patch_width).ok_or("vision pixel offset overflows")?; let mut staging = UploadBatch::default(); - staging.put("vision_pixel_values", 0, images.pixel_values.get(start*1176..end*1176).ok_or("truncated vision pixels")?.iter().copied().flat_map(f32::to_le_bytes)); + staging.put("vision_pixel_values", 0, images.pixel_values.get(pixel_start..pixel_end).ok_or("truncated vision pixels")?.iter().copied().flat_map(f32::to_le_bytes)); staging.i64("vision_position_ids", 0, images.position_ids.get(start..end).ok_or("truncated vision positions")?.iter().flatten().copied()); staging.i32("vision_cu_seqlens", 0, [0, geometry.patches as i32]); staging.i32("vision_num_patches", 0, [geometry.patches as i32]); @@ -544,3 +565,251 @@ fn class_token( staging.i32("vision_feature_offset", 0, [destination_feature_offset as i32]); Ok(staging) } + +#[cfg(test)] +mod tests { + use super::*; + use crate::frontend::images::{ + DeepseekRowMajorImageSettings, Gemma4ImageSettings, ImageGeometry, ImageLimits, + ImageProcessor, ImageSettings, MimoImageSettings, PatchMergeImageSettings, + QwenImageSettings, + }; + + fn bracketed_config(patches_per_feature: usize, patch_features: usize) -> ModelConfig { + let mut config = crate::frontend::test_support::model_config( + crate::model::testing::metadata(), + ); + config.contract.frontend.image_layout = Some(ImageLayoutKind::Bracketed); + config.contract.vision = VisionCapabilities { + feature_slots: 1, + features_per_request: 1024, + max_images: 4, + patches_per_feature, + patch_capacities: vec![9 * 1024], + patch_features, + }; + config + } + + #[test] + fn bracketed_packs_3x3_metadata_widths_and_rejects_invalid_extents() { + let handle = RequestHandle { + slot: 0, + generation: 1, + }; + for width in [768usize, 588] { + let config = bracketed_config(9, width); + assert_eq!( + tensor_layout( + ImageLayoutKind::Bracketed, + &config.contract.vision, + "vision_pixel_values", + 18, + ) + .unwrap(), + (Dtype::Float32, 18 * width), + ); + let images = ProcessedImages { + pixel_values: (0..18 * width).map(|i| i as f32).collect(), + geometry: vec![ImageGeometry { + height: 48, + width: 96, + grid_thw: [1, 3, 6], + patches: 18, + tokens: 2, + }], + position_ids: (0..18).map(|i| [i as i64 % 6, i as i64 / 6]).collect(), + interpolation_indices: vec![], + interpolation_weights: vec![], + cu_seqlens: vec![0, 18], + }; + let batch = bracketed(&config, handle, &images, 0, 5).unwrap(); + let uploads = batch.uploads(); + let pixels = uploads + .iter() + .find(|entry| entry.buffer == "vision_pixel_values") + .unwrap(); + assert_eq!(pixels.bytes.len(), 18 * width * 4); + let truncated = ProcessedImages { + pixel_values: vec![0.0; 18 * width - 1], + ..images.clone() + }; + assert!(bracketed(&config, handle, &truncated, 0, 0).is_err()); + let odd_grid = ProcessedImages { + geometry: vec![ImageGeometry { + height: 64, + width: 64, + grid_thw: [1, 4, 4], + patches: 16, + tokens: 2, + }], + ..images + }; + assert!(bracketed(&config, handle, &odd_grid, 0, 0).is_err()); + } + let legacy = bracketed_config(4, 0); + assert_eq!( + tensor_layout( + ImageLayoutKind::Bracketed, + &legacy.contract.vision, + "vision_pixel_values", + 16, + ) + .unwrap(), + (Dtype::Float32, 16 * 1176), + ); + let non_square = bracketed_config(3, 768); + assert!( + tensor_layout( + ImageLayoutKind::Bracketed, + &non_square.contract.vision, + "vision_pixel_values", + 9, + ) + .is_err() + ); + // Non-Bracketed layouts with non-square patches_per_feature remain unaffected. + assert_eq!( + tensor_layout( + ImageLayoutKind::Deepseek, + &non_square.contract.vision, + "vision_pixel_values", + 9, + ) + .unwrap(), + (Dtype::Float32, 9 * 588), + ); + } + + #[test] + fn processor_patch_features_match_tensor_layout_for_every_profile() { + let cases: Vec<(ImageSettings, ImageLimits, ImageLayoutKind, usize, usize)> = vec![ + ( + ImageSettings::Qwen(QwenImageSettings { + min_pixels: 3136, + max_pixels: 1_000_000, + position_side: 48, + image_token_id: 1, + video_token_id: 2, + }), + ImageLimits::default(), + ImageLayoutKind::Qwen, + 4, + 0, + ), + ( + ImageSettings::Mimo(MimoImageSettings { + min_pixels: 3136, + max_pixels: 1_000_000, + image_mean: [0.5; 3], + image_std: [0.5; 3], + }), + ImageLimits::default(), + ImageLayoutKind::Mimo, + 4, + 0, + ), + ( + ImageSettings::Deepseek4 {}, + ImageLimits::default(), + ImageLayoutKind::Deepseek, + 9, + 0, + ), + ( + ImageSettings::DeepseekRowMajor(DeepseekRowMajorImageSettings { + min_pixels: 3136, + max_tokens: 1024, + max_width_height_ratio: None, + }), + ImageLimits::default(), + ImageLayoutKind::DeepseekRowMajor, + 9, + 0, + ), + ( + ImageSettings::Moonvit {}, + ImageLimits::default(), + ImageLayoutKind::Moonvit, + 4, + 0, + ), + ( + ImageSettings::Step {}, + ImageLimits::default(), + ImageLayoutKind::Step, + 4, + 0, + ), + ( + ImageSettings::Radio {}, + ImageLimits::default(), + ImageLayoutKind::Radio, + 4, + 0, + ), + ( + ImageSettings::Glm {}, + ImageLimits::default(), + ImageLayoutKind::Glm, + 4, + 0, + ), + ( + ImageSettings::PatchMerge(PatchMergeImageSettings { + patch_size: 14, + min_pixels: 3136, + max_pixels: 451_584, + image_mean: [0.5; 3], + image_std: [0.5; 3], + image_token: "image".into(), + start_token: "start".into(), + end_token: "end".into(), + }), + ImageLimits::default(), + ImageLayoutKind::Bracketed, + 4, + 0, + ), + ( + ImageSettings::PaddedGrid {}, + ImageLimits::default(), + ImageLayoutKind::ClassToken, + 4, + 0, + ), + ( + ImageSettings::Gemma4(Gemma4ImageSettings { + patch_size: 16, + pooling_kernel_size: 3, + max_soft_tokens: 280, + image_token: "<|image|>".into(), + start_token: "<|image>".into(), + end_token: "".into(), + }), + ImageLimits { + patches_per_feature: 9, + ..ImageLimits::default() + }, + ImageLayoutKind::Bracketed, + 9, + 768, + ), + ]; + for (settings, limits, layout, patches_per_feature, patch_features) in cases { + let processor = ImageProcessor::load(settings, limits).unwrap(); + let vision = VisionCapabilities { + feature_slots: 1, + features_per_request: 1024, + max_images: 4, + patches_per_feature, + patch_capacities: vec![patches_per_feature * 16], + patch_features, + }; + let (dtype, width) = + tensor_layout(layout, &vision, "vision_pixel_values", 1).unwrap(); + assert_eq!(dtype, Dtype::Float32); + assert_eq!(processor.patch_features(), width, "{layout:?}"); + } + } +} diff --git a/helios/src/frontend/images/patch_merge.rs b/helios/src/frontend/images/patch_merge.rs index fa9c6d034..a3639523c 100644 --- a/helios/src/frontend/images/patch_merge.rs +++ b/helios/src/frontend/images/patch_merge.rs @@ -7,56 +7,30 @@ use super::*; +/// Start/feature/end token envelope (`image_token`, `start_token`, `end_token`) +/// shared by `PatchMerge` and `Gemma4` image preparation profiles. #[derive(Clone)] -pub(super) struct Processor { - pub(super) patches: patches::PatchProcessor, +pub(super) struct Envelope { image_token: String, start_token: String, end_token: String, } -impl Processor { - pub(super) fn load(settings: PatchMergeImageSettings, limits: ImageLimits) -> Result { - if settings.patch_size != 14 - || settings.min_pixels == 0 - || settings.max_pixels < settings.min_pixels - || settings.image_mean.iter().any(|x| !x.is_finite()) - || settings - .image_std - .iter() - .any(|x| !x.is_finite() || *x <= 0.) - || [ - &settings.image_token, - &settings.start_token, - &settings.end_token, - ] +impl Envelope { + pub(super) fn load(image_token: String, start_token: String, end_token: String) -> Result { + if [&image_token, &start_token, &end_token] .iter() .any(|s| s.is_empty()) - || settings.image_token == settings.start_token - || settings.image_token == settings.end_token - || settings.start_token == settings.end_token + || image_token == start_token + || image_token == end_token + || start_token == end_token { - return Err("invalid temporal patch-merge image settings".into()); + return Err("invalid image envelope tokens".into()); } - Ok(Self { - patches: patches::PatchProcessor { - limits, - patch_size: settings.patch_size, - min_pixels: settings.min_pixels, - max_pixels: settings.max_pixels, - normalization: patches::Normalization::ScaledChannel { - mean: settings.image_mean, - std: settings.image_std, - }, - resize: resize::resize, - }, - image_token: settings.image_token, - start_token: settings.start_token, - end_token: settings.end_token, - }) + Ok(Self { image_token, start_token, end_token }) } - pub(super) fn expand_prompt( + pub(super) fn expand( &self, frontend: &Frontend, prompt_token_ids: &[u32], @@ -107,6 +81,56 @@ impl Processor { } } +#[derive(Clone)] +pub(super) struct Processor { + pub(super) patches: patches::PatchProcessor, + envelope: Envelope, +} + +impl Processor { + pub(super) fn load(settings: PatchMergeImageSettings, limits: ImageLimits) -> Result { + if settings.patch_size != 14 + || settings.min_pixels == 0 + || settings.max_pixels < settings.min_pixels + || settings.image_mean.iter().any(|x| !x.is_finite()) + || settings + .image_std + .iter() + .any(|x| !x.is_finite() || *x <= 0.) + { + return Err("invalid temporal patch-merge image settings".into()); + } + let envelope = Envelope::load( + settings.image_token, + settings.start_token, + settings.end_token, + )?; + Ok(Self { + patches: patches::PatchProcessor { + limits, + patch_size: settings.patch_size, + min_pixels: settings.min_pixels, + max_pixels: settings.max_pixels, + normalization: patches::Normalization::ScaledChannel { + mean: settings.image_mean, + std: settings.image_std, + }, + resize: resize::resize, + }, + envelope, + }) + } + + pub(super) fn expand_prompt( + &self, + frontend: &Frontend, + prompt_token_ids: &[u32], + images: &ProcessedImages, + ) -> Result { + self.envelope.expand(frontend, prompt_token_ids, images) + } +} + #[cfg(test)] mod tests { use super::*; @@ -187,4 +211,92 @@ sys.stdout.buffer.write(result['pixel_values'].contiguous().numpy().tobytes()) assert_eq!(*a, b, "pixel {i}"); } } + + #[test] + fn envelope_expands_image_placeholders_and_rejects_mismatches() { + use crate::frontend::{Asset, FrontendAssets}; + use sha2::{Digest, Sha256}; + static SERIAL: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); + let root = std::env::temp_dir().join(format!( + "flare-envelope-{}-{}", + std::process::id(), + SERIAL.fetch_add(1, std::sync::atomic::Ordering::Relaxed) + )); + std::fs::create_dir_all(&root).unwrap(); + let vocab: tokenizers::models::bpe::Vocab = (0..128) + .map(|id| ((id as u8 as char).to_string(), id)) + .collect(); + let model = tokenizers::models::bpe::BPE::builder() + .vocab_and_merges(vocab, vec![]) + .build() + .unwrap(); + let mut tokenizer = tokenizers::Tokenizer::new(model); + tokenizer + .add_special_tokens( + [ + "<|image|>", + "<|image>", + "", + "]<]image[>[", + "]<]start of image[>[", + "]<]end of image[>[", + ] + .map(|text| tokenizers::AddedToken::from(text, true)), + ) + .unwrap(); + let asset = |name: &str, bytes: &[u8]| { + let path = root.join(name); + std::fs::write(&path, bytes).unwrap(); + Asset { + range: None, + path, + sha256: format!("{:x}", Sha256::digest(bytes)), + } + }; + let frontend = Frontend::load( + FrontendAssets { + tokenizer: asset("tokenizer.json", tokenizer.to_string(false).unwrap().as_bytes()), + tokens: Default::default(), + chat_template: Some(asset( + "chat_template.jinja", + b"{% mark %}{{ messages[0].content }}", + )), + }, + Default::default(), + ) + .unwrap(); + std::fs::remove_dir_all(&root).unwrap(); + + for (image_tok, start_tok, end_tok) in [ + ("<|image|>", "<|image>", ""), + ("]<]image[>[", "]<]start of image[>[", "]<]end of image[>["), + ] { + let envelope = Envelope::load(image_tok.into(), start_tok.into(), end_tok.into()).unwrap(); + let prompt = format!("A {image_tok} B {image_tok} C"); + let prompt_ids = frontend.encode(&prompt, false).unwrap(); + let processed = ProcessedImages { + geometry: vec![ + ImageGeometry { height: 48, width: 48, grid_thw: [1, 3, 3], patches: 9, tokens: 2 }, + ImageGeometry { height: 48, width: 48, grid_thw: [1, 3, 3], patches: 9, tokens: 3 }, + ], + ..Default::default() + }; + let expanded = envelope.expand(&frontend, &prompt_ids, &processed).unwrap(); + let img_id = frontend.encode(image_tok, false).unwrap()[0]; + let start_id = frontend.encode(start_tok, false).unwrap()[0]; + let end_id = frontend.encode(end_tok, false).unwrap()[0]; + assert_eq!(expanded.token_ids.iter().filter(|id| **id == img_id).count(), 5); + assert_eq!(expanded.token_ids.iter().filter(|id| **id == start_id).count(), 2); + assert_eq!(expanded.token_ids.iter().filter(|id| **id == end_id).count(), 2); + assert_eq!(expanded.mm_token_type_ids.iter().filter(|kind| **kind == 1).count(), 5); + // Placeholder count mismatch fails cleanly. + assert!(envelope.expand(&frontend, &prompt_ids, &ProcessedImages::default()).is_err()); + } + + // Duplicate or empty tokens fail load; multi-token marker fails expand. + assert!(Envelope::load("".into(), "<|image>".into(), "".into()).is_err()); + assert!(Envelope::load("<|image|>".into(), "<|image|>".into(), "".into()).is_err()); + let bad = Envelope::load("ab".into(), "<|image>".into(), "".into()).unwrap(); + assert!(bad.expand(&frontend, &[], &ProcessedImages::default()).is_err()); + } } diff --git a/helios/src/model.rs b/helios/src/model.rs index 601a298fb..58fe0314d 100644 --- a/helios/src/model.rs +++ b/helios/src/model.rs @@ -50,6 +50,9 @@ pub struct VisionCapabilities { pub max_images: usize, pub patches_per_feature: usize, pub patch_capacities: Vec, + /// Float32 elements per vision patch; zero inherits the layout's legacy width. + #[cfg_attr(any(feature = "frontend", feature = "runtime-core"), serde(default))] + pub patch_features: usize, } impl VisionCapabilities { @@ -60,6 +63,7 @@ impl VisionCapabilities { max_images: 0, patches_per_feature: 0, patch_capacities: Vec::new(), + patch_features: 0, } } @@ -67,6 +71,16 @@ impl VisionCapabilities { self.max_images > 0 } + /// Per-patch float width for `ImageLayoutKind::Bracketed`; `0` inherits the legacy + /// temporal-merge width (`3 * 2 * 14² = 1176`). + pub fn bracketed_patch_features(&self) -> usize { + if self.patch_features != 0 { + self.patch_features + } else { + 1176 + } + } + pub fn validate(&self) -> Result<()> { if self == &Self::disabled() { return Ok(()); @@ -74,6 +88,7 @@ impl VisionCapabilities { if self.feature_slots == 0 || self.feature_slots > crate::execution::REQUEST_LANES || self.patches_per_feature == 0 + || !self.patch_features.is_multiple_of(3) || self.max_images == 0 || self.features_per_request == 0 || self.patch_capacities.is_empty() diff --git a/helios/src/model/contract.rs b/helios/src/model/contract.rs index 09a80d0cb..13f8097fe 100644 --- a/helios/src/model/contract.rs +++ b/helios/src/model/contract.rs @@ -66,7 +66,7 @@ contract_enum!(InputIndexing { Scalar = 1, SubmissionRow = 2, RequestRow = 3, Pa contract_enum!(StateAccessKind { Read = 1, Write = 2, ReadWrite = 3 }); contract_enum!(ToolParserKind { QwenCoder = 1, GlmArgumentTags = 2, Dsml = 3, Xtml = 4, MiniMaxXml = 5, GemmaCall = 6, Atem = 7, TmlJson = 8, TaggedJson = 9 }); contract_enum!(ReasoningParserKind { ThinkTags = 1, XtmlThink = 2, MmThink = 3, ChannelThought = 4, RecipientHeaders = 5, ContentHeaders = 6 }); -contract_enum!(ImagePreparationKind { Qwen = 1, Mimo = 2, Deepseek = 3, Moonvit = 4, Step = 5, Radio = 6, DeepseekRowMajor = 7, Glm = 8, PatchMerge = 9, PaddedGrid = 10 }); +contract_enum!(ImagePreparationKind { Qwen = 1, Mimo = 2, Deepseek = 3, Moonvit = 4, Step = 5, Radio = 6, DeepseekRowMajor = 7, Glm = 8, PatchMerge = 9, PaddedGrid = 10, Gemma4 = 11 }); contract_enum!(ImageLayoutKind { Qwen = 1, Mimo = 2, Deepseek = 3, Moonvit = 4, Step = 5, Radio = 6, DeepseekRowMajor = 7, Glm = 8, Bracketed = 9, ClassToken = 10 }); contract_enum!(GraphOperation { Init = 1, Restore = 2, Snapshot = 3, Prefill = 4, Decode = 5, Resume = 6, Vision = 7, Speculative = 8, Mixed = 9, ScoredPrefill = 12, TerminalPrefill = 14 }); diff --git a/helios/src/model/packing.rs b/helios/src/model/packing.rs index 217909f76..077ea22a7 100644 --- a/helios/src/model/packing.rs +++ b/helios/src/model/packing.rs @@ -81,6 +81,7 @@ impl Inputs { .ok_or("image tensor has no prepared layout")?; let (dtype, minimum) = crate::frontend::images::packing::tensor_layout( layout, + &config.contract.vision, &binding.tensor, graph.token_capacity, )?; diff --git a/helios/src/model/prompt.rs b/helios/src/model/prompt.rs index 377fc0945..db7dc3120 100644 --- a/helios/src/model/prompt.rs +++ b/helios/src/model/prompt.rs @@ -51,7 +51,17 @@ pub fn prepare_image_inputs( } let mut prepared = match config.contract.frontend.image_layout { Some(ImageLayoutKind::Bracketed) => crate::frontend::images::layouts::bracketed::prepare_input( - frontend, processor, rendered, &images, + frontend, + processor, + rendered, + &images, + config + .contract + .frontend + .image_tokens + .as_ref() + .and_then(|layout| layout.span.as_ref()) + .is_some(), )?, Some(ImageLayoutKind::Glm) => crate::frontend::images::layouts::glm::prepare_input( frontend, processor, rendered, &images, @@ -406,6 +416,7 @@ mod tests { "<|deepseek_image|>", "<|media_pad|>", "<|media_begin|>", "<|media_content|>", "<|media_end|>", "", "", "", "", "", "", "", "", "", + "<|image|>", "<|image>", "", "<|start|>", "<|message|>", "<|eom|>", "<|eot|>", ].map(|text| tokenizers::AddedToken::from(text, true))).unwrap(); let asset = |name: &str, bytes: &[u8]| { @@ -455,6 +466,7 @@ mod tests { config.contract.vision = crate::model::VisionCapabilities { feature_slots: 4, features_per_request: geometry.tokens, max_images: 1, patches_per_feature: merge, patch_capacities: vec![geometry.patches], + patch_features: 0, }; let syntax = &mut config.contract.frontend; syntax.image_layout = Some(layout); @@ -1155,4 +1167,117 @@ mod tests { assert_eq!(actual, expected, "{ranges:?}"); } } + + #[test] + fn bracketed_layout_emits_atomic_spans_only_when_contract_declares_them() { + use crate::frontend::images::{Gemma4ImageSettings, ImageLimits, ImageSettings}; + use crate::model::contract::{ImageSpan, ImageTokenLayout}; + let frontend = image_frontend(); + let token = |text: &str| frontend.encode(text, false).unwrap()[0]; + let image_token = token("<|image|>"); + let start_token = token("<|image>"); + let end_token = token(""); + let processor = ImageProcessor::load( + ImageSettings::Gemma4(Gemma4ImageSettings { + patch_size: 16, + pooling_kernel_size: 3, + max_soft_tokens: 280, + image_token: "<|image|>".into(), + start_token: "<|image>".into(), + end_token: "".into(), + }), + ImageLimits { + max_patches_per_image: 2520, + max_total_patches: 5040, + patches_per_feature: 9, + ..ImageLimits::default() + }, + ) + .unwrap(); + let image = RgbImage::new(91, 37, vec![128; 91 * 37 * 3]).unwrap(); + // 91x37 under max_soft_tokens=280 resizes to 260 soft tokens (262-token envelope). + let text = "Compare <|image|> and <|image|>".to_string(); + let rendered = RenderedPrompt { + token_ids: frontend.encode(&text, false).unwrap(), + message_boundaries: vec![], + text, + image_sources: vec![], + image_checkpoint_hints: vec![], + ordinary: vec![], + }; + let mut config = super::super::tests::config(); + config.limits.max_sequence_tokens = 4096; + config.limits.prefill_chunk_size = 512; + config.contract.vocabulary = 1000; + config.contract.input_vocabulary = 1000; + config.contract.vision = crate::model::VisionCapabilities { + feature_slots: 4, + features_per_request: 560, + max_images: 2, + patches_per_feature: 9, + patch_capacities: vec![2520, 5040], + patch_features: 768, + }; + config.contract.frontend.image_layout = Some(ImageLayoutKind::Bracketed); + config.contract.frontend.position_dimensions = 0; + config.contract.frontend.rejected_tokens.clear(); + config.contract.frontend.image_tokens = Some(ImageTokenLayout { + feature_token: image_token, + span: Some(ImageSpan { + start_token, + end_token, + max_tokens: 282, + interior_tokens: vec![], + unscoped_tokens: vec![], + }), + }); + + let prepared = prepare_input( + &config, + &frontend, + Some(&processor), + &rendered, + vec![image.clone(), image.clone()], + ) + .unwrap(); + assert_eq!(prepared.data.spans.len(), 2); + for (span, input) in prepared.data.spans.iter().zip(&prepared.conditioned_inputs) { + assert_eq!(span, &input.token_span); + assert_eq!(span.len(), 262); + assert_eq!(prepared.tokens[span.start], start_token); + assert_eq!(prepared.tokens[span.end - 1], end_token); + assert!( + prepared.tokens[span.start + 1..span.end - 1] + .iter() + .all(|id| *id == image_token) + ); + } + + // A valid 64-aligned chunk size smaller than the 262-token span is rejected. + let mut small_chunk = config.clone(); + small_chunk.limits.prefill_chunk_size = 256; + assert!( + prepare_input( + &small_chunk, + &frontend, + Some(&processor), + &rendered, + vec![image.clone(), image.clone()], + ) + .is_err() + ); + + // Without declared atomic spans (e.g. MiniMax), Bracketed leaves data.spans empty. + let mut no_spans = config; + no_spans.contract.frontend.image_tokens.as_mut().unwrap().span = None; + let prepared = prepare_input( + &no_spans, + &frontend, + Some(&processor), + &rendered, + vec![image.clone(), image], + ) + .unwrap(); + assert!(prepared.data.spans.is_empty()); + } } diff --git a/helios/src/model/tests.rs b/helios/src/model/tests.rs index 96e7b3bfb..2a72198f0 100644 --- a/helios/src/model/tests.rs +++ b/helios/src/model/tests.rs @@ -1602,6 +1602,184 @@ fn vision_upload_selects_source_image_independently_of_destination_feature_offse } } +#[cfg(feature = "images")] +#[test] +fn legacy_bracketed_core_omitting_patch_features_loads_and_stages_1176_wide_pixels() { + use crate::execution::{BufferDescriptor, Dtype, GraphDescriptor, GraphKind, InputBinding, SamplingMode}; + use crate::frontend::images::{ImageGeometry, ProcessedImages}; + use crate::model::contract::{ + GraphContract, GraphOperation, ImageLayoutKind, ImagePreparationKind, ImageTokenLayout, + InputIndexing, PreparedContract, ValueBinding, ValueSource, + }; + + let base_config = config(); + let mut base_manifest = manifest(&base_config); + let mut contract = base_config.contract.clone(); + contract.vision = VisionCapabilities { + feature_slots: 1, + features_per_request: 4, + max_images: 1, + patches_per_feature: 4, + patch_capacities: vec![16], + patch_features: 0, + }; + contract.frontend.image_layout = Some(ImageLayoutKind::Bracketed); + contract.frontend.image_preparation = Some(ImagePreparationKind::PatchMerge); + contract.frontend.image_tokens = Some(ImageTokenLayout { + feature_token: 42, + span: None, + }); + let scalar_binding = |name: &str, source: ValueSource, tensor: &str| ValueBinding { + buffer: name.into(), + source, + indexing: InputIndexing::Scalar, + value_offset: 0, + padding: 0, + tensor: tensor.into(), + parameter: String::new(), + }; + contract.graphs.push(GraphContract { + graph: "vision-1-16".into(), + kind: GraphOperation::Vision, + state_rows_per_request: 1, + inputs: vec![ + scalar_binding("vision_slot", ValueSource::RequestSlot, ""), + scalar_binding("vision_generation", ValueSource::RequestGeneration, ""), + scalar_binding("vision_feature_slot", ValueSource::ImageFeatureSlot, ""), + scalar_binding("vision_pixel_values", ValueSource::ImageTensor, "vision_pixel_values"), + scalar_binding("vision_position_ids", ValueSource::ImageTensor, "vision_position_ids"), + scalar_binding("vision_cu_seqlens", ValueSource::ImageTensor, "vision_cu_seqlens"), + scalar_binding("vision_num_patches", ValueSource::ImageTensor, "vision_num_patches"), + scalar_binding("vision_num_features", ValueSource::ImageTensor, "vision_num_features"), + scalar_binding("vision_feature_offset", ValueSource::ImageTensor, "vision_feature_offset"), + ], + state: vec![], + pending_token: None, + draft_cursor: None, + tuned_bindings: vec![], + embedding_tables: vec![], + }); + + // Simulate a legacy core JSON that predates `vision.patch_features`. + let mut json = serde_json::to_value(&contract).unwrap(); + json["vision"].as_object_mut().unwrap().remove("patch_features"); + let decoded: PreparedContract = serde_json::from_value(json).unwrap(); + assert_eq!(decoded.vision.patch_features, 0); + + let mut legacy_config = base_config; + legacy_config.contract = decoded; + + let build_manifest = |pixel_width: usize| { + let mut m = base_manifest.clone(); + let mut address = m + .buffers + .iter() + .map(|b| (b.address + b.nbytes).next_multiple_of(8)) + .max() + .unwrap_or(0x10000); + let mut host = m.input_frame_bytes; + let frame_offset = m.graphs[0].input_bindings[0].clone(); + let seq_offset = m.graphs[0].input_bindings[1].clone(); + let mut bindings = vec![frame_offset, seq_offset]; + for (name, dtype, shape) in [ + ("vision_slot", Dtype::Int64, vec![1]), + ("vision_generation", Dtype::Int64, vec![1]), + ("vision_feature_slot", Dtype::Int32, vec![1]), + ("vision_pixel_values", Dtype::Float32, vec![16, pixel_width]), + ("vision_position_ids", Dtype::Int64, vec![16, 2]), + ("vision_cu_seqlens", Dtype::Int32, vec![2]), + ("vision_num_patches", Dtype::Int32, vec![1]), + ("vision_num_features", Dtype::Int32, vec![1]), + ("vision_feature_offset", Dtype::Int32, vec![1]), + ] { + let nbytes = shape.iter().product::() * dtype.size(); + let mut stride = 1; + let mut strides: Vec<_> = shape + .iter() + .rev() + .map(|n| { + let s = stride; + stride *= n; + s + }) + .collect(); + strides.reverse(); + m.buffers.push(BufferDescriptor { + name: name.into(), + address, + nbytes, + dtype, + shape, + strides, + }); + bindings.push(InputBinding { + buffer_name: name.into(), + host_offset: host, + nbytes, + }); + address += nbytes.next_multiple_of(8); + host += nbytes.next_multiple_of(8); + } + m.input_frame_bytes = host; + m.graphs.push(GraphDescriptor { + name: "vision-1-16".into(), + kind: GraphKind::Vision, + sampling_mode: SamplingMode::General, + handle: 1, + batch_capacity: 1, + token_capacity: 16, + prefill_capacity: 0, + packed_token_capacity: 0, + draft_tokens: 0, + confidence_width: 0, + estimated_duration_ns: 1000, + input_bindings: bindings, + tuned_bindings: vec![], + }); + m + }; + + // Legacy 1176-wide Bracketed core loads cleanly through Inputs::new and stages 16 * 1176 floats. + let legacy_manifest = build_manifest(1176); + assert!(Inputs::new(&legacy_config, &legacy_manifest).is_ok()); + let images = ProcessedImages { + pixel_values: (0..16 * 1176).map(|i| i as f32).collect(), + geometry: vec![ImageGeometry { + height: 56, + width: 56, + grid_thw: [1, 4, 4], + patches: 16, + tokens: 4, + }], + position_ids: (0..16).map(|i| [i % 4, i / 4]).collect(), + interpolation_indices: vec![], + interpolation_weights: vec![], + cu_seqlens: vec![0, 16], + }; + let staged = crate::frontend::images::packing::prepare( + &legacy_config, + crate::scheduler::RequestHandle { slot: 0, generation: 1 }, + &images, + 0, + 0, + ) + .unwrap(); + let pixels = staged + .uploads() + .into_iter() + .find(|u| u.buffer == "vision_pixel_values") + .unwrap(); + assert_eq!(pixels.bytes.len(), 16 * 1176 * 4); + + // Undersized 768-wide buffer or non-square patches_per_feature is rejected at Inputs::new. + assert!(Inputs::new(&legacy_config, &build_manifest(768)).is_err()); + let mut non_square = legacy_config; + non_square.contract.vision.patches_per_feature = 3; + non_square.contract.vision.patch_capacities = vec![15]; + base_manifest = build_manifest(1176); + assert!(Inputs::new(&non_square, &base_manifest).is_err()); +} + fn grammar_packing_fixture() -> ( ModelConfig, crate::execution::ExecutionManifest, diff --git a/helios/src/runtime_core/describe.rs b/helios/src/runtime_core/describe.rs index 56aaf6a83..b02cf1fd5 100644 --- a/helios/src/runtime_core/describe.rs +++ b/helios/src/runtime_core/describe.rs @@ -452,11 +452,13 @@ pub(super) fn vision_json( Profile::Radio(_) => json!({"profile": "radio"}), Profile::PatchMerge(c) => json!({"profile": "patch_merge", "patch_size": c.patch_size, "min_pixels": c.min_pixels, "max_pixels": c.max_pixels}), + Profile::Gemma4(c) => json!({"profile": "gemma4", "patch_size": c.patch_size, + "pooling_kernel_size": c.pooling_kernel_size, "max_soft_tokens": c.max_soft_tokens}), Profile::Glm(_) => json!({"profile": "glm"}), Profile::PaddedGrid(_) => json!({"profile": "padded_grid"}), } }); - json!({ + let mut value = json!({ "feature_slots": vision.feature_slots, "max_image_tokens_per_prompt": context_tokens, "max_images": context_tokens, @@ -464,7 +466,11 @@ pub(super) fn vision_json( "patches_per_feature": vision.patches_per_feature, "patch_capacities": vision.patch_capacities, "image": profile, - }) + }); + if vision.patch_features != 0 { + value["patch_features"] = json!(vision.patch_features); + } + value } fn engram_json(engram: &wire::Engram) -> Value { @@ -1155,6 +1161,7 @@ mod tests { max_images: 0, patches_per_feature: 0, patch_capacities: vec![], + patch_features: 0, }; assert_eq!( vision_json(Some(&disabled), &settings, Some(131072)), @@ -1166,6 +1173,7 @@ mod tests { max_images: 4096, patches_per_feature: 9, patch_capacities: vec![3456], + patch_features: 0, }; let value = vision_json(Some(&enabled), &settings, Some(131072)); assert_eq!(value["max_image_tokens_per_prompt"], 131072); diff --git a/helios/src/runtime_core/protobuf.rs b/helios/src/runtime_core/protobuf.rs index 691519645..e4c89bfa5 100644 --- a/helios/src/runtime_core/protobuf.rs +++ b/helios/src/runtime_core/protobuf.rs @@ -190,6 +190,11 @@ pub(super) fn frontend_settings(value: wire::FrontendSettings) -> Result serde_json::json!({"gemma4": { + "patch_size": config.patch_size, "pooling_kernel_size": config.pooling_kernel_size, + "max_soft_tokens": config.max_soft_tokens, + "image_token": config.image_token, "start_token": config.start_token, "end_token": config.end_token, + }}), Profile::DeepseekRowMajor(config) => serde_json::json!({"deepseek_row_major": { "min_pixels": config.min_pixels, "max_tokens": config.max_tokens, "max_width_height_ratio": config.max_width_height_ratio, @@ -829,6 +834,61 @@ mod tests { } } + #[test] + fn serialized_gemma4_profile_selects_only_image_preparation() { + // Field 11 adds the Gemma 4 profile without changing any preceding profile tag. + let encoded = wire::FrontendSettings { + tokenizer: Some(wire::TokenizerSettings::default()), + image: Some(wire::ImageSettings { + profile: Some(wire::image_settings::Profile::Gemma4( + wire::Gemma4ImageSettings { + patch_size: 16, + pooling_kernel_size: 3, + max_soft_tokens: 280, + image_token: "<|image|>".into(), + start_token: "<|image>".into(), + end_token: "".into(), + }, + )), + }), + eos_token_ids: vec![1], + ..Default::default() + } + .encode_to_vec(); + let decoded = wire::FrontendSettings::decode(encoded.as_slice()).unwrap(); + let json = frontend_settings(decoded).unwrap(); + assert_eq!( + json["image"], + serde_json::json!({"gemma4": { + "patch_size": 16, + "pooling_kernel_size": 3, + "max_soft_tokens": 280, + "image_token": "<|image|>", + "start_token": "<|image>", + "end_token": "", + }}) + ); + assert_eq!(json["prompt_encoder"], 0); + #[cfg(feature = "server")] + { + let frontend: crate::frontend::FrontendSettings = serde_json::from_value(json).unwrap(); + let settings = frontend.image.unwrap(); + assert_eq!( + settings.preparation_kind(), + crate::model::contract::ImagePreparationKind::Gemma4 + ); + let processor = crate::frontend::images::ImageProcessor::load( + settings, + crate::frontend::images::ImageLimits { + patches_per_feature: 9, + ..Default::default() + }, + ) + .unwrap(); + assert_eq!(processor.geometry(672, 672).unwrap().tokens, 256); + } + } + #[test] fn prompt_encoder_round_trip_preserves_explicit_image_token_and_rejects_unknown_encoder() { for encoder in [1, 2, 3] { diff --git a/helios/src/scheduler/boundary_tests.rs b/helios/src/scheduler/boundary_tests.rs index 590d95a7b..75f8ef492 100644 --- a/helios/src/scheduler/boundary_tests.rs +++ b/helios/src/scheduler/boundary_tests.rs @@ -63,6 +63,7 @@ fn scheduler_with_concurrency(snapshots: u32, mtp: bool, page_tokens: usize, act max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16384], + patch_features: 0, }, draft_pages_per_request: 1, completion_inputs: vec![], diff --git a/helios/src/scheduler/cache_memory.rs b/helios/src/scheduler/cache_memory.rs index 503930bc9..eab9c1e73 100644 --- a/helios/src/scheduler/cache_memory.rs +++ b/helios/src/scheduler/cache_memory.rs @@ -1557,6 +1557,7 @@ mod tests { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16384], + patch_features: 0, }, draft_pages_per_request: 1, completion_inputs: vec![], diff --git a/helios/src/scheduler/tests.rs b/helios/src/scheduler/tests.rs index 6f1c39f67..bdee9579d 100644 --- a/helios/src/scheduler/tests.rs +++ b/helios/src/scheduler/tests.rs @@ -141,6 +141,7 @@ fn scheduler_with_geometry(active: usize, pages: u32, snapshots: u32, page_token max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16384], + patch_features: 0, }, draft_pages_per_request: 1, completion_inputs: vec![], @@ -601,6 +602,7 @@ fn configured_prefill_chunks_and_tails_preserve_alignment_and_live_page_extents( max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16384], + patch_features: 0, }, draft_pages_per_request: 1, completion_inputs: vec![], @@ -681,6 +683,7 @@ fn invalid_prefill_limits_reject_before_request_resources_are_created() { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16384], + patch_features: 0, }, draft_pages_per_request: 1, completion_inputs: vec![], @@ -2400,6 +2403,7 @@ fn declared_model_capabilities_drive_state_slots_and_vision_buckets() { max_images: 2, patches_per_feature: 2, patch_capacities: vec![8, 32], + patch_features: 0, }, draft_pages_per_request: 1, completion_inputs: vec![], diff --git a/helios/src/scheduler/vision_window_tests.rs b/helios/src/scheduler/vision_window_tests.rs index 1df43d04f..94f1e6d90 100644 --- a/helios/src/scheduler/vision_window_tests.rs +++ b/helios/src/scheduler/vision_window_tests.rs @@ -40,6 +40,7 @@ fn scheduler_with_resources( max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16_384], + patch_features: 0, }, draft_pages_per_request: 1, completion_inputs: vec![], diff --git a/helios/src/server/config.rs b/helios/src/server/config.rs index 6b0467379..8c50ba4e4 100644 --- a/helios/src/server/config.rs +++ b/helios/src/server/config.rs @@ -276,12 +276,14 @@ impl Bootstrap { return Err("image preparation identifier differs from its settings".into()); } let images = if model.contract.vision.enabled() { - Some(ImageProcessor::load( + let processor = ImageProcessor::load( frontend_settings .image .ok_or("vision requires prepared image settings")?, image_limits(&model.contract.vision, model.limits.max_sequence_tokens)?, - )?) + )?; + validate_loaded_image_processor(&model, &processor)?; + Some(processor) } else { if frontend_settings.image.is_some() { return Err("text-only model must not declare image settings".into()); @@ -426,6 +428,54 @@ impl ServerConfig { } } +pub(crate) fn validate_loaded_image_processor( + model: &ModelConfig, + processor: &ImageProcessor, +) -> Result<()> { + let vision = &model.contract.vision; + let width = processor.patch_features(); + if model.contract.frontend.image_layout == Some(crate::model::contract::ImageLayoutKind::Bracketed) { + let expected = vision.bracketed_patch_features(); + if width != expected { + return Err(format!( + "bracketed image layout patch width ({expected}) differs from image processor ({width}); re-export the core with vision.patch_features" + ) + .into()); + } + } else if vision.patch_features != 0 && width != vision.patch_features { + return Err(format!( + "image preparation patch width ({width}) differs from prepared vision.patch_features ({})", + vision.patch_features + ) + .into()); + } + if let (Some(span), Some(max_envelope)) = ( + model + .contract + .frontend + .image_tokens + .as_ref() + .and_then(|layout| layout.span.as_ref()), + processor.max_image_envelope_tokens(), + ) { + if max_envelope > model.limits.prefill_chunk_size { + return Err(format!( + "maximum image envelope ({max_envelope} tokens) exceeds prefill_chunk_size ({})", + model.limits.prefill_chunk_size + ) + .into()); + } + if max_envelope > span.max_tokens { + return Err(format!( + "maximum image envelope ({max_envelope} tokens) exceeds declared span max_tokens ({})", + span.max_tokens + ) + .into()); + } + } + Ok(()) +} + pub(crate) fn image_limits(vision: &crate::model::VisionCapabilities, context_tokens: usize) -> Result { ImageLimits::for_vision(vision, context_tokens) } @@ -449,6 +499,7 @@ mod tests { max_images: 4, patches_per_feature: merge, patch_capacities: vec![graph_patches], + patch_features: 0, }; vision.validate().unwrap(); let limits = image_limits(&vision, features * 3).unwrap(); @@ -890,4 +941,93 @@ mod tests { "{error}" ); } + + #[test] + fn loaded_gemma4_image_processor_validates_patch_width_and_envelope_chunk_bounds() { + use crate::{ + frontend::images::Gemma4ImageSettings, + model::contract::{ImageLayoutKind, ImageSpan, ImageTokenLayout}, + }; + + let make_model = |patch_features: usize, prefill_chunk_size: usize, span_max: usize| { + let mut model = + crate::frontend::test_support::model_config(crate::model::testing::metadata()); + model.limits.prefill_chunk_size = prefill_chunk_size; + model.limits.max_sequence_tokens = 8192; + model.limits.validate_prefill().unwrap(); + model.contract.vision = VisionCapabilities { + feature_slots: 1, + features_per_request: 1120, + max_images: 4, + patches_per_feature: 9, + patch_capacities: vec![10_080], + patch_features, + }; + model.contract.vision.validate().unwrap(); + model.contract.frontend.image_layout = Some(ImageLayoutKind::Bracketed); + model.contract.frontend.image_tokens = Some(ImageTokenLayout { + feature_token: 258_880, + span: Some(ImageSpan { + start_token: 255_999, + end_token: 258_882, + max_tokens: span_max, + interior_tokens: vec![], + unscoped_tokens: vec![], + }), + }); + model + }; + let load_gemma4 = |max_soft_tokens: usize| { + ImageProcessor::load( + ImageSettings::Gemma4(Gemma4ImageSettings { + patch_size: 16, + pooling_kernel_size: 3, + max_soft_tokens, + image_token: "<|image|>".into(), + start_token: "<|image>".into(), + end_token: "".into(), + }), + ImageLimits { + patches_per_feature: 9, + max_patches_per_image: 10_080, + max_total_patches: 10_080, + ..ImageLimits::default() + }, + ) + .unwrap() + }; + + let proc_1120 = load_gemma4(1120); + // Valid 64-aligned chunk boundaries around max_envelope = 1122: 1088 fails, 1152 passes. + assert!(validate_loaded_image_processor(&make_model(768, 1152, 1122), &proc_1120).is_ok()); + assert!( + validate_loaded_image_processor(&make_model(768, 1088, 1122), &proc_1120) + .unwrap_err() + .to_string() + .contains("prefill_chunk_size") + ); + // Exact span.max_tokens boundary: 1121 fails, 1122 passes. + assert!( + validate_loaded_image_processor(&make_model(768, 1152, 1121), &proc_1120) + .unwrap_err() + .to_string() + .contains("span max_tokens") + ); + // Missing patch_features (legacy 0 -> 1176) gives an actionable re-export error. + let legacy_err = validate_loaded_image_processor(&make_model(0, 1152, 1122), &proc_1120) + .unwrap_err() + .to_string(); + assert!(legacy_err.contains("re-export"), "{legacy_err}"); + // Explicit mismatched patch_features reports both actual and expected widths. + let mismatch_err = + validate_loaded_image_processor(&make_model(588, 1152, 1122), &proc_1120) + .unwrap_err() + .to_string(); + assert!(mismatch_err.contains("768") && mismatch_err.contains("588"), "{mismatch_err}"); + + let proc_280 = load_gemma4(280); + // Valid 64-aligned chunk boundaries around max_envelope = 282: 256 fails, 320 passes. + assert!(validate_loaded_image_processor(&make_model(768, 320, 282), &proc_280).is_ok()); + assert!(validate_loaded_image_processor(&make_model(768, 256, 282), &proc_280).is_err()); + } } diff --git a/helios/src/server/models.rs b/helios/src/server/models.rs index eeffb0e4b..24a1068f5 100644 --- a/helios/src/server/models.rs +++ b/helios/src/server/models.rs @@ -397,6 +397,7 @@ mod tests { features_per_request: 256, patches_per_feature: 4, patch_capacities: vec![1024], + patch_features: 0, }; let vision = ModelCatalog::new(&model, &[], None).card; assert_eq!(vision["max_model_len"], 4096); @@ -481,6 +482,7 @@ mod tests { features_per_request: 256, patches_per_feature: 4, patch_capacities: vec![1024], + patch_features: 0, }; } model.contract.frontend.tools = tools.then(|| ToolParser { diff --git a/helios/src/server/protocol/decode.rs b/helios/src/server/protocol/decode.rs index bffd0378e..438ddc132 100644 --- a/helios/src/server/protocol/decode.rs +++ b/helios/src/server/protocol/decode.rs @@ -1310,6 +1310,7 @@ mod native_prompt_tests { max_images: 2, patches_per_feature: 4, patch_capacities: vec![geometry.patches], + patch_features: 0, }; config.contract.frontend.image_layout = Some(layout); config.contract.frontend.position_dimensions = if layout == ImageLayoutKind::Qwen { diff --git a/helios/src/server/request.rs b/helios/src/server/request.rs index bde28ab42..6f8af53bc 100644 --- a/helios/src/server/request.rs +++ b/helios/src/server/request.rs @@ -830,7 +830,8 @@ mod tests { let geometry = initial.geometry(1075, 1521).unwrap(); let vision = crate::model::VisionCapabilities { feature_slots: 1, max_images: 1, features_per_request: geometry.tokens, patches_per_feature: 9, - patch_capacities: vec![geometry.patches] }; + patch_capacities: vec![geometry.patches], + patch_features: 0, }; let context = 2 * geometry.tokens + 64; let limits = crate::server::config::image_limits(&vision, context).unwrap(); let processor = ImageProcessor::load(ImageSettings::Deepseek4 {}, limits).unwrap(); diff --git a/helios/src/server/request/tml_tests.rs b/helios/src/server/request/tml_tests.rs index 562af5523..edb3c6be0 100644 --- a/helios/src/server/request/tml_tests.rs +++ b/helios/src/server/request/tml_tests.rs @@ -279,6 +279,7 @@ fn images_preserve_reference_order_feature_spans_and_message_endpoints() { inkling.config.contract.vision = crate::model::VisionCapabilities { feature_slots: 4, max_images: 4, features_per_request: 16384, patches_per_feature: 4, patch_capacities: vec![65536], + patch_features: 0, }; let processor = ImageProcessor::load(ImageSettings::PaddedGrid {}, ImageLimits { max_images: 4, max_patches_per_image: 65536, max_total_patches: 65536, diff --git a/helios/src/server/runtime.rs b/helios/src/server/runtime.rs index 94297c958..106d53d45 100644 --- a/helios/src/server/runtime.rs +++ b/helios/src/server/runtime.rs @@ -3484,6 +3484,7 @@ mod tests { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16384], + patch_features: 0, }, draft_pages_per_request: 1, @@ -4261,6 +4262,7 @@ mod tests { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256, 1024, 4096, 16384], + patch_features: 0, }, draft_pages_per_request: 1, diff --git a/helios/src/server/runtime/phase_tests.rs b/helios/src/server/runtime/phase_tests.rs index 97779767f..8857bfac7 100644 --- a/helios/src/server/runtime/phase_tests.rs +++ b/helios/src/server/runtime/phase_tests.rs @@ -281,6 +281,7 @@ fn image_admission_queues_excess_images_and_admits_text() { max_images: 1, patches_per_feature: 4, patch_capacities: vec![256], + patch_features: 0, }; let vision_contract: crate::model::contract::PreparedContract = serde_json::from_str(include_str!("../../../tests/support/contracts/qwen38.json")).unwrap(); @@ -5748,6 +5749,7 @@ fn host_prefix_selects_whole_required_images_and_compacts_feature_indices() { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256], + patch_features: 0, }; fixture.config.contract.frontend = serde_json::from_str::(include_str!( @@ -5814,6 +5816,7 @@ fn failed_host_restore_replans_all_images_from_the_shallower_prefix() { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256], + patch_features: 0, }; fixture.config.contract.frontend = serde_json::from_str::(include_str!( @@ -5882,6 +5885,7 @@ fn image_materialization_failure_retires_only_its_request() { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256], + patch_features: 0, }; fixture.config.contract.frontend = serde_json::from_str::(include_str!( @@ -5929,6 +5933,7 @@ fn prepared_image_window_stays_global_until_pack_or_cancellation() { max_images: 4, patches_per_feature: 4, patch_capacities: vec![256], + patch_features: 0, }; fixture.config.contract.frontend = serde_json::from_str::( include_str!("../../../tests/support/contracts/qwen38.json"), @@ -5995,6 +6000,7 @@ fn park_and_device_error_teardown_release_prepared_image_slot_for_next_request() max_images: 4, patches_per_feature: 4, patch_capacities: vec![256], + patch_features: 0, }; fixture.config.contract.frontend = serde_json::from_str::( include_str!("../../../tests/support/contracts/qwen38.json"), @@ -6192,6 +6198,7 @@ fn worker_restores_conditioned_windows_with_fresh_generation_and_unchanged_sampl max_images: 4, patches_per_feature: 4, patch_capacities: vec![256], + patch_features: 0, }; fixture.config.contract.frontend = serde_json::from_str::( include_str!("../../../tests/support/contracts/qwen38.json"), diff --git a/helios/tests/deepseek_requests.rs b/helios/tests/deepseek_requests.rs index ddcec058c..6a752293d 100644 --- a/helios/tests/deepseek_requests.rs +++ b/helios/tests/deepseek_requests.rs @@ -545,6 +545,7 @@ fn base64_images_follow_the_rendered_placeholder_order() { max_images: 4, patches_per_feature: 9, patch_capacities: vec![576, 1152, 2304, 4608, 9216], + patch_features: 0, }; let syntax = &mut f.config.contract.frontend; syntax.image_preparation = Some(ImagePreparationKind::DeepseekRowMajor); diff --git a/ignition/preparation/contract.py b/ignition/preparation/contract.py index 4ef4d79ca..c9b59b1cf 100644 --- a/ignition/preparation/contract.py +++ b/ignition/preparation/contract.py @@ -156,8 +156,14 @@ def core_parameter(name, default, *, minimum=None, maximum=None): def model_contract(*, vocabulary, input_vocabulary=None, vision=None, page_tokens, page_tables, graphs, frontend, regions, codec_layout=None, core_parameters=()): + """Build a version-3 `ModelContract` dict. + + `Bracketed` vision recipes whose per-patch float width differs from the legacy `1176` + default (for example `768` for Gemma 4) must set `vision["patch_features"]`. + """ result = dict(version=3, vocabulary=vocabulary, input_vocabulary=input_vocabulary or vocabulary, - vision={"feature_slots": 0, **(vision or dict(features_per_request=0, max_images=0, patches_per_feature=0, patch_capacities=[]))}, + vision={"feature_slots": 0, "patch_features": 0, + **(vision or dict(features_per_request=0, max_images=0, patches_per_feature=0, patch_capacities=[]))}, cache=dict(page_tokens=page_tokens, page_tables=page_tables, regions=regions, **({"codec_layout": codec_layout} if codec_layout else {})), graphs=graphs, frontend=frontend) if core_parameters: diff --git a/ignition/preparation/frontend.py b/ignition/preparation/frontend.py index 4cd348d2c..ce42f3ac0 100644 --- a/ignition/preparation/frontend.py +++ b/ignition/preparation/frontend.py @@ -32,6 +32,7 @@ class PromptEncoder(IntEnum): "deepseek4", "qwen", "mimo", + "gemma4", }) _EMPTY_IMAGE_PROFILES = frozenset({"padded_grid", "glm", "radio", "moonvit", "deepseek4"}) @@ -199,6 +200,40 @@ def _validate_image_payload(profile: str, payload: Mapping[str, Any]) -> dict[st raise ValueError(f"unsupported image processor {key}") result[key] = [float(v) for v in values] return result + if profile == "gemma4": + expected_keys = { + "patch_size", + "pooling_kernel_size", + "max_soft_tokens", + "image_token", + "start_token", + "end_token", + } + if set(payload) != expected_keys: + raise ValueError("unsupported gemma4 image payload fields") + patch_size = payload["patch_size"] + if type(patch_size) is not int or not 1 <= patch_size <= 64: + raise ValueError("unsupported image processor patch_size") + pooling_kernel_size = payload["pooling_kernel_size"] + if type(pooling_kernel_size) is not int or not 1 <= pooling_kernel_size <= 16: + raise ValueError("unsupported image processor pooling_kernel_size") + max_soft_tokens = payload["max_soft_tokens"] + if type(max_soft_tokens) is not int or max_soft_tokens not in (70, 140, 280, 560, 1120): + raise ValueError("unsupported image processor max_soft_tokens") + tokens = {} + for key in ("image_token", "start_token", "end_token"): + value = payload[key] + if not isinstance(value, str) or not value: + raise ValueError(f"unsupported image processor {key}") + tokens[key] = value + if len(set(tokens.values())) != 3: + raise ValueError("image envelope tokens must be distinct") + return { + "patch_size": patch_size, + "pooling_kernel_size": pooling_kernel_size, + "max_soft_tokens": max_soft_tokens, + **tokens, + } raise ValueError("unsupported image preprocessing profile") diff --git a/ignition/preparation/runtime_core_pb2.py b/ignition/preparation/runtime_core_pb2.py index 14dbfe4eb..264473336 100644 --- a/ignition/preparation/runtime_core_pb2.py +++ b/ignition/preparation/runtime_core_pb2.py @@ -24,7 +24,7 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12runtime_core.proto\x12\rflare.runtime\"\x99\x01\n\x0eProtectedIndex\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x0f\n\x07\x63ore_id\x18\x02 \x01(\x0c\x12\x0e\n\x06signer\x18\x03 \x01(\x0c\x12*\n\x06groups\x18\x04 \x03(\x0b\x32\x1a.flare.runtime.SignedGroup\x12)\n\x05ranks\x18\x05 \x03(\x0b\x32\x1a.flare.runtime.SignedGroup\"<\n\x0bSignedGroup\x12\x0c\n\x04kind\x18\x01 \x01(\r\x12\x0c\n\x04\x62ody\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\"\xcc\x01\n\x11PublisherMetadata\x12(\n\x05index\x18\x01 \x01(\x0b\x32\x19.flare.runtime.ModelIndex\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x17\n\x0fofficial_source\x18\x03 \x01(\t\x12\x14\n\x0cgroup_hashes\x18\x04 \x03(\x0c\x12\x13\n\x0b\x64\x65velopment\x18\x05 \x01(\x08\x12\r\n\x05ranks\x18\x06 \x01(\r\x12\'\n\x07license\x18\x07 \x01(\x0b\x32\x16.flare.runtime.License\"%\n\x07License\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04link\x18\x02 \x01(\t\"F\n\x0fResourceCatalog\x12\x33\n\tresources\x18\x01 \x03(\x0b\x32 .flare.runtime.ProtectedResource\"^\n\x11ProtectedResource\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12\x14\n\x0cstored_bytes\x18\x02 \x01(\x04\x12\x13\n\x0bplain_bytes\x18\x03 \x01(\x04\x12\x0e\n\x06sha256\x18\x04 \x03(\x0c\"`\n\nStoredData\x12\x0e\n\x06nbytes\x18\x01 \x01(\x04\x12\x0e\n\x06sha256\x18\x02 \x01(\x0c\x12\x0e\n\x06offset\x18\x03 \x01(\x04\x12\"\n\x05parts\x18\x04 \x03(\x0b\x32\x13.flare.runtime.Span\"\xd9\x01\n\x0eRankProtection\x12\x0c\n\x04rank\x18\x01 \x01(\r\x12*\n\x06\x62undle\x18\x02 \x01(\x0b\x32\x1a.flare.runtime.BundleIndex\x12\x33\n\x0b\x65xecutables\x18\x03 \x01(\x0b\x32\x1e.flare.runtime.ResourceCatalog\x12/\n\x07support\x18\x04 \x01(\x0b\x32\x1e.flare.runtime.ResourceCatalog\x12\'\n\x04\x64\x61ta\x18\x05 \x01(\x0b\x32\x19.flare.runtime.StoredData\"\x8c\x04\n\nModelIndex\x12\x0f\n\x07version\x18\x01 \x01(\r\x12)\n\x05ranks\x18\x02 \x03(\x0b\x32\x1a.flare.runtime.BundleIndex\x12.\n\x0bpeer_memory\x18\x03 \x03(\x0b\x32\x19.flare.runtime.PeerMemory\x12$\n\x06\x61ssets\x18\x05 \x03(\x0b\x32\x14.flare.runtime.Asset\x12%\n\x06\x65ngram\x18\x06 \x01(\x0b\x32\x15.flare.runtime.Engram\x12\x43\n\x11sampling_defaults\x18\x07 \x01(\x0b\x32(.flare.runtime.DefaultSamplingParameters\x12\x31\n\x08\x66rontend\x18\x08 \x01(\x0b\x32\x1f.flare.runtime.FrontendSettings\x12\'\n\x07\x63luster\x18\t \x01(\x0b\x32\x16.flare.runtime.Cluster\x12\x30\n\x08\x63ontract\x18\n \x01(\x0b\x32\x1e.flare.runtime.ServingContract\x12\x33\n\x07rebuild\x18\x0b \x01(\x0b\x32\x1e.flare.runtime.RebuildManifestB\x02\x18\x01\x12\x37\n\x0bpreparation\x18\x0c \x01(\x0b\x32\".flare.runtime.PreparationManifestJ\x04\x08\x04\x10\x05\"\xf9\x01\n\x13PreparationManifest\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x0e\n\x06recipe\x18\x02 \x01(\t\x12\x17\n\x0fsource_identity\x18\x03 \x01(\t\x12\x1d\n\x15\x63heckpoint_repository\x18\x04 \x01(\t\x12\x1b\n\x13\x63heckpoint_revision\x18\x05 \x01(\t\x12\x18\n\x10local_checkpoint\x18\x06 \x01(\x08\x12\x19\n\x11reproduction_args\x18\x07 \x03(\t\x12\x37\n\nparameters\x18\x08 \x03(\x0b\x32#.flare.runtime.PreparationParameter\"\x8c\x01\n\x14PreparationParameter\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x37\n\x05scope\x18\x02 \x01(\x0e\x32(.flare.runtime.PreparationParameterScope\x12.\n\x05value\x18\x03 \x01(\x0b\x32\x1f.flare.runtime.PreparationValue\"\xc6\x01\n\x10PreparationValue\x12\x14\n\nbool_value\x18\x01 \x01(\x08H\x00\x12\x13\n\tint_value\x18\x02 \x01(\x03H\x00\x12\x14\n\nuint_value\x18\x03 \x01(\x04H\x00\x12\x15\n\x0b\x66loat_value\x18\x04 \x01(\x01H\x00\x12\x16\n\x0cstring_value\x18\x05 \x01(\tH\x00\x12\x39\n\nlist_value\x18\x06 \x01(\x0b\x32#.flare.runtime.PreparationValueListH\x00\x42\x07\n\x05value\"G\n\x14PreparationValueList\x12/\n\x06values\x18\x01 \x03(\x0b\x32\x1f.flare.runtime.PreparationValue\"\xdb\x07\n\x0fRebuildManifest\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x0e\n\x06recipe\x18\x02 \x01(\t\x12\x17\n\x0fsource_identity\x18\x03 \x01(\t\x12\x1d\n\x15\x63heckpoint_repository\x18\x04 \x01(\t\x12\x1b\n\x13\x63heckpoint_revision\x18\x05 \x01(\t\x12\x17\n\x0ftensor_parallel\x18\x06 \x01(\r\x12\x17\n\x0fmax_concurrency\x18\x07 \x01(\x04\x12\x15\n\rprefill_chunk\x18\x08 \x01(\x04\x12\x19\n\x11image_concurrency\x18\t \x01(\x04\x12\x18\n\x10\x63ontext_parallel\x18\n \x01(\x08\x12\x16\n\x0estream_overlap\x18\x0b \x01(\x08\x12\x15\n\rmixed_prefill\x18\x0c \x01(\x08\x12%\n\x18\x65xpert_scale_compression\x18\r \x01(\tH\x00\x88\x01\x01\x12\x18\n\x10mla_compute_mode\x18\x0e \x01(\t\x12\x11\n\troce_ring\x18\x0f \x01(\x08\x12\x14\n\x0conline_mxfp8\x18\x10 \x01(\x08\x12\x1b\n\x13language_model_only\x18\x11 \x01(\x08\x12\x36\n\x0bspeculation\x18\x12 \x01(\x0b\x32!.flare.runtime.RebuildSpeculation\x12\x19\n\x11\x63ompiled_forwards\x18\x13 \x01(\x08\x12\x15\n\rreserve_bytes\x18\x14 \x01(\x04\x12\x18\n\x10local_checkpoint\x18\x15 \x01(\x08\x12\x12\n\nroce_chain\x18\x16 \x01(\x08\x12\x1e\n\x16shard_hyperconnections\x18\x18 \x01(\x08\x12\x1c\n\x14\x66orce_moe_decode_a16\x18\x1b \x01(\x08\x12\x19\n\x11row_shard_prefill\x18\x1c \x01(\x08\x12\x1a\n\x12online_mxfp8_scope\x18\x1e \x01(\t\x12\x1d\n\x15\x63ontext_parallel_size\x18\x1f \x01(\r\x12\x17\n\x0fprompt_logprobs\x18 \x01(\x08\x12\x17\n\x0f\x61utotune_effort\x18! \x01(\t\x12 \n\x18native_dense_activations\x18\" \x01(\x08\x12\x17\n\x0flock_gpu_clocks\x18# \x01(\x08\x12\x19\n\x11reproduction_args\x18$ \x03(\t:\x02\x18\x01\x42\x1b\n\x19_expert_scale_compressionJ\x04\x08\x17\x10\x18J\x04\x08\x19\x10\x1aJ\x04\x08\x1a\x10\x1bR\x0cjoint_tuningR\x11\x63ollective_tuningR\x16\x63ollective_ladder_json\"\x82\x04\n\x12RebuildSpeculation\x12\x14\n\x0c\x64raft_tokens\x18\x01 \x01(\r\x12\x10\n\x08\x61\x64\x61ptive\x18\x02 \x01(\x08\x12\x17\n\x0fproposal_source\x18\x03 \x01(\t\x12\x16\n\x0ehistory_drafts\x18\x04 \x01(\x08\x12\x16\n\x0etoken_capacity\x18\x05 \x01(\x04\x12\x1b\n\x13packed_verification\x18\x06 \x01(\x08\x12\x1e\n\x16\x64raft_prefix_selection\x18\x07 \x01(\t\x12$\n\x17\x64raft_head_quantization\x18\x08 \x01(\tH\x00\x88\x01\x01\x12%\n\x18markov_head_quantization\x18\t \x01(\tH\x01\x88\x01\x01\x12\x19\n\x0cgraph_budget\x18\n \x01(\x04H\x02\x88\x01\x01\x12$\n\x1cvocabulary_parallel_sampling\x18\x0b \x01(\x08\x12\x0e\n\x06method\x18\x0c \x01(\t\x12\x10\n\x08mtp_only\x18\r \x01(\x08\x12$\n\x17\x64raft_body_quantization\x18\x0e \x01(\tH\x03\x88\x01\x01:\x02\x18\x01\x42\x1a\n\x18_draft_head_quantizationB\x1b\n\x19_markov_head_quantizationB\x0f\n\r_graph_budgetB\x1a\n\x18_draft_body_quantization\"e\n\x0eRebuildWeights\x12\x0f\n\x07version\x18\x01 \x01(\r\x12-\n\x07tensors\x18\x02 \x03(\x0b\x32\x1c.flare.runtime.RebuildTensor\x12\x13\n\x0bunavailable\x18\x03 \x03(\t\"\xa2\x01\n\rRebuildTensor\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05\x64type\x18\x02 \x01(\t\x12\x15\n\relement_bytes\x18\x03 \x01(\r\x12\r\n\x05shape\x18\x04 \x03(\x04\x12\x0e\n\x06stride\x18\x05 \x03(\x04\x12\x13\n\x0blayout_type\x18\x06 \x01(\t\x12)\n\x07storage\x18\x07 \x01(\x0b\x32\x18.flare.runtime.Reference\"\xcb\x06\n\x0fServingContract\x12\x10\n\x08model_id\x18\x01 \x01(\t\x12\x10\n\x08identity\x18\x02 \x01(\t\x12\x34\n\x0emodel_contract\x18\x03 \x01(\x0b\x32\x1c.flare.runtime.ModelContract\x12\x1b\n\x13max_sequence_tokens\x18\x04 \x01(\x04\x12\x1a\n\x12prefill_chunk_size\x18\x05 \x01(\x04\x12\r\n\x05pages\x18\x06 \x01(\x04\x12\x12\n\nstate_rows\x18\x07 \x01(\x04\x12\x11\n\tsnapshots\x18\x08 \x01(\x04\x12\x13\n\x0bpage_tokens\x18\t \x01(\x04\x12\x1a\n\x12speculative_widths\x18\x0b \x03(\x04\x12$\n\x17speculative_fixed_width\x18\x0c \x01(\x04H\x00\x88\x01\x01\x12\x16\n\x0ehistory_drafts\x18\r \x01(\x08\x12#\n\x1bspeculative_proposal_source\x18\x0e \x01(\t\x12\x1b\n\x0emax_new_tokens\x18\x0f \x01(\x04H\x01\x88\x01\x01\x12\x17\n\nmax_active\x18\x10 \x01(\x04H\x02\x88\x01\x01\x12\x14\n\x0cserved_names\x18\x11 \x03(\t\x12\x1a\n\rreserve_bytes\x18\x12 \x01(\x04H\x03\x88\x01\x01\x12\x1b\n\x0equeue_capacity\x18\x13 \x01(\x04H\x04\x88\x01\x01\x12\x1d\n\x10\x66rontend_workers\x18\x14 \x01(\x04H\x05\x88\x01\x01\x12\x1b\n\x0emax_body_bytes\x18\x15 \x01(\x04H\x06\x88\x01\x01\x12\x14\n\x0c\x63ontext_hint\x18\x16 \x01(\t\x12\x15\n\rcapacity_hint\x18\x17 \x01(\t\x12\"\n\x1aspeculative_token_capacity\x18\x18 \x01(\x04\x12 \n\x13\x64\x65\x63ode_weight_bytes\x18\x19 \x01(\x04H\x07\x88\x01\x01\x42\x1a\n\x18_speculative_fixed_widthB\x11\n\x0f_max_new_tokensB\r\n\x0b_max_activeB\x10\n\x0e_reserve_bytesB\x11\n\x0f_queue_capacityB\x13\n\x11_frontend_workersB\x11\n\x0f_max_body_bytesB\x16\n\x14_decode_weight_bytesJ\x04\x08\n\x10\x0b\"\xc2\x02\n\rModelContract\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x12\n\nvocabulary\x18\x02 \x01(\x04\x12\x18\n\x10input_vocabulary\x18\x03 \x01(\x04\x12-\n\x06vision\x18\x04 \x01(\x0b\x32\x1d.flare.runtime.VisionCapacity\x12+\n\x05\x63\x61\x63he\x18\x05 \x01(\x0b\x32\x1c.flare.runtime.CacheContract\x12,\n\x06graphs\x18\x06 \x03(\x0b\x32\x1c.flare.runtime.GraphContract\x12\x31\n\x08\x66rontend\x18\x07 \x01(\x0b\x32\x1f.flare.runtime.FrontendContract\x12\x35\n\x0f\x63ore_parameters\x18\x08 \x03(\x0b\x32\x1c.flare.runtime.CoreParameter\"}\n\rCoreParameter\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1a\n\rdefault_value\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12\x30\n\x05range\x18\x03 \x01(\x0b\x32!.flare.runtime.CoreParameterRangeB\x10\n\x0e_default_value\"H\n\x12\x43oreParameterRange\x12\x10\n\x03min\x18\x01 \x01(\x02H\x00\x88\x01\x01\x12\x10\n\x03max\x18\x02 \x01(\x02H\x01\x88\x01\x01\x42\x06\n\x04_minB\x06\n\x04_max\"\x90\x01\n\x0eVisionCapacity\x12\x15\n\rfeature_slots\x18\x05 \x01(\x04\x12\x1c\n\x14\x66\x65\x61tures_per_request\x18\x01 \x01(\x04\x12\x12\n\nmax_images\x18\x02 \x01(\x04\x12\x1b\n\x13patches_per_feature\x18\x03 \x01(\x04\x12\x18\n\x10patch_capacities\x18\x04 \x03(\x04\"\xb8\x01\n\rCacheContract\x12\x13\n\x0bpage_tokens\x18\x01 \x01(\x04\x12-\n\x07regions\x18\x02 \x03(\x0b\x32\x1c.flare.runtime.HistoryRegion\x12\x31\n\x0bpage_tables\x18\x03 \x03(\x0b\x32\x1c.flare.runtime.PageTableView\x12\x30\n\x0c\x63odec_layout\x18\x04 \x01(\x0b\x32\x1a.flare.runtime.CodecLayout\"r\n\x0b\x43odecLayout\x12\x10\n\x08revision\x18\x01 \x01(\r\x12)\n\x06\x66ields\x18\x02 \x03(\x0b\x32\x19.flare.runtime.CodecField\x12\x17\n\ngpu_module\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\r\n\x0b_gpu_module\"N\n\nCodecField\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x0e\n\x06offset\x18\x02 \x01(\x04\x12\x0e\n\x06length\x18\x03 \x01(\x04\x12\x10\n\x08\x65ncoding\x18\x04 \x01(\r\"\x96\x01\n\rHistoryRegion\x12(\n\x04kind\x18\x01 \x01(\x0e\x32\x1a.flare.runtime.HistoryKind\x12)\n\x07storage\x18\x02 \x01(\x0b\x32\x18.flare.runtime.StateView\x12\x19\n\x11tokens_per_record\x18\x03 \x01(\x04\x12\x15\n\rwindow_tokens\x18\x04 \x01(\x04\"4\n\rPageTableView\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x13\n\x0bpage_offset\x18\x02 \x01(\x04\"\xc4\x01\n\x0cValueBinding\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12*\n\x06source\x18\x02 \x01(\x0e\x32\x1a.flare.runtime.ValueSource\x12.\n\x08indexing\x18\x03 \x01(\x0e\x32\x1c.flare.runtime.InputIndexing\x12\x14\n\x0cvalue_offset\x18\x04 \x01(\x12\x12\x0f\n\x07padding\x18\x05 \x01(\x12\x12\x0e\n\x06tensor\x18\x06 \x01(\t\x12\x11\n\tparameter\x18\x07 \x01(\t\"K\n\tStateView\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x0e\n\x06offset\x18\x02 \x01(\x04\x12\x0e\n\x06stride\x18\x03 \x01(\x04\x12\x0e\n\x06nbytes\x18\x04 \x01(\x04\"e\n\x0bStateAccess\x12&\n\x04view\x18\x01 \x01(\x0b\x32\x18.flare.runtime.StateView\x12.\n\x06\x61\x63\x63\x65ss\x18\x02 \x01(\x0e\x32\x1e.flare.runtime.StateAccessKind\"O\n\x10\x43ompletionCursor\x12\'\n\x05state\x18\x01 \x01(\x0b\x32\x18.flare.runtime.StateView\x12\x12\n\nlag_tokens\x18\x02 \x01(\x04\"4\n\x0cTunedBinding\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x14\n\x0ctuning_graph\x18\x02 \x01(\t\"\xfa\x02\n\rGraphContract\x12\r\n\x05graph\x18\x01 \x01(\t\x12+\n\x06inputs\x18\x02 \x03(\x0b\x32\x1b.flare.runtime.ValueBinding\x12)\n\x05state\x18\x03 \x03(\x0b\x32\x1a.flare.runtime.StateAccess\x12\x1e\n\x16state_rows_per_request\x18\x04 \x01(\x04\x12\x35\n\x0c\x64raft_cursor\x18\x05 \x01(\x0b\x32\x1f.flare.runtime.CompletionCursor\x12\x18\n\x10\x65mbedding_tables\x18\x06 \x03(\r\x12/\n\rpending_token\x18\x07 \x01(\x0b\x32\x18.flare.runtime.StateView\x12+\n\x04kind\x18\x08 \x01(\x0e\x32\x1d.flare.runtime.GraphOperation\x12\x33\n\x0etuned_bindings\x18\t \x03(\x0b\x32\x1b.flare.runtime.TunedBinding\"\x88\x01\n\nToolParser\x12+\n\x04kind\x18\x01 \x01(\x0e\x32\x1d.flare.runtime.ToolParserKind\x12\x19\n\x11wrapping_newlines\x18\x02 \x01(\r\x12\x15\n\rtag_separator\x18\x03 \x01(\t\x12\x0c\n\x04open\x18\x04 \x01(\t\x12\r\n\x05\x63lose\x18\x05 \x01(\t\"\x95\x01\n\x0fReasoningParser\x12\x30\n\x04kind\x18\x01 \x01(\x0e\x32\".flare.runtime.ReasoningParserKind\x12\x0c\n\x04open\x18\x02 \x01(\t\x12\r\n\x05\x63lose\x18\x03 \x01(\t\x12\x19\n\x11wrapping_newlines\x18\x04 \x01(\r\x12\x18\n\x10terminal_markers\x18\x05 \x03(\t\"\xca\x01\n\x0ePrefixBoundary\x12\r\n\x05roles\x18\x01 \x03(\t\x12\x18\n\x0b\x61ppend_role\x18\x02 \x01(\tH\x00\x88\x01\x01\x12\x1e\n\x16\x63ontinue_final_message\x18\x03 \x01(\x08\x12\x18\n\x10minimum_messages\x18\x04 \x01(\x04\x12\x16\n\x0erequired_start\x18\x05 \x01(\t\x12\x14\n\x0crequired_end\x18\x06 \x01(\t\x12\x17\n\x0frequired_marker\x18\x07 \x01(\tB\x0e\n\x0c_append_role\"y\n\tImageSpan\x12\x13\n\x0bstart_token\x18\x01 \x01(\r\x12\x11\n\tend_token\x18\x02 \x01(\r\x12\x12\n\nmax_tokens\x18\x03 \x01(\x04\x12\x17\n\x0finterior_tokens\x18\x04 \x03(\r\x12\x17\n\x0funscoped_tokens\x18\x05 \x03(\r\"Q\n\x10ImageTokenLayout\x12\x15\n\rfeature_token\x18\x01 \x01(\r\x12&\n\x04span\x18\x02 \x01(\x0b\x32\x18.flare.runtime.ImageSpan\"\xf2\x03\n\x10\x46rontendContract\x12(\n\x05tools\x18\x01 \x01(\x0b\x32\x19.flare.runtime.ToolParser\x12\x31\n\treasoning\x18\x02 \x01(\x0b\x32\x1e.flare.runtime.ReasoningParser\x12\x43\n\x11image_preparation\x18\x03 \x01(\x0e\x32#.flare.runtime.ImagePreparationKindH\x00\x88\x01\x01\x12\x39\n\x0cimage_layout\x18\x04 \x01(\x0e\x32\x1e.flare.runtime.ImageLayoutKindH\x01\x88\x01\x01\x12\x17\n\x0frejected_tokens\x18\x05 \x03(\r\x12\x1b\n\x13position_dimensions\x18\x06 \x01(\r\x12\x18\n\x10\x61ssistant_marker\x18\x07 \x01(\t\x12\x1b\n\x13message_end_markers\x18\x08 \x03(\t\x12\x36\n\x0fprefix_boundary\x18\t \x01(\x0b\x32\x1d.flare.runtime.PrefixBoundary\x12\x35\n\x0cimage_tokens\x18\n \x01(\x0b\x32\x1f.flare.runtime.ImageTokenLayoutB\x14\n\x12_image_preparationB\x0f\n\r_image_layout\"1\n\x07\x43luster\x12\r\n\x05world\x18\x01 \x01(\r\x12\x11\n\texport_id\x18\x03 \x01(\tJ\x04\x08\x02\x10\x03\"\x8c\x03\n\x19\x44\x65\x66\x61ultSamplingParameters\x12\x11\n\x04seed\x18\x01 \x01(\x04H\x00\x88\x01\x01\x12\x18\n\x0btemperature\x18\x02 \x01(\x02H\x01\x88\x01\x01\x12\x12\n\x05top_k\x18\x03 \x01(\x05H\x02\x88\x01\x01\x12\x12\n\x05top_p\x18\x04 \x01(\x02H\x03\x88\x01\x01\x12\x12\n\x05min_p\x18\x05 \x01(\x02H\x04\x88\x01\x01\x12\x1f\n\x12repetition_penalty\x18\x06 \x01(\x02H\x05\x88\x01\x01\x12\x1d\n\x10presence_penalty\x18\x07 \x01(\x02H\x06\x88\x01\x01\x12\x1e\n\x11\x66requency_penalty\x18\x08 \x01(\x02H\x07\x88\x01\x01\x12-\n\x06ranges\x18\t \x01(\x0b\x32\x1d.flare.runtime.SamplingRangesB\x07\n\x05_seedB\x0e\n\x0c_temperatureB\x08\n\x06_top_kB\x08\n\x06_top_pB\x08\n\x06_min_pB\x15\n\x13_repetition_penaltyB\x13\n\x11_presence_penaltyB\x14\n\x12_frequency_penalty\"H\n\x12SamplingFloatRange\x12\x10\n\x03min\x18\x01 \x01(\x02H\x00\x88\x01\x01\x12\x10\n\x03max\x18\x02 \x01(\x02H\x01\x88\x01\x01\x42\x06\n\x04_minB\x06\n\x04_max\"F\n\x10SamplingIntRange\x12\x10\n\x03min\x18\x01 \x01(\x05H\x00\x88\x01\x01\x12\x10\n\x03max\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\x06\n\x04_minB\x06\n\x04_max\"\x96\x03\n\x0eSamplingRanges\x12\x36\n\x0btemperature\x18\x01 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12.\n\x05top_k\x18\x02 \x01(\x0b\x32\x1f.flare.runtime.SamplingIntRange\x12\x30\n\x05top_p\x18\x03 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12\x30\n\x05min_p\x18\x04 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12=\n\x12repetition_penalty\x18\x05 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12;\n\x10presence_penalty\x18\x06 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12<\n\x11\x66requency_penalty\x18\x07 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\"\xc5\x02\n\x10\x46rontendSettings\x12\x33\n\ttokenizer\x18\x01 \x01(\x0b\x32 .flare.runtime.TokenizerSettings\x12+\n\x05image\x18\x02 \x01(\x0b\x32\x1c.flare.runtime.ImageSettings\x12\x15\n\reos_token_ids\x18\x03 \x03(\r\x12:\n\x11template_encoding\x18\x04 \x01(\x0e\x32\x1f.flare.runtime.TemplateEncoding\x12\x34\n\x0eprompt_encoder\x18\x05 \x01(\x0e\x32\x1c.flare.runtime.PromptEncoder\x12\'\n\x1aimage_placeholder_token_id\x18\x06 \x01(\rH\x00\x88\x01\x01\x42\x1d\n\x1b_image_placeholder_token_id\"\xdc\x02\n\x11TokenizerSettings\x12\x16\n\tbos_token\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x16\n\teos_token\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x16\n\tunk_token\x18\x03 \x01(\tH\x02\x88\x01\x01\x12\x16\n\tsep_token\x18\x04 \x01(\tH\x03\x88\x01\x01\x12\x16\n\tpad_token\x18\x05 \x01(\tH\x04\x88\x01\x01\x12\x16\n\tcls_token\x18\x06 \x01(\tH\x05\x88\x01\x01\x12\x17\n\nmask_token\x18\x07 \x01(\tH\x06\x88\x01\x01\x12;\n\x19\x61\x64\x64itional_special_tokens\x18\x08 \x01(\x0b\x32\x18.flare.runtime.TokenListB\x0c\n\n_bos_tokenB\x0c\n\n_eos_tokenB\x0c\n\n_unk_tokenB\x0c\n\n_sep_tokenB\x0c\n\n_pad_tokenB\x0c\n\n_cls_tokenB\r\n\x0b_mask_token\"\x1b\n\tTokenList\x12\x0e\n\x06values\x18\x01 \x03(\t\"\xfc\x03\n\rImageSettings\x12\x30\n\x04qwen\x18\x01 \x01(\x0b\x32 .flare.runtime.QwenImageSettingsH\x00\x12\x30\n\x04mimo\x18\x02 \x01(\x0b\x32 .flare.runtime.MimoImageSettingsH\x00\x12)\n\tdeepseek4\x18\x03 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12\'\n\x07moonvit\x18\x04 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12$\n\x04step\x18\x05 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12%\n\x05radio\x18\x06 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12J\n\x12\x64\x65\x65pseek_row_major\x18\x07 \x01(\x0b\x32,.flare.runtime.DeepseekRowMajorImageSettingsH\x00\x12#\n\x03glm\x18\x08 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12=\n\x0bpatch_merge\x18\t \x01(\x0b\x32&.flare.runtime.PatchMergeImageSettingsH\x00\x12+\n\x0bpadded_grid\x18\n \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x42\t\n\x07profile\"\xb9\x01\n\x17PatchMergeImageSettings\x12\x12\n\npatch_size\x18\x01 \x01(\r\x12\x12\n\nmin_pixels\x18\x02 \x01(\x04\x12\x12\n\nmax_pixels\x18\x03 \x01(\x04\x12\x12\n\nimage_mean\x18\x04 \x03(\x02\x12\x11\n\timage_std\x18\x05 \x03(\x02\x12\x13\n\x0bimage_token\x18\x06 \x01(\t\x12\x13\n\x0bstart_token\x18\x07 \x01(\t\x12\x11\n\tend_token\x18\x08 \x01(\t\"\x87\x01\n\x1d\x44\x65\x65pseekRowMajorImageSettings\x12\x12\n\nmin_pixels\x18\x01 \x01(\x04\x12\x12\n\nmax_tokens\x18\x02 \x01(\x04\x12#\n\x16max_width_height_ratio\x18\x03 \x01(\x04H\x00\x88\x01\x01\x42\x19\n\x17_max_width_height_ratio\"\x82\x01\n\x11QwenImageSettings\x12\x12\n\nmin_pixels\x18\x01 \x01(\x04\x12\x12\n\nmax_pixels\x18\x02 \x01(\x04\x12\x15\n\rposition_side\x18\x03 \x01(\r\x12\x16\n\x0eimage_token_id\x18\x04 \x01(\r\x12\x16\n\x0evideo_token_id\x18\x05 \x01(\r\"b\n\x11MimoImageSettings\x12\x12\n\nmin_pixels\x18\x01 \x01(\x04\x12\x12\n\nmax_pixels\x18\x02 \x01(\x04\x12\x12\n\nimage_mean\x18\x03 \x03(\x02\x12\x11\n\timage_std\x18\x04 \x03(\x02\"|\n\x06\x45ngram\x12\x11\n\ttoken_map\x18\x01 \x03(\r\x12\x14\n\x0cpad_token_id\x18\x02 \x01(\r\x12\x1d\n\x15\x63ompressed_vocabulary\x18\x03 \x01(\r\x12*\n\x06tables\x18\x04 \x03(\x0b\x32\x1a.flare.runtime.EngramTable\"\x99\x04\n\x0b\x45ngramTable\x12\r\n\x05layer\x18\x01 \x01(\r\x12\x0c\n\x04rows\x18\x02 \x01(\x04\x12\x17\n\x0f\x65mbedding_width\x18\x03 \x01(\r\x12\x13\n\x0bscale_block\x18\x04 \x01(\r\x12$\n\x07weights\x18\x05 \x01(\x0b\x32\x13.flare.runtime.Span\x12#\n\x06scales\x18\x06 \x01(\x0b\x32\x13.flare.runtime.Span\x12\'\n\x04hash\x18\x07 \x01(\x0b\x32\x19.flare.runtime.EngramHash\x12\x15\n\rweight_buffer\x18\x08 \x01(\t\x12\x14\n\x0cscale_buffer\x18\t \x01(\t\x12\x13\n\x0bhash_buffer\x18\n \x01(\t\x12\x13\n\x0bready_event\x18\x0b \x01(\t\x12\x35\n\x08\x65ncoding\x18\x0c \x01(\x0e\x32#.flare.runtime.EngramTable.Encoding\x12\x16\n\x0erequest_buffer\x18\r \x01(\t\x12\x14\n\x0cglobal_scale\x18\x0e \x01(\x02\x12/\n\x06shards\x18\x0f \x03(\x0b\x32\x1f.flare.runtime.EngramTableShard\x12\x17\n\x0fprefetch_buffer\x18\x10 \x01(\t\"E\n\x08\x45ncoding\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x11\n\rFP8_E4M3_E8M0\x10\x01\x12\x15\n\x11NVFP4_E4M3_GLOBAL\x10\x02\"\x8c\x01\n\x10\x45ngramTableShard\x12\x0c\n\x04rank\x18\x01 \x01(\r\x12\x11\n\tfirst_row\x18\x02 \x01(\x04\x12\x0c\n\x04rows\x18\x03 \x01(\x04\x12$\n\x07weights\x18\x04 \x01(\x0b\x32\x13.flare.runtime.Span\x12#\n\x06scales\x18\x05 \x01(\x0b\x32\x13.flare.runtime.Span\"\xc3\x01\n\nEngramHash\x12\x30\n\x06method\x18\x01 \x01(\x0e\x32 .flare.runtime.EngramHash.Method\x12\x0e\n\x06orders\x18\x02 \x03(\r\x12\x13\n\x0bmultipliers\x18\x03 \x03(\x04\x12\x0e\n\x06primes\x18\x04 \x03(\x04\x12\x0f\n\x07offsets\x18\x05 \x03(\x04\"=\n\x06Method\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nXOR_MODULO\x10\x01\x12\x12\n\x0e\x45OS_XOR_MODULO\x10\x02\"K\n\x05\x41sset\x12\x0c\n\x04name\x18\x01 \x01(\t\x12$\n\x07payload\x18\x02 \x01(\x0b\x32\x13.flare.runtime.Span\x12\x0e\n\x06sha256\x18\x03 \x01(\t\"\xd3\x04\n\x0b\x42undleIndex\x12\x14\n\x0c\x61rchitecture\x18\x01 \x03(\x05\x12.\n\x0b\x61llocations\x18\x02 \x03(\x0b\x32\x19.flare.runtime.Allocation\x12&\n\x07modules\x18\x03 \x03(\x0b\x32\x15.flare.runtime.Module\x12*\n\tfunctions\x18\x04 \x03(\x0b\x32\x17.flare.runtime.Function\x12)\n\x06graphs\x18\x05 \x03(\x0b\x32\x19.flare.runtime.GraphIndex\x12\x30\n\x0creservations\x18\x06 \x03(\x0b\x32\x1a.flare.runtime.Reservation\x12+\n\texecution\x18\x07 \x01(\x0b\x32\x18.flare.runtime.Execution\x12\'\n\x07\x63ontext\x18\x08 \x01(\x0b\x32\x16.flare.runtime.Context\x12<\n\tresources\x18\t \x03(\x0b\x32).flare.runtime.BundleIndex.ResourcesEntry\x12\x0e\n\x06\x65vents\x18\n \x03(\t\x12*\n\x04roce\x18\x0b \x01(\x0b\x32\x1c.flare.runtime.RoceTransport\x12\x36\n\x0frebuild_weights\x18\x0c \x01(\x0b\x32\x1d.flare.runtime.RebuildWeights\x1a\x45\n\x0eResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\"\n\x05value\x18\x02 \x01(\x0b\x32\x13.flare.runtime.Span:\x02\x38\x01\"\xf8\x01\n\rRoceTransport\x12\x11\n\tproxy_abi\x18\x01 \x01(\r\x12\r\n\x05world\x18\x02 \x01(\r\x12\x0c\n\x04rank\x18\x03 \x01(\r\x12\x16\n\x0eregion_address\x18\x04 \x01(\x04\x12\x14\n\x0cregion_bytes\x18\x05 \x01(\x04\x12\x18\n\x10\x63ounters_address\x18\x06 \x01(\x04\x12\x16\n\x0e\x63ounters_bytes\x18\x07 \x01(\x04\x12\x12\n\nslot_bytes\x18\x08 \x01(\x04\x12\x12\n\npipe_bytes\x18\t \x01(\x04\x12\x13\n\x0b\x63trl_offset\x18\n \x01(\x04\x12\x14\n\x0cvarlen_bytes\x18\x10 \x01(\x04J\x04\x08\x0b\x10\x10\"v\n\nGraphIndex\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05\x66lags\x18\x02 \x01(\x04\x12\x10\n\x08resource\x18\x03 \x01(\t\x12\x12\n\nnode_count\x18\x04 \x01(\x04\x12\x12\n\nedge_count\x18\x05 \x01(\x04\x12\x11\n\tfunctions\x18\x06 \x03(\x04\"M\n\nPeerMemory\x12\r\n\x05owner\x18\x01 \x01(\r\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\x04\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04\x12\x0f\n\x07readers\x18\x04 \x03(\r\"M\n\x07\x43ontext\x12\r\n\x05\x66lags\x18\x01 \x01(\r\x12\r\n\x05\x63\x61\x63he\x18\x02 \x01(\x05\x12$\n\x06limits\x18\x03 \x03(\x0b\x32\x14.flare.runtime.Limit\"\"\n\x05Limit\x12\n\n\x02id\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x04\".\n\x0bReservation\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\"8\n\x04Span\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\x12\x10\n\x08\x66ilename\x18\x03 \x01(\t\"\xa2\x02\n\nAllocation\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\x12\x11\n\talignment\x18\x03 \x01(\x04\x12\x11\n\x04\x66ile\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\'\n\ndata_spans\x18\x05 \x03(\x0b\x32\x13.flare.runtime.Span\x12.\n\x0brelocations\x18\x06 \x03(\x0b\x32\x19.flare.runtime.Relocation\x12\x14\n\x07\x61\x64\x64ress\x18\x07 \x01(\x04H\x01\x88\x01\x01\x12%\n\x06memory\x18\x08 \x01(\x0e\x32\x15.flare.runtime.Memory\x12%\n\x06sizing\x18\t \x01(\x0b\x32\x15.flare.runtime.SizingB\x07\n\x05_fileB\n\n\x08_address\"X\n\x06Sizing\x12)\n\x08\x63\x61pacity\x18\x01 \x01(\x0e\x32\x17.flare.runtime.Capacity\x12\x12\n\nunit_bytes\x18\x02 \x01(\x04\x12\x0f\n\x07maximum\x18\x03 \x01(\x04\"L\n\x06Module\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x66ile\x18\x02 \x01(\t\x12&\n\x07globals\x18\x03 \x03(\x0b\x32\x15.flare.runtime.Global\"f\n\x06Global\x12\x0e\n\x06symbol\x18\x01 \x01(\t\x12\x0c\n\x04\x66ile\x18\x02 \x01(\t\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04\x12.\n\x0brelocations\x18\x04 \x03(\x0b\x32\x19.flare.runtime.Relocation\"y\n\x08\x46unction\x12\x0e\n\x06module\x18\x01 \x01(\t\x12\x0e\n\x06symbol\x18\x02 \x01(\t\x12\x17\n\x0fparameter_sizes\x18\x03 \x03(\x04\x12\x34\n\nattributes\x18\x04 \x03(\x0b\x32 .flare.runtime.FunctionAttribute\".\n\x11\x46unctionAttribute\x12\n\n\x02id\x18\x01 \x01(\x05\x12\r\n\x05value\x18\x02 \x01(\x05\"/\n\tReference\x12\x12\n\nallocation\x18\x01 \x01(\t\x12\x0e\n\x06offset\x18\x02 \x01(\x04\"s\n\nRelocation\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12(\n\x06target\x18\x02 \x01(\x0b\x32\x18.flare.runtime.Reference\x12+\n\x04kind\x18\x03 \x01(\x0e\x32\x1d.flare.runtime.RelocationKind\"D\n\x04\x42lob\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\x12.\n\x0brelocations\x18\x02 \x03(\x0b\x32\x19.flare.runtime.Relocation\";\n\tAttribute\x12\n\n\x02id\x18\x01 \x01(\x05\x12\"\n\x05value\x18\x02 \x01(\x0b\x32\x13.flare.runtime.Blob\"\x9d\x01\n\x06Kernel\x12\x10\n\x08\x66unction\x18\x01 \x01(\x04\x12\x0c\n\x04grid\x18\x02 \x03(\r\x12\r\n\x05\x62lock\x18\x03 \x03(\r\x12\x0e\n\x06shared\x18\x04 \x01(\r\x12&\n\targuments\x18\x05 \x03(\x0b\x32\x13.flare.runtime.Blob\x12,\n\nattributes\x18\x06 \x03(\x0b\x32\x18.flare.runtime.Attribute\"\x8a\x01\n\x06Memset\x12-\n\x0b\x64\x65stination\x18\x01 \x01(\x0b\x32\x18.flare.runtime.Reference\x12\r\n\x05pitch\x18\x02 \x01(\x04\x12\r\n\x05value\x18\x03 \x01(\r\x12\x14\n\x0c\x65lement_size\x18\x04 \x01(\r\x12\r\n\x05width\x18\x05 \x01(\x04\x12\x0e\n\x06height\x18\x06 \x01(\x04\"o\n\x04\x43opy\x12(\n\x06source\x18\x01 \x01(\x0b\x32\x18.flare.runtime.Reference\x12-\n\x0b\x64\x65stination\x18\x02 \x01(\x0b\x32\x18.flare.runtime.Reference\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04\"\x07\n\x05\x45mpty\"\x1a\n\tEventWait\x12\r\n\x05\x65vent\x18\x01 \x01(\t\"\xe1\x01\n\x04Node\x12\'\n\x06kernel\x18\x01 \x01(\x0b\x32\x15.flare.runtime.KernelH\x00\x12\'\n\x06memset\x18\x02 \x01(\x0b\x32\x15.flare.runtime.MemsetH\x00\x12#\n\x04\x63opy\x18\x03 \x01(\x0b\x32\x13.flare.runtime.CopyH\x00\x12%\n\x05\x65mpty\x18\x04 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12.\n\nevent_wait\x18\x05 \x01(\x0b\x32\x18.flare.runtime.EventWaitH\x00\x42\x0b\n\toperation\"9\n\x04\x45\x64ge\x12\x0e\n\x06source\x18\x01 \x01(\x04\x12\x13\n\x0b\x64\x65stination\x18\x02 \x01(\x04\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\xb9\x02\n\tExecution\x12\x13\n\x0b\x61\x62i_version\x18\x01 \x01(\r\x12\x12\n\nmax_active\x18\x02 \x01(\x04\x12\x19\n\x11input_frame_bytes\x18\x03 \x01(\x04\x12&\n\x07\x62uffers\x18\x04 \x03(\x0b\x32\x15.flare.runtime.Buffer\x12-\n\x06graphs\x18\x05 \x03(\x0b\x32\x1d.flare.runtime.ExecutionGraph\x12\x31\n\rtuning_graphs\x18\x06 \x03(\x0b\x32\x1a.flare.runtime.TuningGraph\x12!\n\x19\x63ompletion_token_capacity\x18\x07 \x01(\r\x12;\n\x12persistent_workers\x18\x08 \x03(\x0b\x32\x1f.flare.runtime.PersistentWorker\"\xa9\x01\n\x10PersistentWorker\x12\x17\n\x0fworker_sm_count\x18\x01 \x01(\r\x12\r\n\x05graph\x18\x02 \x01(\t\x12+\n\tstop_flag\x18\x03 \x01(\x0b\x32\x18.flare.runtime.Reference\x12)\n\x07metrics\x18\x04 \x01(\x0b\x32\x18.flare.runtime.Reference\x12\x15\n\rmetrics_count\x18\x05 \x01(\r\"C\n\x0bTuningGraph\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07outputs\x18\x02 \x03(\t\x12\x15\n\rstatus_buffer\x18\x03 \x01(\t\"\x82\x01\n\x06\x42uffer\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\x12\r\n\x05\x64type\x18\x03 \x01(\t\x12\r\n\x05shape\x18\x04 \x03(\x04\x12\x0f\n\x07strides\x18\x05 \x03(\x04\x12+\n\treference\x18\x06 \x01(\x0b\x32\x18.flare.runtime.Reference\"\x95\x04\n\x0e\x45xecutionGraph\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04kind\x18\x02 \x01(\t\x12\x15\n\rsampling_mode\x18\x03 \x01(\t\x12\x16\n\x0e\x62\x61tch_capacity\x18\x04 \x01(\x04\x12\x16\n\x0etoken_capacity\x18\x05 \x01(\x04\x12\x33\n\x0einput_bindings\x18\x06 \x03(\x0b\x32\x1b.flare.runtime.InputBinding\x12\x19\n\x0c\x64raft_tokens\x18\x07 \x01(\rH\x00\x88\x01\x01\x12\x1a\n\rverify_tokens\x18\x08 \x01(\rH\x01\x88\x01\x01\x12\x30\n\x0c\x64raft_source\x18\t \x01(\x0e\x32\x1a.flare.runtime.DraftSource\x12 \n\x13speculation_enabled\x18\n \x01(\x08H\x02\x88\x01\x01\x12\x1d\n\x15\x65stimated_duration_ns\x18\x0b \x01(\x04\x12\x18\n\x10prefill_capacity\x18\x0c \x01(\x04\x12\x1d\n\x15packed_token_capacity\x18\r \x01(\x04\x12\x18\n\x10\x63onfidence_width\x18\x0e \x01(\r\x12\x33\n\x0etuned_bindings\x18\x0f \x03(\x0b\x32\x1b.flare.runtime.TunedBindingB\x0f\n\r_draft_tokensB\x10\n\x0e_verify_tokensB\x16\n\x14_speculation_enabled\"H\n\x0cInputBinding\x12\x13\n\x0b\x62uffer_name\x18\x01 \x01(\t\x12\x13\n\x0bhost_offset\x18\x02 \x01(\x04\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04*\xfa\x01\n\x19PreparationParameterScope\x12+\n\'PREPARATION_PARAMETER_SCOPE_UNSPECIFIED\x10\x00\x12*\n&PREPARATION_PARAMETER_SCOPE_DEPLOYMENT\x10\x01\x12\'\n#PREPARATION_PARAMETER_SCOPE_COMBINE\x10\x02\x12-\n)PREPARATION_PARAMETER_SCOPE_TARGET_WEIGHT\x10\x03\x12,\n(PREPARATION_PARAMETER_SCOPE_DRAFT_WEIGHT\x10\x04*\x8e\x01\n\x0bHistoryKind\x12\x17\n\x13HISTORY_UNSPECIFIED\x10\x00\x12\x13\n\x0fPAGED_KEY_VALUE\x10\x01\x12\x10\n\x0cPAGED_LATENT\x10\x02\x12\x12\n\x0eSLIDING_WINDOW\x10\x03\x12\x13\n\x0fRECURRENT_STATE\x10\x04\x12\x16\n\x12\x43ONTINUATION_STATE\x10\x05*\xc7\x07\n\x0bValueSource\x12\x15\n\x11VALUE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43ONSTANT\x10\x01\x12\x10\n\x0cREQUEST_SLOT\x10\x02\x12\x16\n\x12REQUEST_GENERATION\x10\x03\x12\r\n\tLIVE_ROWS\x10\x04\x12\x10\n\x0cQUERY_LENGTH\x10\x05\x12\x12\n\x0eSAMPLE_ENABLED\x10\x06\x12\x10\n\x0cPROMPT_TOKEN\x10\x07\x12\x11\n\rPENDING_TOKEN\x10\x08\x12\x1c\n\x18PROMPT_AND_PENDING_TOKEN\x10\t\x12\x13\n\x0fPROMPT_POSITION\x10\n\x12\x17\n\x13IMAGE_FEATURE_INDEX\x10\x0b\x12\x16\n\x12IMAGE_LEFT_CONTEXT\x10\x0c\x12\x17\n\x13IMAGE_RIGHT_CONTEXT\x10\r\x12\x0e\n\nPAGE_TABLE\x10\x0e\x12\x13\n\x0fLIVE_STATE_ROWS\x10\x0f\x12\x12\n\x0eLIVE_STATE_ROW\x10\x10\x12\x14\n\x10PREFIX_STATE_ROW\x10\x11\x12\x16\n\x12SNAPSHOT_STATE_ROW\x10\x12\x12\x13\n\x0f\x43ONSUMED_TOKENS\x10\x13\x12\x1c\n\x18SNAPSHOT_CONSUMED_TOKENS\x10\x14\x12\x0f\n\x0bPREFILL_ROW\x10\x15\x12\x11\n\rSAMPLING_SEED\x10\x16\x12\x17\n\x13SAMPLING_PARAMETERS\x10\x17\x12\x12\n\x0eSAMPLING_TOP_K\x10\x18\x12\x12\n\x0eMAX_NEW_TOKENS\x10\x19\x12\x11\n\rEOS_TOKEN_IDS\x10\x1a\x12\r\n\tEOS_COUNT\x10\x1b\x12\x14\n\x10PROMPT_HISTOGRAM\x10\x1c\x12\x10\n\x0cGRAMMAR_MASK\x10\x1d\x12\x13\n\x0fGRAMMAR_ENABLED\x10\x1e\x12\x12\n\x0e\x43OPY_TOKEN_IDS\x10\x1f\x12\x14\n\x10\x43OPY_TOKEN_COUNT\x10 \x12\x18\n\x14\x43OPY_CONSUMED_TOKENS\x10!\x12\x13\n\x0f\x43OPY_GENERATION\x10\"\x12\x15\n\x11\x43OPY_GRAMMAR_MASK\x10#\x12\x16\n\x12\x43OPY_GRAMMAR_COUNT\x10$\x12\x10\n\x0cIMAGE_TENSOR\x10%\x12\x16\n\x12IMAGE_FEATURE_SLOT\x10&\x12\x17\n\x13PROMPT_TARGET_TOKEN\x10\'\x12\x1c\n\x18SPECULATIVE_PREFIX_LIMIT\x10(\x12\x1a\n\x16PROMPT_LOOKAHEAD_TOKEN\x10)\x12\x1b\n\x17PROMPT_LOOKAHEAD_LENGTH\x10*\x12\x12\n\x0e\x43ORE_PARAMETER\x10+*|\n\rInputIndexing\x12\x18\n\x14INDEXING_UNSPECIFIED\x10\x00\x12\n\n\x06SCALAR\x10\x01\x12\x12\n\x0eSUBMISSION_ROW\x10\x02\x12\x0f\n\x0bREQUEST_ROW\x10\x03\x12\x10\n\x0cPACKED_TOKEN\x10\x04\x12\x0e\n\nACTIVE_ROW\x10\x05*T\n\x0fStateAccessKind\x12\x1c\n\x18STATE_ACCESS_UNSPECIFIED\x10\x00\x12\x08\n\x04READ\x10\x01\x12\t\n\x05WRITE\x10\x02\x12\x0e\n\nREAD_WRITE\x10\x03*\x8b\x02\n\x0eGraphOperation\x12\x1f\n\x1bGRAPH_OPERATION_UNSPECIFIED\x10\x00\x12\x08\n\x04INIT\x10\x01\x12\x0b\n\x07RESTORE\x10\x02\x12\x0c\n\x08SNAPSHOT\x10\x03\x12\x0b\n\x07PREFILL\x10\x04\x12\n\n\x06\x44\x45\x43ODE\x10\x05\x12\n\n\x06RESUME\x10\x06\x12\n\n\x06VISION\x10\x07\x12\x0f\n\x0bSPECULATIVE\x10\x08\x12\t\n\x05MIXED\x10\t\x12\x12\n\x0eSCORED_PREFILL\x10\x0c\x12\x14\n\x10TERMINAL_PREFILL\x10\x0e\"\x04\x08\n\x10\n\"\x04\x08\x0b\x10\x0b\"\x04\x08\r\x10\r*\x08PROPOSAL*\x0cVERIFICATION*\x12PACKED_SPECULATIVE*\xb2\x01\n\x0eToolParserKind\x12\x1b\n\x17TOOL_PARSER_UNSPECIFIED\x10\x00\x12\x0e\n\nQWEN_CODER\x10\x01\x12\x15\n\x11GLM_ARGUMENT_TAGS\x10\x02\x12\x08\n\x04\x44SML\x10\x03\x12\x08\n\x04XTML\x10\x04\x12\x0f\n\x0bMINIMAX_XML\x10\x05\x12\x0e\n\nGEMMA_CALL\x10\x06\x12\x08\n\x04\x41TEM\x10\x07\x12\x0c\n\x08TML_JSON\x10\x08\x12\x0f\n\x0bTAGGED_JSON\x10\t*\xa6\x01\n\x13ReasoningParserKind\x12 \n\x1cREASONING_PARSER_UNSPECIFIED\x10\x00\x12\x0e\n\nTHINK_TAGS\x10\x01\x12\x0e\n\nXTML_THINK\x10\x02\x12\x0c\n\x08MM_THINK\x10\x03\x12\x13\n\x0f\x43HANNEL_THOUGHT\x10\x04\x12\x15\n\x11RECIPIENT_HEADERS\x10\x05\x12\x13\n\x0f\x43ONTENT_HEADERS\x10\x06*\xf4\x02\n\x14ImagePreparationKind\x12!\n\x1dIMAGE_PREPARATION_UNSPECIFIED\x10\x00\x12\x1a\n\x16QWEN_IMAGE_PREPARATION\x10\x01\x12\x1a\n\x16MIMO_IMAGE_PREPARATION\x10\x02\x12\x1e\n\x1a\x44\x45\x45PSEEK_IMAGE_PREPARATION\x10\x03\x12\x1d\n\x19MOONVIT_IMAGE_PREPARATION\x10\x04\x12\x1a\n\x16STEP_IMAGE_PREPARATION\x10\x05\x12\x1b\n\x17RADIO_IMAGE_PREPARATION\x10\x06\x12(\n$DEEPSEEK_ROW_MAJOR_IMAGE_PREPARATION\x10\x07\x12\x19\n\x15GLM_IMAGE_PREPARATION\x10\x08\x12!\n\x1dPATCH_MERGE_IMAGE_PREPARATION\x10\t\x12!\n\x1dPADDED_GRID_IMAGE_PREPARATION\x10\n*\xb6\x02\n\x0fImageLayoutKind\x12\x1c\n\x18IMAGE_LAYOUT_UNSPECIFIED\x10\x00\x12\x15\n\x11QWEN_IMAGE_LAYOUT\x10\x01\x12\x15\n\x11MIMO_IMAGE_LAYOUT\x10\x02\x12\x19\n\x15\x44\x45\x45PSEEK_IMAGE_LAYOUT\x10\x03\x12\x18\n\x14MOONVIT_IMAGE_LAYOUT\x10\x04\x12\x15\n\x11STEP_IMAGE_LAYOUT\x10\x05\x12\x16\n\x12RADIO_IMAGE_LAYOUT\x10\x06\x12#\n\x1f\x44\x45\x45PSEEK_ROW_MAJOR_IMAGE_LAYOUT\x10\x07\x12\x14\n\x10GLM_IMAGE_LAYOUT\x10\x08\x12\x1a\n\x16\x42RACKETED_IMAGE_LAYOUT\x10\t\x12\x1c\n\x18\x43LASS_TOKEN_IMAGE_LAYOUT\x10\n*P\n\rPromptEncoder\x12\x10\n\x0cPROMPT_JINJA\x10\x00\x12\x0f\n\x0b\x44\x45\x45PSEEK_V4\x10\x01\x12\x10\n\x0c\x44\x45\x45PSEEK_V41\x10\x02\x12\n\n\x06TML_V0\x10\x03*B\n\x10TemplateEncoding\x12\x11\n\rTEMPLATE_TEXT\x10\x00\x12\x1b\n\x17TEMPLATE_TOKEN_SEGMENTS\x10\x01*/\n\x06Memory\x12\n\n\x06\x44\x45VICE\x10\x00\x12\x0f\n\x0bMAPPED_HOST\x10\x01\x12\x08\n\x04PEER\x10\x02*(\n\x08\x43\x61pacity\x12\x0e\n\nSTATE_ROWS\x10\x00\x12\x0c\n\x08KV_PAGES\x10\x01*-\n\x0eRelocationKind\x12\x0b\n\x07POINTER\x10\x00\x12\x0e\n\nTENSOR_MAP\x10\x01*4\n\x0b\x44raftSource\x12\x0c\n\x08NO_DRAFT\x10\x00\x12\x07\n\x03MTP\x10\x01\x12\x0e\n\nCOPY_DRAFT\x10\x02\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12runtime_core.proto\x12\rflare.runtime\"\x99\x01\n\x0eProtectedIndex\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x0f\n\x07\x63ore_id\x18\x02 \x01(\x0c\x12\x0e\n\x06signer\x18\x03 \x01(\x0c\x12*\n\x06groups\x18\x04 \x03(\x0b\x32\x1a.flare.runtime.SignedGroup\x12)\n\x05ranks\x18\x05 \x03(\x0b\x32\x1a.flare.runtime.SignedGroup\"<\n\x0bSignedGroup\x12\x0c\n\x04kind\x18\x01 \x01(\r\x12\x0c\n\x04\x62ody\x18\x02 \x01(\x0c\x12\x11\n\tsignature\x18\x03 \x01(\x0c\"\xcc\x01\n\x11PublisherMetadata\x12(\n\x05index\x18\x01 \x01(\x0b\x32\x19.flare.runtime.ModelIndex\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x17\n\x0fofficial_source\x18\x03 \x01(\t\x12\x14\n\x0cgroup_hashes\x18\x04 \x03(\x0c\x12\x13\n\x0b\x64\x65velopment\x18\x05 \x01(\x08\x12\r\n\x05ranks\x18\x06 \x01(\r\x12\'\n\x07license\x18\x07 \x01(\x0b\x32\x16.flare.runtime.License\"%\n\x07License\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04link\x18\x02 \x01(\t\"F\n\x0fResourceCatalog\x12\x33\n\tresources\x18\x01 \x03(\x0b\x32 .flare.runtime.ProtectedResource\"^\n\x11ProtectedResource\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12\x14\n\x0cstored_bytes\x18\x02 \x01(\x04\x12\x13\n\x0bplain_bytes\x18\x03 \x01(\x04\x12\x0e\n\x06sha256\x18\x04 \x03(\x0c\"`\n\nStoredData\x12\x0e\n\x06nbytes\x18\x01 \x01(\x04\x12\x0e\n\x06sha256\x18\x02 \x01(\x0c\x12\x0e\n\x06offset\x18\x03 \x01(\x04\x12\"\n\x05parts\x18\x04 \x03(\x0b\x32\x13.flare.runtime.Span\"\xd9\x01\n\x0eRankProtection\x12\x0c\n\x04rank\x18\x01 \x01(\r\x12*\n\x06\x62undle\x18\x02 \x01(\x0b\x32\x1a.flare.runtime.BundleIndex\x12\x33\n\x0b\x65xecutables\x18\x03 \x01(\x0b\x32\x1e.flare.runtime.ResourceCatalog\x12/\n\x07support\x18\x04 \x01(\x0b\x32\x1e.flare.runtime.ResourceCatalog\x12\'\n\x04\x64\x61ta\x18\x05 \x01(\x0b\x32\x19.flare.runtime.StoredData\"\x8c\x04\n\nModelIndex\x12\x0f\n\x07version\x18\x01 \x01(\r\x12)\n\x05ranks\x18\x02 \x03(\x0b\x32\x1a.flare.runtime.BundleIndex\x12.\n\x0bpeer_memory\x18\x03 \x03(\x0b\x32\x19.flare.runtime.PeerMemory\x12$\n\x06\x61ssets\x18\x05 \x03(\x0b\x32\x14.flare.runtime.Asset\x12%\n\x06\x65ngram\x18\x06 \x01(\x0b\x32\x15.flare.runtime.Engram\x12\x43\n\x11sampling_defaults\x18\x07 \x01(\x0b\x32(.flare.runtime.DefaultSamplingParameters\x12\x31\n\x08\x66rontend\x18\x08 \x01(\x0b\x32\x1f.flare.runtime.FrontendSettings\x12\'\n\x07\x63luster\x18\t \x01(\x0b\x32\x16.flare.runtime.Cluster\x12\x30\n\x08\x63ontract\x18\n \x01(\x0b\x32\x1e.flare.runtime.ServingContract\x12\x33\n\x07rebuild\x18\x0b \x01(\x0b\x32\x1e.flare.runtime.RebuildManifestB\x02\x18\x01\x12\x37\n\x0bpreparation\x18\x0c \x01(\x0b\x32\".flare.runtime.PreparationManifestJ\x04\x08\x04\x10\x05\"\xf9\x01\n\x13PreparationManifest\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x0e\n\x06recipe\x18\x02 \x01(\t\x12\x17\n\x0fsource_identity\x18\x03 \x01(\t\x12\x1d\n\x15\x63heckpoint_repository\x18\x04 \x01(\t\x12\x1b\n\x13\x63heckpoint_revision\x18\x05 \x01(\t\x12\x18\n\x10local_checkpoint\x18\x06 \x01(\x08\x12\x19\n\x11reproduction_args\x18\x07 \x03(\t\x12\x37\n\nparameters\x18\x08 \x03(\x0b\x32#.flare.runtime.PreparationParameter\"\x8c\x01\n\x14PreparationParameter\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x37\n\x05scope\x18\x02 \x01(\x0e\x32(.flare.runtime.PreparationParameterScope\x12.\n\x05value\x18\x03 \x01(\x0b\x32\x1f.flare.runtime.PreparationValue\"\xc6\x01\n\x10PreparationValue\x12\x14\n\nbool_value\x18\x01 \x01(\x08H\x00\x12\x13\n\tint_value\x18\x02 \x01(\x03H\x00\x12\x14\n\nuint_value\x18\x03 \x01(\x04H\x00\x12\x15\n\x0b\x66loat_value\x18\x04 \x01(\x01H\x00\x12\x16\n\x0cstring_value\x18\x05 \x01(\tH\x00\x12\x39\n\nlist_value\x18\x06 \x01(\x0b\x32#.flare.runtime.PreparationValueListH\x00\x42\x07\n\x05value\"G\n\x14PreparationValueList\x12/\n\x06values\x18\x01 \x03(\x0b\x32\x1f.flare.runtime.PreparationValue\"\xdb\x07\n\x0fRebuildManifest\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x0e\n\x06recipe\x18\x02 \x01(\t\x12\x17\n\x0fsource_identity\x18\x03 \x01(\t\x12\x1d\n\x15\x63heckpoint_repository\x18\x04 \x01(\t\x12\x1b\n\x13\x63heckpoint_revision\x18\x05 \x01(\t\x12\x17\n\x0ftensor_parallel\x18\x06 \x01(\r\x12\x17\n\x0fmax_concurrency\x18\x07 \x01(\x04\x12\x15\n\rprefill_chunk\x18\x08 \x01(\x04\x12\x19\n\x11image_concurrency\x18\t \x01(\x04\x12\x18\n\x10\x63ontext_parallel\x18\n \x01(\x08\x12\x16\n\x0estream_overlap\x18\x0b \x01(\x08\x12\x15\n\rmixed_prefill\x18\x0c \x01(\x08\x12%\n\x18\x65xpert_scale_compression\x18\r \x01(\tH\x00\x88\x01\x01\x12\x18\n\x10mla_compute_mode\x18\x0e \x01(\t\x12\x11\n\troce_ring\x18\x0f \x01(\x08\x12\x14\n\x0conline_mxfp8\x18\x10 \x01(\x08\x12\x1b\n\x13language_model_only\x18\x11 \x01(\x08\x12\x36\n\x0bspeculation\x18\x12 \x01(\x0b\x32!.flare.runtime.RebuildSpeculation\x12\x19\n\x11\x63ompiled_forwards\x18\x13 \x01(\x08\x12\x15\n\rreserve_bytes\x18\x14 \x01(\x04\x12\x18\n\x10local_checkpoint\x18\x15 \x01(\x08\x12\x12\n\nroce_chain\x18\x16 \x01(\x08\x12\x1e\n\x16shard_hyperconnections\x18\x18 \x01(\x08\x12\x1c\n\x14\x66orce_moe_decode_a16\x18\x1b \x01(\x08\x12\x19\n\x11row_shard_prefill\x18\x1c \x01(\x08\x12\x1a\n\x12online_mxfp8_scope\x18\x1e \x01(\t\x12\x1d\n\x15\x63ontext_parallel_size\x18\x1f \x01(\r\x12\x17\n\x0fprompt_logprobs\x18 \x01(\x08\x12\x17\n\x0f\x61utotune_effort\x18! \x01(\t\x12 \n\x18native_dense_activations\x18\" \x01(\x08\x12\x17\n\x0flock_gpu_clocks\x18# \x01(\x08\x12\x19\n\x11reproduction_args\x18$ \x03(\t:\x02\x18\x01\x42\x1b\n\x19_expert_scale_compressionJ\x04\x08\x17\x10\x18J\x04\x08\x19\x10\x1aJ\x04\x08\x1a\x10\x1bR\x0cjoint_tuningR\x11\x63ollective_tuningR\x16\x63ollective_ladder_json\"\x82\x04\n\x12RebuildSpeculation\x12\x14\n\x0c\x64raft_tokens\x18\x01 \x01(\r\x12\x10\n\x08\x61\x64\x61ptive\x18\x02 \x01(\x08\x12\x17\n\x0fproposal_source\x18\x03 \x01(\t\x12\x16\n\x0ehistory_drafts\x18\x04 \x01(\x08\x12\x16\n\x0etoken_capacity\x18\x05 \x01(\x04\x12\x1b\n\x13packed_verification\x18\x06 \x01(\x08\x12\x1e\n\x16\x64raft_prefix_selection\x18\x07 \x01(\t\x12$\n\x17\x64raft_head_quantization\x18\x08 \x01(\tH\x00\x88\x01\x01\x12%\n\x18markov_head_quantization\x18\t \x01(\tH\x01\x88\x01\x01\x12\x19\n\x0cgraph_budget\x18\n \x01(\x04H\x02\x88\x01\x01\x12$\n\x1cvocabulary_parallel_sampling\x18\x0b \x01(\x08\x12\x0e\n\x06method\x18\x0c \x01(\t\x12\x10\n\x08mtp_only\x18\r \x01(\x08\x12$\n\x17\x64raft_body_quantization\x18\x0e \x01(\tH\x03\x88\x01\x01:\x02\x18\x01\x42\x1a\n\x18_draft_head_quantizationB\x1b\n\x19_markov_head_quantizationB\x0f\n\r_graph_budgetB\x1a\n\x18_draft_body_quantization\"e\n\x0eRebuildWeights\x12\x0f\n\x07version\x18\x01 \x01(\r\x12-\n\x07tensors\x18\x02 \x03(\x0b\x32\x1c.flare.runtime.RebuildTensor\x12\x13\n\x0bunavailable\x18\x03 \x03(\t\"\xa2\x01\n\rRebuildTensor\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05\x64type\x18\x02 \x01(\t\x12\x15\n\relement_bytes\x18\x03 \x01(\r\x12\r\n\x05shape\x18\x04 \x03(\x04\x12\x0e\n\x06stride\x18\x05 \x03(\x04\x12\x13\n\x0blayout_type\x18\x06 \x01(\t\x12)\n\x07storage\x18\x07 \x01(\x0b\x32\x18.flare.runtime.Reference\"\xcb\x06\n\x0fServingContract\x12\x10\n\x08model_id\x18\x01 \x01(\t\x12\x10\n\x08identity\x18\x02 \x01(\t\x12\x34\n\x0emodel_contract\x18\x03 \x01(\x0b\x32\x1c.flare.runtime.ModelContract\x12\x1b\n\x13max_sequence_tokens\x18\x04 \x01(\x04\x12\x1a\n\x12prefill_chunk_size\x18\x05 \x01(\x04\x12\r\n\x05pages\x18\x06 \x01(\x04\x12\x12\n\nstate_rows\x18\x07 \x01(\x04\x12\x11\n\tsnapshots\x18\x08 \x01(\x04\x12\x13\n\x0bpage_tokens\x18\t \x01(\x04\x12\x1a\n\x12speculative_widths\x18\x0b \x03(\x04\x12$\n\x17speculative_fixed_width\x18\x0c \x01(\x04H\x00\x88\x01\x01\x12\x16\n\x0ehistory_drafts\x18\r \x01(\x08\x12#\n\x1bspeculative_proposal_source\x18\x0e \x01(\t\x12\x1b\n\x0emax_new_tokens\x18\x0f \x01(\x04H\x01\x88\x01\x01\x12\x17\n\nmax_active\x18\x10 \x01(\x04H\x02\x88\x01\x01\x12\x14\n\x0cserved_names\x18\x11 \x03(\t\x12\x1a\n\rreserve_bytes\x18\x12 \x01(\x04H\x03\x88\x01\x01\x12\x1b\n\x0equeue_capacity\x18\x13 \x01(\x04H\x04\x88\x01\x01\x12\x1d\n\x10\x66rontend_workers\x18\x14 \x01(\x04H\x05\x88\x01\x01\x12\x1b\n\x0emax_body_bytes\x18\x15 \x01(\x04H\x06\x88\x01\x01\x12\x14\n\x0c\x63ontext_hint\x18\x16 \x01(\t\x12\x15\n\rcapacity_hint\x18\x17 \x01(\t\x12\"\n\x1aspeculative_token_capacity\x18\x18 \x01(\x04\x12 \n\x13\x64\x65\x63ode_weight_bytes\x18\x19 \x01(\x04H\x07\x88\x01\x01\x42\x1a\n\x18_speculative_fixed_widthB\x11\n\x0f_max_new_tokensB\r\n\x0b_max_activeB\x10\n\x0e_reserve_bytesB\x11\n\x0f_queue_capacityB\x13\n\x11_frontend_workersB\x11\n\x0f_max_body_bytesB\x16\n\x14_decode_weight_bytesJ\x04\x08\n\x10\x0b\"\xc2\x02\n\rModelContract\x12\x0f\n\x07version\x18\x01 \x01(\r\x12\x12\n\nvocabulary\x18\x02 \x01(\x04\x12\x18\n\x10input_vocabulary\x18\x03 \x01(\x04\x12-\n\x06vision\x18\x04 \x01(\x0b\x32\x1d.flare.runtime.VisionCapacity\x12+\n\x05\x63\x61\x63he\x18\x05 \x01(\x0b\x32\x1c.flare.runtime.CacheContract\x12,\n\x06graphs\x18\x06 \x03(\x0b\x32\x1c.flare.runtime.GraphContract\x12\x31\n\x08\x66rontend\x18\x07 \x01(\x0b\x32\x1f.flare.runtime.FrontendContract\x12\x35\n\x0f\x63ore_parameters\x18\x08 \x03(\x0b\x32\x1c.flare.runtime.CoreParameter\"}\n\rCoreParameter\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1a\n\rdefault_value\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12\x30\n\x05range\x18\x03 \x01(\x0b\x32!.flare.runtime.CoreParameterRangeB\x10\n\x0e_default_value\"H\n\x12\x43oreParameterRange\x12\x10\n\x03min\x18\x01 \x01(\x02H\x00\x88\x01\x01\x12\x10\n\x03max\x18\x02 \x01(\x02H\x01\x88\x01\x01\x42\x06\n\x04_minB\x06\n\x04_max\"\xa8\x01\n\x0eVisionCapacity\x12\x15\n\rfeature_slots\x18\x05 \x01(\x04\x12\x1c\n\x14\x66\x65\x61tures_per_request\x18\x01 \x01(\x04\x12\x12\n\nmax_images\x18\x02 \x01(\x04\x12\x1b\n\x13patches_per_feature\x18\x03 \x01(\x04\x12\x18\n\x10patch_capacities\x18\x04 \x03(\x04\x12\x16\n\x0epatch_features\x18\x06 \x01(\x04\"\xb8\x01\n\rCacheContract\x12\x13\n\x0bpage_tokens\x18\x01 \x01(\x04\x12-\n\x07regions\x18\x02 \x03(\x0b\x32\x1c.flare.runtime.HistoryRegion\x12\x31\n\x0bpage_tables\x18\x03 \x03(\x0b\x32\x1c.flare.runtime.PageTableView\x12\x30\n\x0c\x63odec_layout\x18\x04 \x01(\x0b\x32\x1a.flare.runtime.CodecLayout\"r\n\x0b\x43odecLayout\x12\x10\n\x08revision\x18\x01 \x01(\r\x12)\n\x06\x66ields\x18\x02 \x03(\x0b\x32\x19.flare.runtime.CodecField\x12\x17\n\ngpu_module\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\r\n\x0b_gpu_module\"N\n\nCodecField\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x0e\n\x06offset\x18\x02 \x01(\x04\x12\x0e\n\x06length\x18\x03 \x01(\x04\x12\x10\n\x08\x65ncoding\x18\x04 \x01(\r\"\x96\x01\n\rHistoryRegion\x12(\n\x04kind\x18\x01 \x01(\x0e\x32\x1a.flare.runtime.HistoryKind\x12)\n\x07storage\x18\x02 \x01(\x0b\x32\x18.flare.runtime.StateView\x12\x19\n\x11tokens_per_record\x18\x03 \x01(\x04\x12\x15\n\rwindow_tokens\x18\x04 \x01(\x04\"4\n\rPageTableView\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x13\n\x0bpage_offset\x18\x02 \x01(\x04\"\xc4\x01\n\x0cValueBinding\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12*\n\x06source\x18\x02 \x01(\x0e\x32\x1a.flare.runtime.ValueSource\x12.\n\x08indexing\x18\x03 \x01(\x0e\x32\x1c.flare.runtime.InputIndexing\x12\x14\n\x0cvalue_offset\x18\x04 \x01(\x12\x12\x0f\n\x07padding\x18\x05 \x01(\x12\x12\x0e\n\x06tensor\x18\x06 \x01(\t\x12\x11\n\tparameter\x18\x07 \x01(\t\"K\n\tStateView\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x0e\n\x06offset\x18\x02 \x01(\x04\x12\x0e\n\x06stride\x18\x03 \x01(\x04\x12\x0e\n\x06nbytes\x18\x04 \x01(\x04\"e\n\x0bStateAccess\x12&\n\x04view\x18\x01 \x01(\x0b\x32\x18.flare.runtime.StateView\x12.\n\x06\x61\x63\x63\x65ss\x18\x02 \x01(\x0e\x32\x1e.flare.runtime.StateAccessKind\"O\n\x10\x43ompletionCursor\x12\'\n\x05state\x18\x01 \x01(\x0b\x32\x18.flare.runtime.StateView\x12\x12\n\nlag_tokens\x18\x02 \x01(\x04\"4\n\x0cTunedBinding\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\t\x12\x14\n\x0ctuning_graph\x18\x02 \x01(\t\"\xfa\x02\n\rGraphContract\x12\r\n\x05graph\x18\x01 \x01(\t\x12+\n\x06inputs\x18\x02 \x03(\x0b\x32\x1b.flare.runtime.ValueBinding\x12)\n\x05state\x18\x03 \x03(\x0b\x32\x1a.flare.runtime.StateAccess\x12\x1e\n\x16state_rows_per_request\x18\x04 \x01(\x04\x12\x35\n\x0c\x64raft_cursor\x18\x05 \x01(\x0b\x32\x1f.flare.runtime.CompletionCursor\x12\x18\n\x10\x65mbedding_tables\x18\x06 \x03(\r\x12/\n\rpending_token\x18\x07 \x01(\x0b\x32\x18.flare.runtime.StateView\x12+\n\x04kind\x18\x08 \x01(\x0e\x32\x1d.flare.runtime.GraphOperation\x12\x33\n\x0etuned_bindings\x18\t \x03(\x0b\x32\x1b.flare.runtime.TunedBinding\"\x88\x01\n\nToolParser\x12+\n\x04kind\x18\x01 \x01(\x0e\x32\x1d.flare.runtime.ToolParserKind\x12\x19\n\x11wrapping_newlines\x18\x02 \x01(\r\x12\x15\n\rtag_separator\x18\x03 \x01(\t\x12\x0c\n\x04open\x18\x04 \x01(\t\x12\r\n\x05\x63lose\x18\x05 \x01(\t\"\x95\x01\n\x0fReasoningParser\x12\x30\n\x04kind\x18\x01 \x01(\x0e\x32\".flare.runtime.ReasoningParserKind\x12\x0c\n\x04open\x18\x02 \x01(\t\x12\r\n\x05\x63lose\x18\x03 \x01(\t\x12\x19\n\x11wrapping_newlines\x18\x04 \x01(\r\x12\x18\n\x10terminal_markers\x18\x05 \x03(\t\"\xca\x01\n\x0ePrefixBoundary\x12\r\n\x05roles\x18\x01 \x03(\t\x12\x18\n\x0b\x61ppend_role\x18\x02 \x01(\tH\x00\x88\x01\x01\x12\x1e\n\x16\x63ontinue_final_message\x18\x03 \x01(\x08\x12\x18\n\x10minimum_messages\x18\x04 \x01(\x04\x12\x16\n\x0erequired_start\x18\x05 \x01(\t\x12\x14\n\x0crequired_end\x18\x06 \x01(\t\x12\x17\n\x0frequired_marker\x18\x07 \x01(\tB\x0e\n\x0c_append_role\"y\n\tImageSpan\x12\x13\n\x0bstart_token\x18\x01 \x01(\r\x12\x11\n\tend_token\x18\x02 \x01(\r\x12\x12\n\nmax_tokens\x18\x03 \x01(\x04\x12\x17\n\x0finterior_tokens\x18\x04 \x03(\r\x12\x17\n\x0funscoped_tokens\x18\x05 \x03(\r\"Q\n\x10ImageTokenLayout\x12\x15\n\rfeature_token\x18\x01 \x01(\r\x12&\n\x04span\x18\x02 \x01(\x0b\x32\x18.flare.runtime.ImageSpan\"\xf2\x03\n\x10\x46rontendContract\x12(\n\x05tools\x18\x01 \x01(\x0b\x32\x19.flare.runtime.ToolParser\x12\x31\n\treasoning\x18\x02 \x01(\x0b\x32\x1e.flare.runtime.ReasoningParser\x12\x43\n\x11image_preparation\x18\x03 \x01(\x0e\x32#.flare.runtime.ImagePreparationKindH\x00\x88\x01\x01\x12\x39\n\x0cimage_layout\x18\x04 \x01(\x0e\x32\x1e.flare.runtime.ImageLayoutKindH\x01\x88\x01\x01\x12\x17\n\x0frejected_tokens\x18\x05 \x03(\r\x12\x1b\n\x13position_dimensions\x18\x06 \x01(\r\x12\x18\n\x10\x61ssistant_marker\x18\x07 \x01(\t\x12\x1b\n\x13message_end_markers\x18\x08 \x03(\t\x12\x36\n\x0fprefix_boundary\x18\t \x01(\x0b\x32\x1d.flare.runtime.PrefixBoundary\x12\x35\n\x0cimage_tokens\x18\n \x01(\x0b\x32\x1f.flare.runtime.ImageTokenLayoutB\x14\n\x12_image_preparationB\x0f\n\r_image_layout\"1\n\x07\x43luster\x12\r\n\x05world\x18\x01 \x01(\r\x12\x11\n\texport_id\x18\x03 \x01(\tJ\x04\x08\x02\x10\x03\"\x8c\x03\n\x19\x44\x65\x66\x61ultSamplingParameters\x12\x11\n\x04seed\x18\x01 \x01(\x04H\x00\x88\x01\x01\x12\x18\n\x0btemperature\x18\x02 \x01(\x02H\x01\x88\x01\x01\x12\x12\n\x05top_k\x18\x03 \x01(\x05H\x02\x88\x01\x01\x12\x12\n\x05top_p\x18\x04 \x01(\x02H\x03\x88\x01\x01\x12\x12\n\x05min_p\x18\x05 \x01(\x02H\x04\x88\x01\x01\x12\x1f\n\x12repetition_penalty\x18\x06 \x01(\x02H\x05\x88\x01\x01\x12\x1d\n\x10presence_penalty\x18\x07 \x01(\x02H\x06\x88\x01\x01\x12\x1e\n\x11\x66requency_penalty\x18\x08 \x01(\x02H\x07\x88\x01\x01\x12-\n\x06ranges\x18\t \x01(\x0b\x32\x1d.flare.runtime.SamplingRangesB\x07\n\x05_seedB\x0e\n\x0c_temperatureB\x08\n\x06_top_kB\x08\n\x06_top_pB\x08\n\x06_min_pB\x15\n\x13_repetition_penaltyB\x13\n\x11_presence_penaltyB\x14\n\x12_frequency_penalty\"H\n\x12SamplingFloatRange\x12\x10\n\x03min\x18\x01 \x01(\x02H\x00\x88\x01\x01\x12\x10\n\x03max\x18\x02 \x01(\x02H\x01\x88\x01\x01\x42\x06\n\x04_minB\x06\n\x04_max\"F\n\x10SamplingIntRange\x12\x10\n\x03min\x18\x01 \x01(\x05H\x00\x88\x01\x01\x12\x10\n\x03max\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\x06\n\x04_minB\x06\n\x04_max\"\x96\x03\n\x0eSamplingRanges\x12\x36\n\x0btemperature\x18\x01 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12.\n\x05top_k\x18\x02 \x01(\x0b\x32\x1f.flare.runtime.SamplingIntRange\x12\x30\n\x05top_p\x18\x03 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12\x30\n\x05min_p\x18\x04 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12=\n\x12repetition_penalty\x18\x05 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12;\n\x10presence_penalty\x18\x06 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\x12<\n\x11\x66requency_penalty\x18\x07 \x01(\x0b\x32!.flare.runtime.SamplingFloatRange\"\xc5\x02\n\x10\x46rontendSettings\x12\x33\n\ttokenizer\x18\x01 \x01(\x0b\x32 .flare.runtime.TokenizerSettings\x12+\n\x05image\x18\x02 \x01(\x0b\x32\x1c.flare.runtime.ImageSettings\x12\x15\n\reos_token_ids\x18\x03 \x03(\r\x12:\n\x11template_encoding\x18\x04 \x01(\x0e\x32\x1f.flare.runtime.TemplateEncoding\x12\x34\n\x0eprompt_encoder\x18\x05 \x01(\x0e\x32\x1c.flare.runtime.PromptEncoder\x12\'\n\x1aimage_placeholder_token_id\x18\x06 \x01(\rH\x00\x88\x01\x01\x42\x1d\n\x1b_image_placeholder_token_id\"\xdc\x02\n\x11TokenizerSettings\x12\x16\n\tbos_token\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x16\n\teos_token\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x16\n\tunk_token\x18\x03 \x01(\tH\x02\x88\x01\x01\x12\x16\n\tsep_token\x18\x04 \x01(\tH\x03\x88\x01\x01\x12\x16\n\tpad_token\x18\x05 \x01(\tH\x04\x88\x01\x01\x12\x16\n\tcls_token\x18\x06 \x01(\tH\x05\x88\x01\x01\x12\x17\n\nmask_token\x18\x07 \x01(\tH\x06\x88\x01\x01\x12;\n\x19\x61\x64\x64itional_special_tokens\x18\x08 \x01(\x0b\x32\x18.flare.runtime.TokenListB\x0c\n\n_bos_tokenB\x0c\n\n_eos_tokenB\x0c\n\n_unk_tokenB\x0c\n\n_sep_tokenB\x0c\n\n_pad_tokenB\x0c\n\n_cls_tokenB\r\n\x0b_mask_token\"\x1b\n\tTokenList\x12\x0e\n\x06values\x18\x01 \x03(\t\"\xb2\x04\n\rImageSettings\x12\x30\n\x04qwen\x18\x01 \x01(\x0b\x32 .flare.runtime.QwenImageSettingsH\x00\x12\x30\n\x04mimo\x18\x02 \x01(\x0b\x32 .flare.runtime.MimoImageSettingsH\x00\x12)\n\tdeepseek4\x18\x03 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12\'\n\x07moonvit\x18\x04 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12$\n\x04step\x18\x05 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12%\n\x05radio\x18\x06 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12J\n\x12\x64\x65\x65pseek_row_major\x18\x07 \x01(\x0b\x32,.flare.runtime.DeepseekRowMajorImageSettingsH\x00\x12#\n\x03glm\x18\x08 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12=\n\x0bpatch_merge\x18\t \x01(\x0b\x32&.flare.runtime.PatchMergeImageSettingsH\x00\x12+\n\x0bpadded_grid\x18\n \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12\x34\n\x06gemma4\x18\x0b \x01(\x0b\x32\".flare.runtime.Gemma4ImageSettingsH\x00\x42\t\n\x07profile\"\xb9\x01\n\x17PatchMergeImageSettings\x12\x12\n\npatch_size\x18\x01 \x01(\r\x12\x12\n\nmin_pixels\x18\x02 \x01(\x04\x12\x12\n\nmax_pixels\x18\x03 \x01(\x04\x12\x12\n\nimage_mean\x18\x04 \x03(\x02\x12\x11\n\timage_std\x18\x05 \x03(\x02\x12\x13\n\x0bimage_token\x18\x06 \x01(\t\x12\x13\n\x0bstart_token\x18\x07 \x01(\t\x12\x11\n\tend_token\x18\x08 \x01(\t\"\x9c\x01\n\x13Gemma4ImageSettings\x12\x12\n\npatch_size\x18\x01 \x01(\r\x12\x1b\n\x13pooling_kernel_size\x18\x02 \x01(\r\x12\x17\n\x0fmax_soft_tokens\x18\x03 \x01(\r\x12\x13\n\x0bimage_token\x18\x04 \x01(\t\x12\x13\n\x0bstart_token\x18\x05 \x01(\t\x12\x11\n\tend_token\x18\x06 \x01(\t\"\x87\x01\n\x1d\x44\x65\x65pseekRowMajorImageSettings\x12\x12\n\nmin_pixels\x18\x01 \x01(\x04\x12\x12\n\nmax_tokens\x18\x02 \x01(\x04\x12#\n\x16max_width_height_ratio\x18\x03 \x01(\x04H\x00\x88\x01\x01\x42\x19\n\x17_max_width_height_ratio\"\x82\x01\n\x11QwenImageSettings\x12\x12\n\nmin_pixels\x18\x01 \x01(\x04\x12\x12\n\nmax_pixels\x18\x02 \x01(\x04\x12\x15\n\rposition_side\x18\x03 \x01(\r\x12\x16\n\x0eimage_token_id\x18\x04 \x01(\r\x12\x16\n\x0evideo_token_id\x18\x05 \x01(\r\"b\n\x11MimoImageSettings\x12\x12\n\nmin_pixels\x18\x01 \x01(\x04\x12\x12\n\nmax_pixels\x18\x02 \x01(\x04\x12\x12\n\nimage_mean\x18\x03 \x03(\x02\x12\x11\n\timage_std\x18\x04 \x03(\x02\"|\n\x06\x45ngram\x12\x11\n\ttoken_map\x18\x01 \x03(\r\x12\x14\n\x0cpad_token_id\x18\x02 \x01(\r\x12\x1d\n\x15\x63ompressed_vocabulary\x18\x03 \x01(\r\x12*\n\x06tables\x18\x04 \x03(\x0b\x32\x1a.flare.runtime.EngramTable\"\x99\x04\n\x0b\x45ngramTable\x12\r\n\x05layer\x18\x01 \x01(\r\x12\x0c\n\x04rows\x18\x02 \x01(\x04\x12\x17\n\x0f\x65mbedding_width\x18\x03 \x01(\r\x12\x13\n\x0bscale_block\x18\x04 \x01(\r\x12$\n\x07weights\x18\x05 \x01(\x0b\x32\x13.flare.runtime.Span\x12#\n\x06scales\x18\x06 \x01(\x0b\x32\x13.flare.runtime.Span\x12\'\n\x04hash\x18\x07 \x01(\x0b\x32\x19.flare.runtime.EngramHash\x12\x15\n\rweight_buffer\x18\x08 \x01(\t\x12\x14\n\x0cscale_buffer\x18\t \x01(\t\x12\x13\n\x0bhash_buffer\x18\n \x01(\t\x12\x13\n\x0bready_event\x18\x0b \x01(\t\x12\x35\n\x08\x65ncoding\x18\x0c \x01(\x0e\x32#.flare.runtime.EngramTable.Encoding\x12\x16\n\x0erequest_buffer\x18\r \x01(\t\x12\x14\n\x0cglobal_scale\x18\x0e \x01(\x02\x12/\n\x06shards\x18\x0f \x03(\x0b\x32\x1f.flare.runtime.EngramTableShard\x12\x17\n\x0fprefetch_buffer\x18\x10 \x01(\t\"E\n\x08\x45ncoding\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x11\n\rFP8_E4M3_E8M0\x10\x01\x12\x15\n\x11NVFP4_E4M3_GLOBAL\x10\x02\"\x8c\x01\n\x10\x45ngramTableShard\x12\x0c\n\x04rank\x18\x01 \x01(\r\x12\x11\n\tfirst_row\x18\x02 \x01(\x04\x12\x0c\n\x04rows\x18\x03 \x01(\x04\x12$\n\x07weights\x18\x04 \x01(\x0b\x32\x13.flare.runtime.Span\x12#\n\x06scales\x18\x05 \x01(\x0b\x32\x13.flare.runtime.Span\"\xc3\x01\n\nEngramHash\x12\x30\n\x06method\x18\x01 \x01(\x0e\x32 .flare.runtime.EngramHash.Method\x12\x0e\n\x06orders\x18\x02 \x03(\r\x12\x13\n\x0bmultipliers\x18\x03 \x03(\x04\x12\x0e\n\x06primes\x18\x04 \x03(\x04\x12\x0f\n\x07offsets\x18\x05 \x03(\x04\"=\n\x06Method\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nXOR_MODULO\x10\x01\x12\x12\n\x0e\x45OS_XOR_MODULO\x10\x02\"K\n\x05\x41sset\x12\x0c\n\x04name\x18\x01 \x01(\t\x12$\n\x07payload\x18\x02 \x01(\x0b\x32\x13.flare.runtime.Span\x12\x0e\n\x06sha256\x18\x03 \x01(\t\"\xd3\x04\n\x0b\x42undleIndex\x12\x14\n\x0c\x61rchitecture\x18\x01 \x03(\x05\x12.\n\x0b\x61llocations\x18\x02 \x03(\x0b\x32\x19.flare.runtime.Allocation\x12&\n\x07modules\x18\x03 \x03(\x0b\x32\x15.flare.runtime.Module\x12*\n\tfunctions\x18\x04 \x03(\x0b\x32\x17.flare.runtime.Function\x12)\n\x06graphs\x18\x05 \x03(\x0b\x32\x19.flare.runtime.GraphIndex\x12\x30\n\x0creservations\x18\x06 \x03(\x0b\x32\x1a.flare.runtime.Reservation\x12+\n\texecution\x18\x07 \x01(\x0b\x32\x18.flare.runtime.Execution\x12\'\n\x07\x63ontext\x18\x08 \x01(\x0b\x32\x16.flare.runtime.Context\x12<\n\tresources\x18\t \x03(\x0b\x32).flare.runtime.BundleIndex.ResourcesEntry\x12\x0e\n\x06\x65vents\x18\n \x03(\t\x12*\n\x04roce\x18\x0b \x01(\x0b\x32\x1c.flare.runtime.RoceTransport\x12\x36\n\x0frebuild_weights\x18\x0c \x01(\x0b\x32\x1d.flare.runtime.RebuildWeights\x1a\x45\n\x0eResourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\"\n\x05value\x18\x02 \x01(\x0b\x32\x13.flare.runtime.Span:\x02\x38\x01\"\xf8\x01\n\rRoceTransport\x12\x11\n\tproxy_abi\x18\x01 \x01(\r\x12\r\n\x05world\x18\x02 \x01(\r\x12\x0c\n\x04rank\x18\x03 \x01(\r\x12\x16\n\x0eregion_address\x18\x04 \x01(\x04\x12\x14\n\x0cregion_bytes\x18\x05 \x01(\x04\x12\x18\n\x10\x63ounters_address\x18\x06 \x01(\x04\x12\x16\n\x0e\x63ounters_bytes\x18\x07 \x01(\x04\x12\x12\n\nslot_bytes\x18\x08 \x01(\x04\x12\x12\n\npipe_bytes\x18\t \x01(\x04\x12\x13\n\x0b\x63trl_offset\x18\n \x01(\x04\x12\x14\n\x0cvarlen_bytes\x18\x10 \x01(\x04J\x04\x08\x0b\x10\x10\"v\n\nGraphIndex\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05\x66lags\x18\x02 \x01(\x04\x12\x10\n\x08resource\x18\x03 \x01(\t\x12\x12\n\nnode_count\x18\x04 \x01(\x04\x12\x12\n\nedge_count\x18\x05 \x01(\x04\x12\x11\n\tfunctions\x18\x06 \x03(\x04\"M\n\nPeerMemory\x12\r\n\x05owner\x18\x01 \x01(\r\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\x04\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04\x12\x0f\n\x07readers\x18\x04 \x03(\r\"M\n\x07\x43ontext\x12\r\n\x05\x66lags\x18\x01 \x01(\r\x12\r\n\x05\x63\x61\x63he\x18\x02 \x01(\x05\x12$\n\x06limits\x18\x03 \x03(\x0b\x32\x14.flare.runtime.Limit\"\"\n\x05Limit\x12\n\n\x02id\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x04\".\n\x0bReservation\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\"8\n\x04Span\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\x12\x10\n\x08\x66ilename\x18\x03 \x01(\t\"\xa2\x02\n\nAllocation\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\x12\x11\n\talignment\x18\x03 \x01(\x04\x12\x11\n\x04\x66ile\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\'\n\ndata_spans\x18\x05 \x03(\x0b\x32\x13.flare.runtime.Span\x12.\n\x0brelocations\x18\x06 \x03(\x0b\x32\x19.flare.runtime.Relocation\x12\x14\n\x07\x61\x64\x64ress\x18\x07 \x01(\x04H\x01\x88\x01\x01\x12%\n\x06memory\x18\x08 \x01(\x0e\x32\x15.flare.runtime.Memory\x12%\n\x06sizing\x18\t \x01(\x0b\x32\x15.flare.runtime.SizingB\x07\n\x05_fileB\n\n\x08_address\"X\n\x06Sizing\x12)\n\x08\x63\x61pacity\x18\x01 \x01(\x0e\x32\x17.flare.runtime.Capacity\x12\x12\n\nunit_bytes\x18\x02 \x01(\x04\x12\x0f\n\x07maximum\x18\x03 \x01(\x04\"L\n\x06Module\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x66ile\x18\x02 \x01(\t\x12&\n\x07globals\x18\x03 \x03(\x0b\x32\x15.flare.runtime.Global\"f\n\x06Global\x12\x0e\n\x06symbol\x18\x01 \x01(\t\x12\x0c\n\x04\x66ile\x18\x02 \x01(\t\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04\x12.\n\x0brelocations\x18\x04 \x03(\x0b\x32\x19.flare.runtime.Relocation\"y\n\x08\x46unction\x12\x0e\n\x06module\x18\x01 \x01(\t\x12\x0e\n\x06symbol\x18\x02 \x01(\t\x12\x17\n\x0fparameter_sizes\x18\x03 \x03(\x04\x12\x34\n\nattributes\x18\x04 \x03(\x0b\x32 .flare.runtime.FunctionAttribute\".\n\x11\x46unctionAttribute\x12\n\n\x02id\x18\x01 \x01(\x05\x12\r\n\x05value\x18\x02 \x01(\x05\"/\n\tReference\x12\x12\n\nallocation\x18\x01 \x01(\t\x12\x0e\n\x06offset\x18\x02 \x01(\x04\"s\n\nRelocation\x12\x0e\n\x06offset\x18\x01 \x01(\x04\x12(\n\x06target\x18\x02 \x01(\x0b\x32\x18.flare.runtime.Reference\x12+\n\x04kind\x18\x03 \x01(\x0e\x32\x1d.flare.runtime.RelocationKind\"D\n\x04\x42lob\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\x12.\n\x0brelocations\x18\x02 \x03(\x0b\x32\x19.flare.runtime.Relocation\";\n\tAttribute\x12\n\n\x02id\x18\x01 \x01(\x05\x12\"\n\x05value\x18\x02 \x01(\x0b\x32\x13.flare.runtime.Blob\"\x9d\x01\n\x06Kernel\x12\x10\n\x08\x66unction\x18\x01 \x01(\x04\x12\x0c\n\x04grid\x18\x02 \x03(\r\x12\r\n\x05\x62lock\x18\x03 \x03(\r\x12\x0e\n\x06shared\x18\x04 \x01(\r\x12&\n\targuments\x18\x05 \x03(\x0b\x32\x13.flare.runtime.Blob\x12,\n\nattributes\x18\x06 \x03(\x0b\x32\x18.flare.runtime.Attribute\"\x8a\x01\n\x06Memset\x12-\n\x0b\x64\x65stination\x18\x01 \x01(\x0b\x32\x18.flare.runtime.Reference\x12\r\n\x05pitch\x18\x02 \x01(\x04\x12\r\n\x05value\x18\x03 \x01(\r\x12\x14\n\x0c\x65lement_size\x18\x04 \x01(\r\x12\r\n\x05width\x18\x05 \x01(\x04\x12\x0e\n\x06height\x18\x06 \x01(\x04\"o\n\x04\x43opy\x12(\n\x06source\x18\x01 \x01(\x0b\x32\x18.flare.runtime.Reference\x12-\n\x0b\x64\x65stination\x18\x02 \x01(\x0b\x32\x18.flare.runtime.Reference\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04\"\x07\n\x05\x45mpty\"\x1a\n\tEventWait\x12\r\n\x05\x65vent\x18\x01 \x01(\t\"\xe1\x01\n\x04Node\x12\'\n\x06kernel\x18\x01 \x01(\x0b\x32\x15.flare.runtime.KernelH\x00\x12\'\n\x06memset\x18\x02 \x01(\x0b\x32\x15.flare.runtime.MemsetH\x00\x12#\n\x04\x63opy\x18\x03 \x01(\x0b\x32\x13.flare.runtime.CopyH\x00\x12%\n\x05\x65mpty\x18\x04 \x01(\x0b\x32\x14.flare.runtime.EmptyH\x00\x12.\n\nevent_wait\x18\x05 \x01(\x0b\x32\x18.flare.runtime.EventWaitH\x00\x42\x0b\n\toperation\"9\n\x04\x45\x64ge\x12\x0e\n\x06source\x18\x01 \x01(\x04\x12\x13\n\x0b\x64\x65stination\x18\x02 \x01(\x04\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\xb9\x02\n\tExecution\x12\x13\n\x0b\x61\x62i_version\x18\x01 \x01(\r\x12\x12\n\nmax_active\x18\x02 \x01(\x04\x12\x19\n\x11input_frame_bytes\x18\x03 \x01(\x04\x12&\n\x07\x62uffers\x18\x04 \x03(\x0b\x32\x15.flare.runtime.Buffer\x12-\n\x06graphs\x18\x05 \x03(\x0b\x32\x1d.flare.runtime.ExecutionGraph\x12\x31\n\rtuning_graphs\x18\x06 \x03(\x0b\x32\x1a.flare.runtime.TuningGraph\x12!\n\x19\x63ompletion_token_capacity\x18\x07 \x01(\r\x12;\n\x12persistent_workers\x18\x08 \x03(\x0b\x32\x1f.flare.runtime.PersistentWorker\"\xa9\x01\n\x10PersistentWorker\x12\x17\n\x0fworker_sm_count\x18\x01 \x01(\r\x12\r\n\x05graph\x18\x02 \x01(\t\x12+\n\tstop_flag\x18\x03 \x01(\x0b\x32\x18.flare.runtime.Reference\x12)\n\x07metrics\x18\x04 \x01(\x0b\x32\x18.flare.runtime.Reference\x12\x15\n\rmetrics_count\x18\x05 \x01(\r\"C\n\x0bTuningGraph\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07outputs\x18\x02 \x03(\t\x12\x15\n\rstatus_buffer\x18\x03 \x01(\t\"\x82\x01\n\x06\x42uffer\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06nbytes\x18\x02 \x01(\x04\x12\r\n\x05\x64type\x18\x03 \x01(\t\x12\r\n\x05shape\x18\x04 \x03(\x04\x12\x0f\n\x07strides\x18\x05 \x03(\x04\x12+\n\treference\x18\x06 \x01(\x0b\x32\x18.flare.runtime.Reference\"\x95\x04\n\x0e\x45xecutionGraph\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04kind\x18\x02 \x01(\t\x12\x15\n\rsampling_mode\x18\x03 \x01(\t\x12\x16\n\x0e\x62\x61tch_capacity\x18\x04 \x01(\x04\x12\x16\n\x0etoken_capacity\x18\x05 \x01(\x04\x12\x33\n\x0einput_bindings\x18\x06 \x03(\x0b\x32\x1b.flare.runtime.InputBinding\x12\x19\n\x0c\x64raft_tokens\x18\x07 \x01(\rH\x00\x88\x01\x01\x12\x1a\n\rverify_tokens\x18\x08 \x01(\rH\x01\x88\x01\x01\x12\x30\n\x0c\x64raft_source\x18\t \x01(\x0e\x32\x1a.flare.runtime.DraftSource\x12 \n\x13speculation_enabled\x18\n \x01(\x08H\x02\x88\x01\x01\x12\x1d\n\x15\x65stimated_duration_ns\x18\x0b \x01(\x04\x12\x18\n\x10prefill_capacity\x18\x0c \x01(\x04\x12\x1d\n\x15packed_token_capacity\x18\r \x01(\x04\x12\x18\n\x10\x63onfidence_width\x18\x0e \x01(\r\x12\x33\n\x0etuned_bindings\x18\x0f \x03(\x0b\x32\x1b.flare.runtime.TunedBindingB\x0f\n\r_draft_tokensB\x10\n\x0e_verify_tokensB\x16\n\x14_speculation_enabled\"H\n\x0cInputBinding\x12\x13\n\x0b\x62uffer_name\x18\x01 \x01(\t\x12\x13\n\x0bhost_offset\x18\x02 \x01(\x04\x12\x0e\n\x06nbytes\x18\x03 \x01(\x04*\xfa\x01\n\x19PreparationParameterScope\x12+\n\'PREPARATION_PARAMETER_SCOPE_UNSPECIFIED\x10\x00\x12*\n&PREPARATION_PARAMETER_SCOPE_DEPLOYMENT\x10\x01\x12\'\n#PREPARATION_PARAMETER_SCOPE_COMBINE\x10\x02\x12-\n)PREPARATION_PARAMETER_SCOPE_TARGET_WEIGHT\x10\x03\x12,\n(PREPARATION_PARAMETER_SCOPE_DRAFT_WEIGHT\x10\x04*\x8e\x01\n\x0bHistoryKind\x12\x17\n\x13HISTORY_UNSPECIFIED\x10\x00\x12\x13\n\x0fPAGED_KEY_VALUE\x10\x01\x12\x10\n\x0cPAGED_LATENT\x10\x02\x12\x12\n\x0eSLIDING_WINDOW\x10\x03\x12\x13\n\x0fRECURRENT_STATE\x10\x04\x12\x16\n\x12\x43ONTINUATION_STATE\x10\x05*\xc7\x07\n\x0bValueSource\x12\x15\n\x11VALUE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43ONSTANT\x10\x01\x12\x10\n\x0cREQUEST_SLOT\x10\x02\x12\x16\n\x12REQUEST_GENERATION\x10\x03\x12\r\n\tLIVE_ROWS\x10\x04\x12\x10\n\x0cQUERY_LENGTH\x10\x05\x12\x12\n\x0eSAMPLE_ENABLED\x10\x06\x12\x10\n\x0cPROMPT_TOKEN\x10\x07\x12\x11\n\rPENDING_TOKEN\x10\x08\x12\x1c\n\x18PROMPT_AND_PENDING_TOKEN\x10\t\x12\x13\n\x0fPROMPT_POSITION\x10\n\x12\x17\n\x13IMAGE_FEATURE_INDEX\x10\x0b\x12\x16\n\x12IMAGE_LEFT_CONTEXT\x10\x0c\x12\x17\n\x13IMAGE_RIGHT_CONTEXT\x10\r\x12\x0e\n\nPAGE_TABLE\x10\x0e\x12\x13\n\x0fLIVE_STATE_ROWS\x10\x0f\x12\x12\n\x0eLIVE_STATE_ROW\x10\x10\x12\x14\n\x10PREFIX_STATE_ROW\x10\x11\x12\x16\n\x12SNAPSHOT_STATE_ROW\x10\x12\x12\x13\n\x0f\x43ONSUMED_TOKENS\x10\x13\x12\x1c\n\x18SNAPSHOT_CONSUMED_TOKENS\x10\x14\x12\x0f\n\x0bPREFILL_ROW\x10\x15\x12\x11\n\rSAMPLING_SEED\x10\x16\x12\x17\n\x13SAMPLING_PARAMETERS\x10\x17\x12\x12\n\x0eSAMPLING_TOP_K\x10\x18\x12\x12\n\x0eMAX_NEW_TOKENS\x10\x19\x12\x11\n\rEOS_TOKEN_IDS\x10\x1a\x12\r\n\tEOS_COUNT\x10\x1b\x12\x14\n\x10PROMPT_HISTOGRAM\x10\x1c\x12\x10\n\x0cGRAMMAR_MASK\x10\x1d\x12\x13\n\x0fGRAMMAR_ENABLED\x10\x1e\x12\x12\n\x0e\x43OPY_TOKEN_IDS\x10\x1f\x12\x14\n\x10\x43OPY_TOKEN_COUNT\x10 \x12\x18\n\x14\x43OPY_CONSUMED_TOKENS\x10!\x12\x13\n\x0f\x43OPY_GENERATION\x10\"\x12\x15\n\x11\x43OPY_GRAMMAR_MASK\x10#\x12\x16\n\x12\x43OPY_GRAMMAR_COUNT\x10$\x12\x10\n\x0cIMAGE_TENSOR\x10%\x12\x16\n\x12IMAGE_FEATURE_SLOT\x10&\x12\x17\n\x13PROMPT_TARGET_TOKEN\x10\'\x12\x1c\n\x18SPECULATIVE_PREFIX_LIMIT\x10(\x12\x1a\n\x16PROMPT_LOOKAHEAD_TOKEN\x10)\x12\x1b\n\x17PROMPT_LOOKAHEAD_LENGTH\x10*\x12\x12\n\x0e\x43ORE_PARAMETER\x10+*|\n\rInputIndexing\x12\x18\n\x14INDEXING_UNSPECIFIED\x10\x00\x12\n\n\x06SCALAR\x10\x01\x12\x12\n\x0eSUBMISSION_ROW\x10\x02\x12\x0f\n\x0bREQUEST_ROW\x10\x03\x12\x10\n\x0cPACKED_TOKEN\x10\x04\x12\x0e\n\nACTIVE_ROW\x10\x05*T\n\x0fStateAccessKind\x12\x1c\n\x18STATE_ACCESS_UNSPECIFIED\x10\x00\x12\x08\n\x04READ\x10\x01\x12\t\n\x05WRITE\x10\x02\x12\x0e\n\nREAD_WRITE\x10\x03*\x8b\x02\n\x0eGraphOperation\x12\x1f\n\x1bGRAPH_OPERATION_UNSPECIFIED\x10\x00\x12\x08\n\x04INIT\x10\x01\x12\x0b\n\x07RESTORE\x10\x02\x12\x0c\n\x08SNAPSHOT\x10\x03\x12\x0b\n\x07PREFILL\x10\x04\x12\n\n\x06\x44\x45\x43ODE\x10\x05\x12\n\n\x06RESUME\x10\x06\x12\n\n\x06VISION\x10\x07\x12\x0f\n\x0bSPECULATIVE\x10\x08\x12\t\n\x05MIXED\x10\t\x12\x12\n\x0eSCORED_PREFILL\x10\x0c\x12\x14\n\x10TERMINAL_PREFILL\x10\x0e\"\x04\x08\n\x10\n\"\x04\x08\x0b\x10\x0b\"\x04\x08\r\x10\r*\x08PROPOSAL*\x0cVERIFICATION*\x12PACKED_SPECULATIVE*\xb2\x01\n\x0eToolParserKind\x12\x1b\n\x17TOOL_PARSER_UNSPECIFIED\x10\x00\x12\x0e\n\nQWEN_CODER\x10\x01\x12\x15\n\x11GLM_ARGUMENT_TAGS\x10\x02\x12\x08\n\x04\x44SML\x10\x03\x12\x08\n\x04XTML\x10\x04\x12\x0f\n\x0bMINIMAX_XML\x10\x05\x12\x0e\n\nGEMMA_CALL\x10\x06\x12\x08\n\x04\x41TEM\x10\x07\x12\x0c\n\x08TML_JSON\x10\x08\x12\x0f\n\x0bTAGGED_JSON\x10\t*\xa6\x01\n\x13ReasoningParserKind\x12 \n\x1cREASONING_PARSER_UNSPECIFIED\x10\x00\x12\x0e\n\nTHINK_TAGS\x10\x01\x12\x0e\n\nXTML_THINK\x10\x02\x12\x0c\n\x08MM_THINK\x10\x03\x12\x13\n\x0f\x43HANNEL_THOUGHT\x10\x04\x12\x15\n\x11RECIPIENT_HEADERS\x10\x05\x12\x13\n\x0f\x43ONTENT_HEADERS\x10\x06*\x92\x03\n\x14ImagePreparationKind\x12!\n\x1dIMAGE_PREPARATION_UNSPECIFIED\x10\x00\x12\x1a\n\x16QWEN_IMAGE_PREPARATION\x10\x01\x12\x1a\n\x16MIMO_IMAGE_PREPARATION\x10\x02\x12\x1e\n\x1a\x44\x45\x45PSEEK_IMAGE_PREPARATION\x10\x03\x12\x1d\n\x19MOONVIT_IMAGE_PREPARATION\x10\x04\x12\x1a\n\x16STEP_IMAGE_PREPARATION\x10\x05\x12\x1b\n\x17RADIO_IMAGE_PREPARATION\x10\x06\x12(\n$DEEPSEEK_ROW_MAJOR_IMAGE_PREPARATION\x10\x07\x12\x19\n\x15GLM_IMAGE_PREPARATION\x10\x08\x12!\n\x1dPATCH_MERGE_IMAGE_PREPARATION\x10\t\x12!\n\x1dPADDED_GRID_IMAGE_PREPARATION\x10\n\x12\x1c\n\x18GEMMA4_IMAGE_PREPARATION\x10\x0b*\xb6\x02\n\x0fImageLayoutKind\x12\x1c\n\x18IMAGE_LAYOUT_UNSPECIFIED\x10\x00\x12\x15\n\x11QWEN_IMAGE_LAYOUT\x10\x01\x12\x15\n\x11MIMO_IMAGE_LAYOUT\x10\x02\x12\x19\n\x15\x44\x45\x45PSEEK_IMAGE_LAYOUT\x10\x03\x12\x18\n\x14MOONVIT_IMAGE_LAYOUT\x10\x04\x12\x15\n\x11STEP_IMAGE_LAYOUT\x10\x05\x12\x16\n\x12RADIO_IMAGE_LAYOUT\x10\x06\x12#\n\x1f\x44\x45\x45PSEEK_ROW_MAJOR_IMAGE_LAYOUT\x10\x07\x12\x14\n\x10GLM_IMAGE_LAYOUT\x10\x08\x12\x1a\n\x16\x42RACKETED_IMAGE_LAYOUT\x10\t\x12\x1c\n\x18\x43LASS_TOKEN_IMAGE_LAYOUT\x10\n*P\n\rPromptEncoder\x12\x10\n\x0cPROMPT_JINJA\x10\x00\x12\x0f\n\x0b\x44\x45\x45PSEEK_V4\x10\x01\x12\x10\n\x0c\x44\x45\x45PSEEK_V41\x10\x02\x12\n\n\x06TML_V0\x10\x03*B\n\x10TemplateEncoding\x12\x11\n\rTEMPLATE_TEXT\x10\x00\x12\x1b\n\x17TEMPLATE_TOKEN_SEGMENTS\x10\x01*/\n\x06Memory\x12\n\n\x06\x44\x45VICE\x10\x00\x12\x0f\n\x0bMAPPED_HOST\x10\x01\x12\x08\n\x04PEER\x10\x02*(\n\x08\x43\x61pacity\x12\x0e\n\nSTATE_ROWS\x10\x00\x12\x0c\n\x08KV_PAGES\x10\x01*-\n\x0eRelocationKind\x12\x0b\n\x07POINTER\x10\x00\x12\x0e\n\nTENSOR_MAP\x10\x01*4\n\x0b\x44raftSource\x12\x0c\n\x08NO_DRAFT\x10\x00\x12\x07\n\x03MTP\x10\x01\x12\x0e\n\nCOPY_DRAFT\x10\x02\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -39,38 +39,38 @@ _globals['_REBUILDSPECULATION']._serialized_options = b'\030\001' _globals['_BUNDLEINDEX_RESOURCESENTRY']._loaded_options = None _globals['_BUNDLEINDEX_RESOURCESENTRY']._serialized_options = b'8\001' - _globals['_PREPARATIONPARAMETERSCOPE']._serialized_start=16373 - _globals['_PREPARATIONPARAMETERSCOPE']._serialized_end=16623 - _globals['_HISTORYKIND']._serialized_start=16626 - _globals['_HISTORYKIND']._serialized_end=16768 - _globals['_VALUESOURCE']._serialized_start=16771 - _globals['_VALUESOURCE']._serialized_end=17738 - _globals['_INPUTINDEXING']._serialized_start=17740 - _globals['_INPUTINDEXING']._serialized_end=17864 - _globals['_STATEACCESSKIND']._serialized_start=17866 - _globals['_STATEACCESSKIND']._serialized_end=17950 - _globals['_GRAPHOPERATION']._serialized_start=17953 - _globals['_GRAPHOPERATION']._serialized_end=18220 - _globals['_TOOLPARSERKIND']._serialized_start=18223 - _globals['_TOOLPARSERKIND']._serialized_end=18401 - _globals['_REASONINGPARSERKIND']._serialized_start=18404 - _globals['_REASONINGPARSERKIND']._serialized_end=18570 - _globals['_IMAGEPREPARATIONKIND']._serialized_start=18573 - _globals['_IMAGEPREPARATIONKIND']._serialized_end=18945 - _globals['_IMAGELAYOUTKIND']._serialized_start=18948 - _globals['_IMAGELAYOUTKIND']._serialized_end=19258 - _globals['_PROMPTENCODER']._serialized_start=19260 - _globals['_PROMPTENCODER']._serialized_end=19340 - _globals['_TEMPLATEENCODING']._serialized_start=19342 - _globals['_TEMPLATEENCODING']._serialized_end=19408 - _globals['_MEMORY']._serialized_start=19410 - _globals['_MEMORY']._serialized_end=19457 - _globals['_CAPACITY']._serialized_start=19459 - _globals['_CAPACITY']._serialized_end=19499 - _globals['_RELOCATIONKIND']._serialized_start=19501 - _globals['_RELOCATIONKIND']._serialized_end=19546 - _globals['_DRAFTSOURCE']._serialized_start=19548 - _globals['_DRAFTSOURCE']._serialized_end=19600 + _globals['_PREPARATIONPARAMETERSCOPE']._serialized_start=16610 + _globals['_PREPARATIONPARAMETERSCOPE']._serialized_end=16860 + _globals['_HISTORYKIND']._serialized_start=16863 + _globals['_HISTORYKIND']._serialized_end=17005 + _globals['_VALUESOURCE']._serialized_start=17008 + _globals['_VALUESOURCE']._serialized_end=17975 + _globals['_INPUTINDEXING']._serialized_start=17977 + _globals['_INPUTINDEXING']._serialized_end=18101 + _globals['_STATEACCESSKIND']._serialized_start=18103 + _globals['_STATEACCESSKIND']._serialized_end=18187 + _globals['_GRAPHOPERATION']._serialized_start=18190 + _globals['_GRAPHOPERATION']._serialized_end=18457 + _globals['_TOOLPARSERKIND']._serialized_start=18460 + _globals['_TOOLPARSERKIND']._serialized_end=18638 + _globals['_REASONINGPARSERKIND']._serialized_start=18641 + _globals['_REASONINGPARSERKIND']._serialized_end=18807 + _globals['_IMAGEPREPARATIONKIND']._serialized_start=18810 + _globals['_IMAGEPREPARATIONKIND']._serialized_end=19212 + _globals['_IMAGELAYOUTKIND']._serialized_start=19215 + _globals['_IMAGELAYOUTKIND']._serialized_end=19525 + _globals['_PROMPTENCODER']._serialized_start=19527 + _globals['_PROMPTENCODER']._serialized_end=19607 + _globals['_TEMPLATEENCODING']._serialized_start=19609 + _globals['_TEMPLATEENCODING']._serialized_end=19675 + _globals['_MEMORY']._serialized_start=19677 + _globals['_MEMORY']._serialized_end=19724 + _globals['_CAPACITY']._serialized_start=19726 + _globals['_CAPACITY']._serialized_end=19766 + _globals['_RELOCATIONKIND']._serialized_start=19768 + _globals['_RELOCATIONKIND']._serialized_end=19813 + _globals['_DRAFTSOURCE']._serialized_start=19815 + _globals['_DRAFTSOURCE']._serialized_end=19867 _globals['_PROTECTEDINDEX']._serialized_start=38 _globals['_PROTECTEDINDEX']._serialized_end=191 _globals['_SIGNEDGROUP']._serialized_start=193 @@ -114,143 +114,145 @@ _globals['_COREPARAMETERRANGE']._serialized_start=5256 _globals['_COREPARAMETERRANGE']._serialized_end=5328 _globals['_VISIONCAPACITY']._serialized_start=5331 - _globals['_VISIONCAPACITY']._serialized_end=5475 - _globals['_CACHECONTRACT']._serialized_start=5478 - _globals['_CACHECONTRACT']._serialized_end=5662 - _globals['_CODECLAYOUT']._serialized_start=5664 - _globals['_CODECLAYOUT']._serialized_end=5778 - _globals['_CODECFIELD']._serialized_start=5780 - _globals['_CODECFIELD']._serialized_end=5858 - _globals['_HISTORYREGION']._serialized_start=5861 - _globals['_HISTORYREGION']._serialized_end=6011 - _globals['_PAGETABLEVIEW']._serialized_start=6013 - _globals['_PAGETABLEVIEW']._serialized_end=6065 - _globals['_VALUEBINDING']._serialized_start=6068 - _globals['_VALUEBINDING']._serialized_end=6264 - _globals['_STATEVIEW']._serialized_start=6266 - _globals['_STATEVIEW']._serialized_end=6341 - _globals['_STATEACCESS']._serialized_start=6343 - _globals['_STATEACCESS']._serialized_end=6444 - _globals['_COMPLETIONCURSOR']._serialized_start=6446 - _globals['_COMPLETIONCURSOR']._serialized_end=6525 - _globals['_TUNEDBINDING']._serialized_start=6527 - _globals['_TUNEDBINDING']._serialized_end=6579 - _globals['_GRAPHCONTRACT']._serialized_start=6582 - _globals['_GRAPHCONTRACT']._serialized_end=6960 - _globals['_TOOLPARSER']._serialized_start=6963 - _globals['_TOOLPARSER']._serialized_end=7099 - _globals['_REASONINGPARSER']._serialized_start=7102 - _globals['_REASONINGPARSER']._serialized_end=7251 - _globals['_PREFIXBOUNDARY']._serialized_start=7254 - _globals['_PREFIXBOUNDARY']._serialized_end=7456 - _globals['_IMAGESPAN']._serialized_start=7458 - _globals['_IMAGESPAN']._serialized_end=7579 - _globals['_IMAGETOKENLAYOUT']._serialized_start=7581 - _globals['_IMAGETOKENLAYOUT']._serialized_end=7662 - _globals['_FRONTENDCONTRACT']._serialized_start=7665 - _globals['_FRONTENDCONTRACT']._serialized_end=8163 - _globals['_CLUSTER']._serialized_start=8165 - _globals['_CLUSTER']._serialized_end=8214 - _globals['_DEFAULTSAMPLINGPARAMETERS']._serialized_start=8217 - _globals['_DEFAULTSAMPLINGPARAMETERS']._serialized_end=8613 - _globals['_SAMPLINGFLOATRANGE']._serialized_start=8615 - _globals['_SAMPLINGFLOATRANGE']._serialized_end=8687 - _globals['_SAMPLINGINTRANGE']._serialized_start=8689 - _globals['_SAMPLINGINTRANGE']._serialized_end=8759 - _globals['_SAMPLINGRANGES']._serialized_start=8762 - _globals['_SAMPLINGRANGES']._serialized_end=9168 - _globals['_FRONTENDSETTINGS']._serialized_start=9171 - _globals['_FRONTENDSETTINGS']._serialized_end=9496 - _globals['_TOKENIZERSETTINGS']._serialized_start=9499 - _globals['_TOKENIZERSETTINGS']._serialized_end=9847 - _globals['_TOKENLIST']._serialized_start=9849 - _globals['_TOKENLIST']._serialized_end=9876 - _globals['_IMAGESETTINGS']._serialized_start=9879 - _globals['_IMAGESETTINGS']._serialized_end=10387 - _globals['_PATCHMERGEIMAGESETTINGS']._serialized_start=10390 - _globals['_PATCHMERGEIMAGESETTINGS']._serialized_end=10575 - _globals['_DEEPSEEKROWMAJORIMAGESETTINGS']._serialized_start=10578 - _globals['_DEEPSEEKROWMAJORIMAGESETTINGS']._serialized_end=10713 - _globals['_QWENIMAGESETTINGS']._serialized_start=10716 - _globals['_QWENIMAGESETTINGS']._serialized_end=10846 - _globals['_MIMOIMAGESETTINGS']._serialized_start=10848 - _globals['_MIMOIMAGESETTINGS']._serialized_end=10946 - _globals['_ENGRAM']._serialized_start=10948 - _globals['_ENGRAM']._serialized_end=11072 - _globals['_ENGRAMTABLE']._serialized_start=11075 - _globals['_ENGRAMTABLE']._serialized_end=11612 - _globals['_ENGRAMTABLE_ENCODING']._serialized_start=11543 - _globals['_ENGRAMTABLE_ENCODING']._serialized_end=11612 - _globals['_ENGRAMTABLESHARD']._serialized_start=11615 - _globals['_ENGRAMTABLESHARD']._serialized_end=11755 - _globals['_ENGRAMHASH']._serialized_start=11758 - _globals['_ENGRAMHASH']._serialized_end=11953 - _globals['_ENGRAMHASH_METHOD']._serialized_start=11892 - _globals['_ENGRAMHASH_METHOD']._serialized_end=11953 - _globals['_ASSET']._serialized_start=11955 - _globals['_ASSET']._serialized_end=12030 - _globals['_BUNDLEINDEX']._serialized_start=12033 - _globals['_BUNDLEINDEX']._serialized_end=12628 - _globals['_BUNDLEINDEX_RESOURCESENTRY']._serialized_start=12559 - _globals['_BUNDLEINDEX_RESOURCESENTRY']._serialized_end=12628 - _globals['_ROCETRANSPORT']._serialized_start=12631 - _globals['_ROCETRANSPORT']._serialized_end=12879 - _globals['_GRAPHINDEX']._serialized_start=12881 - _globals['_GRAPHINDEX']._serialized_end=12999 - _globals['_PEERMEMORY']._serialized_start=13001 - _globals['_PEERMEMORY']._serialized_end=13078 - _globals['_CONTEXT']._serialized_start=13080 - _globals['_CONTEXT']._serialized_end=13157 - _globals['_LIMIT']._serialized_start=13159 - _globals['_LIMIT']._serialized_end=13193 - _globals['_RESERVATION']._serialized_start=13195 - _globals['_RESERVATION']._serialized_end=13241 - _globals['_SPAN']._serialized_start=13243 - _globals['_SPAN']._serialized_end=13299 - _globals['_ALLOCATION']._serialized_start=13302 - _globals['_ALLOCATION']._serialized_end=13592 - _globals['_SIZING']._serialized_start=13594 - _globals['_SIZING']._serialized_end=13682 - _globals['_MODULE']._serialized_start=13684 - _globals['_MODULE']._serialized_end=13760 - _globals['_GLOBAL']._serialized_start=13762 - _globals['_GLOBAL']._serialized_end=13864 - _globals['_FUNCTION']._serialized_start=13866 - _globals['_FUNCTION']._serialized_end=13987 - _globals['_FUNCTIONATTRIBUTE']._serialized_start=13989 - _globals['_FUNCTIONATTRIBUTE']._serialized_end=14035 - _globals['_REFERENCE']._serialized_start=14037 - _globals['_REFERENCE']._serialized_end=14084 - _globals['_RELOCATION']._serialized_start=14086 - _globals['_RELOCATION']._serialized_end=14201 - _globals['_BLOB']._serialized_start=14203 - _globals['_BLOB']._serialized_end=14271 - _globals['_ATTRIBUTE']._serialized_start=14273 - _globals['_ATTRIBUTE']._serialized_end=14332 - _globals['_KERNEL']._serialized_start=14335 - _globals['_KERNEL']._serialized_end=14492 - _globals['_MEMSET']._serialized_start=14495 - _globals['_MEMSET']._serialized_end=14633 - _globals['_COPY']._serialized_start=14635 - _globals['_COPY']._serialized_end=14746 - _globals['_EMPTY']._serialized_start=14748 - _globals['_EMPTY']._serialized_end=14755 - _globals['_EVENTWAIT']._serialized_start=14757 - _globals['_EVENTWAIT']._serialized_end=14783 - _globals['_NODE']._serialized_start=14786 - _globals['_NODE']._serialized_end=15011 - _globals['_EDGE']._serialized_start=15013 - _globals['_EDGE']._serialized_end=15070 - _globals['_EXECUTION']._serialized_start=15073 - _globals['_EXECUTION']._serialized_end=15386 - _globals['_PERSISTENTWORKER']._serialized_start=15389 - _globals['_PERSISTENTWORKER']._serialized_end=15558 - _globals['_TUNINGGRAPH']._serialized_start=15560 - _globals['_TUNINGGRAPH']._serialized_end=15627 - _globals['_BUFFER']._serialized_start=15630 - _globals['_BUFFER']._serialized_end=15760 - _globals['_EXECUTIONGRAPH']._serialized_start=15763 - _globals['_EXECUTIONGRAPH']._serialized_end=16296 - _globals['_INPUTBINDING']._serialized_start=16298 - _globals['_INPUTBINDING']._serialized_end=16370 + _globals['_VISIONCAPACITY']._serialized_end=5499 + _globals['_CACHECONTRACT']._serialized_start=5502 + _globals['_CACHECONTRACT']._serialized_end=5686 + _globals['_CODECLAYOUT']._serialized_start=5688 + _globals['_CODECLAYOUT']._serialized_end=5802 + _globals['_CODECFIELD']._serialized_start=5804 + _globals['_CODECFIELD']._serialized_end=5882 + _globals['_HISTORYREGION']._serialized_start=5885 + _globals['_HISTORYREGION']._serialized_end=6035 + _globals['_PAGETABLEVIEW']._serialized_start=6037 + _globals['_PAGETABLEVIEW']._serialized_end=6089 + _globals['_VALUEBINDING']._serialized_start=6092 + _globals['_VALUEBINDING']._serialized_end=6288 + _globals['_STATEVIEW']._serialized_start=6290 + _globals['_STATEVIEW']._serialized_end=6365 + _globals['_STATEACCESS']._serialized_start=6367 + _globals['_STATEACCESS']._serialized_end=6468 + _globals['_COMPLETIONCURSOR']._serialized_start=6470 + _globals['_COMPLETIONCURSOR']._serialized_end=6549 + _globals['_TUNEDBINDING']._serialized_start=6551 + _globals['_TUNEDBINDING']._serialized_end=6603 + _globals['_GRAPHCONTRACT']._serialized_start=6606 + _globals['_GRAPHCONTRACT']._serialized_end=6984 + _globals['_TOOLPARSER']._serialized_start=6987 + _globals['_TOOLPARSER']._serialized_end=7123 + _globals['_REASONINGPARSER']._serialized_start=7126 + _globals['_REASONINGPARSER']._serialized_end=7275 + _globals['_PREFIXBOUNDARY']._serialized_start=7278 + _globals['_PREFIXBOUNDARY']._serialized_end=7480 + _globals['_IMAGESPAN']._serialized_start=7482 + _globals['_IMAGESPAN']._serialized_end=7603 + _globals['_IMAGETOKENLAYOUT']._serialized_start=7605 + _globals['_IMAGETOKENLAYOUT']._serialized_end=7686 + _globals['_FRONTENDCONTRACT']._serialized_start=7689 + _globals['_FRONTENDCONTRACT']._serialized_end=8187 + _globals['_CLUSTER']._serialized_start=8189 + _globals['_CLUSTER']._serialized_end=8238 + _globals['_DEFAULTSAMPLINGPARAMETERS']._serialized_start=8241 + _globals['_DEFAULTSAMPLINGPARAMETERS']._serialized_end=8637 + _globals['_SAMPLINGFLOATRANGE']._serialized_start=8639 + _globals['_SAMPLINGFLOATRANGE']._serialized_end=8711 + _globals['_SAMPLINGINTRANGE']._serialized_start=8713 + _globals['_SAMPLINGINTRANGE']._serialized_end=8783 + _globals['_SAMPLINGRANGES']._serialized_start=8786 + _globals['_SAMPLINGRANGES']._serialized_end=9192 + _globals['_FRONTENDSETTINGS']._serialized_start=9195 + _globals['_FRONTENDSETTINGS']._serialized_end=9520 + _globals['_TOKENIZERSETTINGS']._serialized_start=9523 + _globals['_TOKENIZERSETTINGS']._serialized_end=9871 + _globals['_TOKENLIST']._serialized_start=9873 + _globals['_TOKENLIST']._serialized_end=9900 + _globals['_IMAGESETTINGS']._serialized_start=9903 + _globals['_IMAGESETTINGS']._serialized_end=10465 + _globals['_PATCHMERGEIMAGESETTINGS']._serialized_start=10468 + _globals['_PATCHMERGEIMAGESETTINGS']._serialized_end=10653 + _globals['_GEMMA4IMAGESETTINGS']._serialized_start=10656 + _globals['_GEMMA4IMAGESETTINGS']._serialized_end=10812 + _globals['_DEEPSEEKROWMAJORIMAGESETTINGS']._serialized_start=10815 + _globals['_DEEPSEEKROWMAJORIMAGESETTINGS']._serialized_end=10950 + _globals['_QWENIMAGESETTINGS']._serialized_start=10953 + _globals['_QWENIMAGESETTINGS']._serialized_end=11083 + _globals['_MIMOIMAGESETTINGS']._serialized_start=11085 + _globals['_MIMOIMAGESETTINGS']._serialized_end=11183 + _globals['_ENGRAM']._serialized_start=11185 + _globals['_ENGRAM']._serialized_end=11309 + _globals['_ENGRAMTABLE']._serialized_start=11312 + _globals['_ENGRAMTABLE']._serialized_end=11849 + _globals['_ENGRAMTABLE_ENCODING']._serialized_start=11780 + _globals['_ENGRAMTABLE_ENCODING']._serialized_end=11849 + _globals['_ENGRAMTABLESHARD']._serialized_start=11852 + _globals['_ENGRAMTABLESHARD']._serialized_end=11992 + _globals['_ENGRAMHASH']._serialized_start=11995 + _globals['_ENGRAMHASH']._serialized_end=12190 + _globals['_ENGRAMHASH_METHOD']._serialized_start=12129 + _globals['_ENGRAMHASH_METHOD']._serialized_end=12190 + _globals['_ASSET']._serialized_start=12192 + _globals['_ASSET']._serialized_end=12267 + _globals['_BUNDLEINDEX']._serialized_start=12270 + _globals['_BUNDLEINDEX']._serialized_end=12865 + _globals['_BUNDLEINDEX_RESOURCESENTRY']._serialized_start=12796 + _globals['_BUNDLEINDEX_RESOURCESENTRY']._serialized_end=12865 + _globals['_ROCETRANSPORT']._serialized_start=12868 + _globals['_ROCETRANSPORT']._serialized_end=13116 + _globals['_GRAPHINDEX']._serialized_start=13118 + _globals['_GRAPHINDEX']._serialized_end=13236 + _globals['_PEERMEMORY']._serialized_start=13238 + _globals['_PEERMEMORY']._serialized_end=13315 + _globals['_CONTEXT']._serialized_start=13317 + _globals['_CONTEXT']._serialized_end=13394 + _globals['_LIMIT']._serialized_start=13396 + _globals['_LIMIT']._serialized_end=13430 + _globals['_RESERVATION']._serialized_start=13432 + _globals['_RESERVATION']._serialized_end=13478 + _globals['_SPAN']._serialized_start=13480 + _globals['_SPAN']._serialized_end=13536 + _globals['_ALLOCATION']._serialized_start=13539 + _globals['_ALLOCATION']._serialized_end=13829 + _globals['_SIZING']._serialized_start=13831 + _globals['_SIZING']._serialized_end=13919 + _globals['_MODULE']._serialized_start=13921 + _globals['_MODULE']._serialized_end=13997 + _globals['_GLOBAL']._serialized_start=13999 + _globals['_GLOBAL']._serialized_end=14101 + _globals['_FUNCTION']._serialized_start=14103 + _globals['_FUNCTION']._serialized_end=14224 + _globals['_FUNCTIONATTRIBUTE']._serialized_start=14226 + _globals['_FUNCTIONATTRIBUTE']._serialized_end=14272 + _globals['_REFERENCE']._serialized_start=14274 + _globals['_REFERENCE']._serialized_end=14321 + _globals['_RELOCATION']._serialized_start=14323 + _globals['_RELOCATION']._serialized_end=14438 + _globals['_BLOB']._serialized_start=14440 + _globals['_BLOB']._serialized_end=14508 + _globals['_ATTRIBUTE']._serialized_start=14510 + _globals['_ATTRIBUTE']._serialized_end=14569 + _globals['_KERNEL']._serialized_start=14572 + _globals['_KERNEL']._serialized_end=14729 + _globals['_MEMSET']._serialized_start=14732 + _globals['_MEMSET']._serialized_end=14870 + _globals['_COPY']._serialized_start=14872 + _globals['_COPY']._serialized_end=14983 + _globals['_EMPTY']._serialized_start=14985 + _globals['_EMPTY']._serialized_end=14992 + _globals['_EVENTWAIT']._serialized_start=14994 + _globals['_EVENTWAIT']._serialized_end=15020 + _globals['_NODE']._serialized_start=15023 + _globals['_NODE']._serialized_end=15248 + _globals['_EDGE']._serialized_start=15250 + _globals['_EDGE']._serialized_end=15307 + _globals['_EXECUTION']._serialized_start=15310 + _globals['_EXECUTION']._serialized_end=15623 + _globals['_PERSISTENTWORKER']._serialized_start=15626 + _globals['_PERSISTENTWORKER']._serialized_end=15795 + _globals['_TUNINGGRAPH']._serialized_start=15797 + _globals['_TUNINGGRAPH']._serialized_end=15864 + _globals['_BUFFER']._serialized_start=15867 + _globals['_BUFFER']._serialized_end=15997 + _globals['_EXECUTIONGRAPH']._serialized_start=16000 + _globals['_EXECUTIONGRAPH']._serialized_end=16533 + _globals['_INPUTBINDING']._serialized_start=16535 + _globals['_INPUTBINDING']._serialized_end=16607 # @@protoc_insertion_point(module_scope) diff --git a/tests/frontend/gemma4_images.json b/tests/frontend/gemma4_images.json new file mode 100644 index 000000000..7975e44d9 --- /dev/null +++ b/tests/frontend/gemma4_images.json @@ -0,0 +1,256 @@ +{ + "processor": { + "audio_ms_per_token": 40, + "audio_seq_length": 750, + "feature_extractor": { + "dither": 0.0, + "feature_extractor_type": "Gemma4AudioFeatureExtractor", + "feature_size": 128, + "fft_length": 512, + "fft_overdrive": false, + "frame_length": 320, + "hop_length": 160, + "input_scale_factor": 1.0, + "max_frequency": 8000.0, + "mel_floor": 0.001, + "min_frequency": 0.0, + "padding_side": "right", + "padding_value": 0.0, + "per_bin_mean": null, + "per_bin_stddev": null, + "preemphasis": 0.0, + "preemphasis_htk_flavor": true, + "return_attention_mask": true, + "sampling_rate": 16000 + }, + "image_processor": { + "do_convert_rgb": true, + "do_normalize": false, + "do_rescale": true, + "do_resize": true, + "image_mean": [ + 0.0, + 0.0, + 0.0 + ], + "image_processor_type": "Gemma4ImageProcessor", + "image_seq_length": 280, + "image_std": [ + 1.0, + 1.0, + 1.0 + ], + "max_soft_tokens": 280, + "patch_size": 16, + "pooling_kernel_size": 3, + "resample": 3, + "rescale_factor": 0.00392156862745098 + }, + "image_seq_length": 280, + "processor_class": "Gemma4Processor", + "video_processor": { + "do_convert_rgb": true, + "do_normalize": true, + "do_rescale": true, + "do_resize": true, + "do_sample_frames": true, + "image_mean": [ + 0.0, + 0.0, + 0.0 + ], + "image_std": [ + 1.0, + 1.0, + 1.0 + ], + "max_soft_tokens": 70, + "num_frames": 32, + "patch_size": 16, + "pooling_kernel_size": 3, + "resample": 3, + "rescale_factor": 0.00392156862745098, + "return_metadata": false, + "video_processor_type": "Gemma4VideoProcessor" + } + }, + "model": { + "vision_config": { + "_name_or_path": "", + "architectures": null, + "attention_bias": false, + "attention_dropout": 0.0, + "chunk_size_feed_forward": 0, + "default_output_length": 280, + "dtype": "bfloat16", + "global_head_dim": 72, + "head_dim": 72, + "hidden_activation": "gelu_pytorch_tanh", + "hidden_size": 1152, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_range": 0.02, + "intermediate_size": 4304, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "max_position_embeddings": 131072, + "model_type": "gemma4_vision", + "num_attention_heads": 16, + "num_hidden_layers": 27, + "num_key_value_heads": 16, + "output_attentions": false, + "output_hidden_states": false, + "patch_size": 16, + "pooling_kernel_size": 3, + "position_embedding_size": 10240, + "problem_type": null, + "return_dict": true, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 100.0, + "rope_type": "default" + }, + "standardize": true, + "use_clipped_linears": false + }, + "model_type": "gemma4", + "image_token_id": 258880, + "boi_token_id": 255999, + "eoi_token_id": 258882 + }, + "cases": [ + { + "width": 1, + "height": 1, + "seed": 0, + "max_soft_tokens": 280, + "grid": [ + 1, + 48, + 48 + ], + "tokens": 256, + "patches": 2304, + "pixels": "468a4a459772da4e498bc9635d3a9c9b12584490e1edcc1d914ee7df6448d8b2", + "positions": "4aad87bbd779207de57f944f92624525222e08c076b6c349f82cb6c98d0b3dcd", + "resized": "f0a0e8d753bbee26646b9cedd3cad510258b922274c4085b8da7d4f08e4cca3f" + }, + { + "width": 91, + "height": 37, + "seed": 1, + "max_soft_tokens": 280, + "grid": [ + 1, + 30, + 78 + ], + "tokens": 260, + "patches": 2340, + "pixels": "5265a89e1fce5478a650d56dfcc96127c30c21d2ea429b44c7af7d8a6682ac18", + "positions": "230fe091541f6e013b0d2a81d4db758517641e62625d183f5fe9413084933d38", + "resized": "74844bf7eb16d04ff85b2c4e7eb918db8d1aea0e2e302208008904b776dd3c31" + }, + { + "width": 672, + "height": 672, + "seed": 2, + "max_soft_tokens": 280, + "grid": [ + 1, + 48, + 48 + ], + "tokens": 256, + "patches": 2304, + "pixels": "66294430dcf7320533ade9aa9944cb1e7eefbf0ee969737041c51dc4474242e4", + "positions": "4aad87bbd779207de57f944f92624525222e08c076b6c349f82cb6c98d0b3dcd", + "resized": "993d71e2a28e4389e225eed5378b03ca1cb6c1056395c8a5b4b31754f594a81a" + }, + { + "width": 1008, + "height": 672, + "seed": 3, + "max_soft_tokens": 280, + "grid": [ + 1, + 39, + 60 + ], + "tokens": 260, + "patches": 2340, + "pixels": "c5c5fb7fe6d48bd9a3670d89832d4dadb51759666188ecbc3a7429c2bb43e3f9", + "positions": "ad2b173f5b91cabb2863a1d545039ab7e22bb7b45309657f92c7e53d079dfb50", + "resized": "33cbdc838936699ecaeff512700edf7f6049a87af183bb09f8db7d96f2320808" + }, + { + "width": 1920, + "height": 1080, + "seed": 4, + "max_soft_tokens": 280, + "grid": [ + 1, + 36, + 66 + ], + "tokens": 264, + "patches": 2376, + "pixels": "815b779d85aa29f4f7ddb74d47c0b8d73e656897be5d8a45ce74893cbbfd2338", + "positions": "e43d86caabf6609fe1ad0ef620caef5581ad7b5c6dbf69f3eb6d55fabf49d773", + "resized": "cd2ec808d9fb5ab009b7756729b0befc89c5ff6119ecfbafc25c9f0089907e21" + }, + { + "width": 10, + "height": 3000, + "seed": 5, + "max_soft_tokens": 280, + "grid": [ + 1, + 840, + 3 + ], + "tokens": 280, + "patches": 2520, + "pixels": "b17b383076944d67f62ccfd2dd998d80daa5be42f2b0ba6bda8f309ff7d21f7b", + "positions": "97d697bfd1f692c2e5393ed53d68c05abee541492e4bdc875526318c206ef557", + "resized": "0f17928e5360c931dc5c54bb1ebdd50afb7b126dab817e634c8358be87be1fbe" + }, + { + "width": 3000, + "height": 10, + "seed": 6, + "max_soft_tokens": 280, + "grid": [ + 1, + 3, + 840 + ], + "tokens": 280, + "patches": 2520, + "pixels": "16ef5cbab3d32dd200b95fbe680c28290c914ff65c26619cf7e22155f2118f45", + "positions": "2f51f7ce8893690da5ec517147c02d8367bdac99ccadbbe17d564d5a5d338683", + "resized": "e39f4eb95590e7ece96dbe9c5ce3d1388ecc7dffe40ac64bfc6bad1a04ae1548" + }, + { + "width": 1920, + "height": 1080, + "seed": 7, + "max_soft_tokens": 1120, + "grid": [ + 1, + 75, + 132 + ], + "tokens": 1100, + "patches": 9900, + "pixels": "4ff02c2491f5406ff26c77ad1115bceabc3c03152eb11f183ee5907a2ae016a0", + "positions": "76fbdbbe40e17eec69727f75e9de788f773ca33fd7fc83ad7b99c6c32fc79946", + "resized": "b411dbb8c91eba7b9db63355c7d63e74102800d8aafa70df989d39ff65ad2d2c" + } + ] +} diff --git a/tests/frontend/generate_gemma4_image_fixtures.py b/tests/frontend/generate_gemma4_image_fixtures.py new file mode 100644 index 000000000..09e91dabd --- /dev/null +++ b/tests/frontend/generate_gemma4_image_fixtures.py @@ -0,0 +1,94 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 Flare community contributors +# SPDX-License-Identifier: Apache-2.0 + +"""Generate Gemma 4 image preprocessing fixtures from the canonical processor.""" + +import argparse +import hashlib +import json +from pathlib import Path + +import numpy as np +import torch +import torchvision.transforms.functional as tvF +from transformers.models.gemma4.image_processing_gemma4 import Gemma4ImageProcessor + + +def pattern(width, height, seed): + # Vectorized channel ramps exercise bicubic interpolation and extreme aspect clamping. + y, x = np.indices((height, width)) + return np.stack(((x * 7 + seed * 31) % 256, (y * 11) % 256, (x + y * 3) % 256), -1).astype(np.uint8) + + +def digest(tensor): + return hashlib.sha256(tensor.contiguous().numpy().tobytes()).hexdigest() + + +def generate(snapshot, output): + raw = json.loads((snapshot / "processor_config.json").read_text()) + model = json.loads((snapshot / "config.json").read_text()) + cases = [] + specs = [ + (1, 1, 280), + (91, 37, 280), + (672, 672, 280), + (1008, 672, 280), + (1920, 1080, 280), + (10, 3000, 280), + (3000, 10, 280), + (1920, 1080, 1120), + ] + for seed, (width, height, max_soft_tokens) in enumerate(specs): + processor_kwargs = {**raw["image_processor"], "max_soft_tokens": max_soft_tokens} + processor = Gemma4ImageProcessor(**processor_kwargs) + pixels = pattern(width, height, seed) + chw = torch.from_numpy(pixels).permute(2, 0, 1).contiguous() + result = processor(images=[chw], return_tensors="pt") + positions = result["image_position_ids"][0] + valid = (positions >= 0).all(-1) + patches = int(valid.sum()) + valid_positions = positions[:patches] + assert bool(valid[:patches].all()) and not bool(valid[patches:].any()), ( + f"unexpected non-contiguous padding in {width}x{height}" + ) + grid_h = int(valid_positions[..., 1].max()) + 1 + grid_w = int(valid_positions[..., 0].max()) + 1 + pixel_values = result["pixel_values"][0, :patches] + assert pixel_values.dtype == torch.float32 + assert valid_positions.dtype == torch.int64 + resized = processor.aspect_ratio_preserving_resize( + chw, + patch_size=processor.patch_size, + max_patches=max_soft_tokens * processor.pooling_kernel_size * processor.pooling_kernel_size, + pooling_kernel_size=processor.pooling_kernel_size, + resample=tvF.InterpolationMode.BICUBIC, + ).permute(1, 2, 0) + assert resized.dtype == torch.uint8 + cases.append( + dict( + width=width, + height=height, + seed=seed, + max_soft_tokens=max_soft_tokens, + grid=[1, grid_h, grid_w], + tokens=int(result["num_soft_tokens_per_image"][0]), + patches=patches, + pixels=digest(pixel_values), + positions=digest(valid_positions), + resized=digest(resized), + ) + ) + profile = { + key: model[key] + for key in ("vision_config", "model_type", "image_token_id", "boi_token_id", "eoi_token_id") + if key in model + } + output.write_text(json.dumps(dict(processor=raw, model=profile, cases=cases), indent=2) + "\n") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("snapshot", type=Path) + parser.add_argument("output", type=Path) + args = parser.parse_args() + generate(args.snapshot, args.output) diff --git a/tests/preparation/test_frontend_gemma4.py b/tests/preparation/test_frontend_gemma4.py new file mode 100644 index 000000000..d80e16260 --- /dev/null +++ b/tests/preparation/test_frontend_gemma4.py @@ -0,0 +1,152 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 Flare community contributors +# SPDX-License-Identifier: Apache-2.0 + +"""Validate Gemma 4 core image wire schema, protobuf encoding, and spec hooks.""" + +import json +from pathlib import Path + +from google.protobuf import json_format +import pytest + +from ignition.preparation import runtime_core_pb2 as p +from ignition.preparation.frontend import ( + IMAGE_PROFILES, + ImageProcessorSpec, + image_settings, + prepare_frontend, +) + + +_BASE_PAYLOAD = { + "patch_size": 16, + "pooling_kernel_size": 3, + "max_soft_tokens": 280, + "image_token": "<|image|>", + "start_token": "<|image>", + "end_token": "", +} + + +def test_gemma4_profile_validates_wire_payload(): + assert "gemma4" in IMAGE_PROFILES + spec = ImageProcessorSpec(profile="gemma4", extract=lambda image, model: dict(_BASE_PAYLOAD)) + assert image_settings({}, {}, spec) == {"gemma4": _BASE_PAYLOAD} + + # Missing or extra payload keys fail. + for bad in ( + {k: v for k, v in _BASE_PAYLOAD.items() if k != "end_token"}, + {**_BASE_PAYLOAD, "extra": 1}, + ): + with pytest.raises(ValueError, match="unsupported gemma4 image payload fields"): + image_settings({}, {}, ImageProcessorSpec(profile="gemma4", extract=lambda i, m, payload=bad: payload)) + + # Numeric bounds and bool rejection. + for key, bad_value in ( + ("patch_size", 0), + ("patch_size", 65), + ("patch_size", True), + ("pooling_kernel_size", 0), + ("pooling_kernel_size", 17), + ("pooling_kernel_size", False), + ("max_soft_tokens", 300), + ("max_soft_tokens", True), + ): + bad = {**_BASE_PAYLOAD, key: bad_value} + with pytest.raises(ValueError, match=key): + image_settings({}, {}, ImageProcessorSpec(profile="gemma4", extract=lambda i, m, payload=bad: payload)) + + # Empty, non-string, and duplicate envelope tokens fail. + for key, bad_value in ( + ("image_token", ""), + ("start_token", 123), + ("end_token", None), + ): + bad = {**_BASE_PAYLOAD, key: bad_value} + with pytest.raises(ValueError, match=key): + image_settings({}, {}, ImageProcessorSpec(profile="gemma4", extract=lambda i, m, payload=bad: payload)) + + dup = {**_BASE_PAYLOAD, "end_token": "<|image>"} + with pytest.raises(ValueError, match="distinct"): + image_settings({}, {}, ImageProcessorSpec(profile="gemma4", extract=lambda i, m, payload=dup: payload)) + + +def test_prepare_frontend_gemma4_default_preprocessor_and_wire_profile(tmp_path): + (tmp_path / "tokenizer_config.json").write_text(json.dumps({"eos_token": ""})) + (tmp_path / "config.json").write_text( + json.dumps({"model_type": "gemma4", "vision_config": {"model_type": "gemma4_vision", "patch_size": 16}}) + ) + (tmp_path / "processor_config.json").write_text( + json.dumps( + { + "processor_class": "Gemma4Processor", + "image_processor": {"patch_size": 16, "pooling_kernel_size": 3, "max_soft_tokens": 280}, + } + ) + ) + spec = ImageProcessorSpec( + profile="gemma4", + label="Gemma 4", + processor_fields={"processor_class": "Gemma4Processor"}, + image_processor_key="image_processor", + image_processor_fields={"patch_size": 16, "pooling_kernel_size": 3}, + model_types=("gemma4",), + vision_fields={"model_type": "gemma4_vision", "patch_size": 16}, + default_preprocessor="processor_config.json", + extract=lambda image, model: { + "patch_size": image["patch_size"], + "pooling_kernel_size": image["pooling_kernel_size"], + "max_soft_tokens": image["max_soft_tokens"], + "image_token": "<|image|>", + "start_token": "<|image>", + "end_token": "", + }, + ) + prepared = prepare_frontend(tmp_path, eos_token_ids=[1], image_spec=spec) + assert prepared["image"] == {"gemma4": _BASE_PAYLOAD} + + (tmp_path / "processor_config.json").unlink() + with pytest.raises(FileNotFoundError): + prepare_frontend(tmp_path, eos_token_ids=[1], image_spec=spec) + + +def test_checked_in_gemma4_fixture_and_proto_roundtrip(): + fixture_path = Path(__file__).resolve().parents[1] / "frontend" / "gemma4_images.json" + fixture = json.loads(fixture_path.read_text()) + spec = ImageProcessorSpec( + profile="gemma4", + label="Gemma 4", + processor_fields={"processor_class": "Gemma4Processor"}, + image_processor_key="image_processor", + image_processor_fields={ + "image_processor_type": "Gemma4ImageProcessor", + "patch_size": 16, + "pooling_kernel_size": 3, + "do_resize": True, + "do_rescale": True, + "do_normalize": False, + }, + model_types=("gemma4",), + vision_fields={"model_type": "gemma4_vision", "patch_size": 16, "pooling_kernel_size": 3}, + extract=lambda image, model: { + "patch_size": image["patch_size"], + "pooling_kernel_size": image["pooling_kernel_size"], + "max_soft_tokens": image["max_soft_tokens"], + "image_token": "<|image|>", + "start_token": "<|image>", + "end_token": "", + }, + ) + resolved = image_settings(fixture["processor"], fixture["model"], spec) + assert resolved == {"gemma4": _BASE_PAYLOAD} + + wire = json_format.ParseDict(resolved, p.ImageSettings()) + decoded = p.ImageSettings() + decoded.ParseFromString(wire.SerializeToString()) + assert decoded.WhichOneof("profile") == "gemma4" + assert decoded.gemma4.patch_size == 16 + assert decoded.gemma4.pooling_kernel_size == 3 + assert decoded.gemma4.max_soft_tokens == 280 + assert decoded.gemma4.image_token == "<|image|>" + assert decoded.gemma4.start_token == "<|image>" + assert decoded.gemma4.end_token == "" diff --git a/tests/preparation/test_frontend_spec.py b/tests/preparation/test_frontend_spec.py index 7e7585a6e..d997fadd3 100644 --- a/tests/preparation/test_frontend_spec.py +++ b/tests/preparation/test_frontend_spec.py @@ -90,7 +90,7 @@ def test_prepare_frontend_uses_spec_default_preprocessor_and_rejects_raw_strings def test_image_processor_spec_rejects_unknown_profile_and_invalid_mimo_payload(): with pytest.raises(ValueError, match="unsupported image preprocessing profile"): ImageProcessorSpec(profile="unknown_profile") - assert {"padded_grid", "glm", "radio", "moonvit", "deepseek_row_major", "deepseek4", "qwen", "mimo"} == IMAGE_PROFILES + assert {"padded_grid", "glm", "radio", "moonvit", "deepseek_row_major", "deepseek4", "qwen", "mimo", "gemma4"} == IMAGE_PROFILES bad_mimo = ImageProcessorSpec( profile="mimo", extract=lambda image, model: {