Repository navigation
fix(helios,ignition): handle decoded VLM feature tokens on continuation readmission and unify index-driven VisionState - #708
Conversation
|
A case file has been opened for 708. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Ready To MergePR #708 does exactly what it claims, at the right layer, with no per-model branching and no core-format change. Every load-bearing site was verified at
Walkthrough
Merge Risk: Low · up to
|
…on readmission and unify index-driven VisionState
Vision-language models that place their image feature token inside the
decoded vocabulary (such as Nemotron-H, GLM-5.3, Qwen3.8, Qwen3.8-Dense,
Inkling2, Kimi3, MiMo-V2, MiniMax-M3, and Step5) can sample that token—or
an in-vocabulary atomic image span delimiter—during ordinary text
generation because Helios does not mask image feature tokens during
decode. When a request later parks for KV cache preemption,
`thinking_token_budget` enforcement, or a speculative-reasoning grammar
transition, `Worker::park_with_tokens` extends the prompt history with the
generated continuation tokens and assigns `vision_token_indices = -1` to
every appended token. On readmission, two failures occurred:
1. In Helios (`helios/src/server/runtime.rs`), `Worker::admit` called
`Admission::from_prompt`, whose `validate_prompt_data`
(`helios/src/model.rs`) enforced a strict bijection
`(*token == layout.feature_token) == (*index >= 0)` and required atomic
span membership across the entire `tokens` array. Any decoded
in-vocabulary feature or span token returned `Err`, propagating via `?`
out of `Worker::run`, marking worker health unhealthy, failing all
concurrent requests, and permanently terminating the `flare-model`
worker thread. Failures from `TokenStops::new` and `TextStops::new` in
`Worker::admit` propagated out of `Worker::run` in the same way.
2. In Ignition (`ignition/components/vision_state.py`), the shared
`VisionState` used by 9 VLM recipes keyed both `validate_prefill` and
`inject` on `tokens == self.image_token` rather than
`vision_token_indices >= 0` (unlike `qwen38`'s index-driven injection).
Relaxing Helios alone would allow re-prefill of an unindexed decoded
`image_token` to fail device validation or overwrite its text embedding
with an arena vector.
Separating the immutable initial prompt prefix (`0..initial_prompt_tokens`,
anchored in `Carried::prompt_tokens`) from generated continuation tokens
(`initial_prompt_tokens..tokens.len()`) keeps strict multimodal validation
on user prompts while treating decoded continuation tokens as ordinary
text (`index == -1`). Making `VisionState` index-driven aligns re-exported
cores on the same invariant. Decode-time masking of `feature_token` on
legacy token-keyed cores is intentionally omitted because captured graphs
only support per-token decode masking via `GrammarMask`/`GrammarEnabled`
(which disables speculative verification and 2-frame pipelining) and
existing index-driven `qwen38` cores share identical `ModelContract`
metadata with legacy token-keyed `qwen38_dense` cores. Legacy token-keyed
cores remain safe without decode masking: continuations that reuse a KV
checkpoint past the decoded token succeed, and continuations that must
re-prefill it abort only that request inside legacy GPU `validate_prefill`
(`ExecutionError::Device { code: 32 }`) without mutating state or killing
the worker thread.
What changed:
- `ignition/components/vision_state.py` and
`tests/components/test_vision_state.py`: before, `VisionState.__init__`
required `image_token`, `validate_prefill` rejected unindexed
`image_token`, and `inject` replaced embeddings wherever
`metadata.token_ids == self.image_token`. After, `image_token` defaults
to `None` (preserving compatibility with existing recipe call sites),
`validate_prefill` keys on `visual = index >= 0` (allowing `index == -1`
on any token without requiring a feature slot or matching generation,
while checking `index < count[slot]`, `index < arena.shape[1]`,
generation match, valid `feature_slot`, and `tokens == self.image_token`
when `image_token` is set on visual positions), and `inject` keys
replacement on `(index >= 0) & (index < arena.shape[1]) & (feature_slot >= 0) & (feature_slot < arena.shape[0])`.
Added unit tests covering unindexed `image_token` in text-only and mixed
chunks, invalid/out-of-bounds indices, stale tail indices with
`feature_slot == -1`, and `image_token=None`.
- `helios/src/model.rs`, `helios/src/model/admission.rs`, and
`helios/src/model/tests.rs`: before, `validate_prompt_data`,
`Admission::validate`, and `Admission::from_prompt` applied strict
initial-prompt validation to every token. After, added
`validate_continuation_prompt_data`, `Admission::validate_continuation`,
and `Admission::from_continuation`, with existing entry points
delegating with `tokens.len()`. Continuation validation enforces strict
feature-index bijection and atomic spans on `0..initial_prompt_tokens`,
while requiring `vision_token_indices == -1`, no spans past
`initial_prompt_tokens`, and in-vocabulary tokens
(`< config.contract.vocabulary`) on `initial_prompt_tokens..tokens.len()`.
Added unit tests for initial vs. continuation boundaries, OOV
continuation tokens, nonnegative continuation indices, and atomic
`ImageSpan` tokens.
- `helios/src/server/runtime.rs` and
`helios/src/server/runtime/phase_tests.rs`: before, `Worker::admit`
propagated `Admission::from_prompt`, `TokenStops::new`, and
`TextStops::new` errors via `?` out of `Worker::run` and stored
`self.admissions[slot]` before stop-matcher construction finished.
After, `Worker::admit` computes `initial_prompt_tokens` from
`parked.carried.prompt_tokens` (falling back to `incoming.prompt.tokens.len()`),
calls `Admission::from_continuation`, isolates errors from all three
constructors via `self.scheduler.cancel(handle)?`, `incoming.fail(error)`,
and `progress = true; continue;`, and writes `self.admissions[slot]`
only after all three succeed. Added phase tests covering KV preemption
(with and without checkpoint eviction, packed `-1` indices, and repeated
parking), `thinking_token_budget` readmission, `park_grammar_transition`
with in-vocabulary feature and span tokens, and error isolation across
all three `Worker::admit` failure sites with full slot and page
reclamation.
- Compatibility: no Protobuf schema or `ModelContract` fields changed.
Previously exported cores load without re-export; existing `qwen38`
cores work immediately, while legacy token-keyed cores require re-export
to re-prefill unindexed decoded feature tokens as text.
Claimed result:
- VLM requests that decode in-vocabulary image feature or span tokens no
longer terminate the `flare-model` worker thread upon KV preemption,
`thinking_token_budget`, or grammar-transition readmission, and
malformed admission or stop-matcher inputs fail only the affected
request while reclaiming scheduler slots and pages.
- Re-exported VLM cores using `ignition.components.vision_state.VisionState`
validate and inject visual features solely by `vision_token_indices >= 0`,
keeping decoded continuation feature tokens as ordinary text embeddings.
Evidence:
- Python CPU tests (`PYTHONPATH=. .venv/bin/python -m pytest`):
`tests/components/test_vision_state.py` 5 passed; `tests/components` and
`tests/cli` 336 passed, 56 skipped (`FLARE_RUN_CUDA_TESTS` unset).
- Targeted Helios unit and runtime tests (`cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib -- continuation_prompt_validation vlm_feature_token vlm_feature_and_span worker_admit_isolates`):
4 passed, 0 failed.
- Rust release crate tests (CPU): `helios --features runtime-core,server --lib`
1,837 passed, 47 ignored, 7 failed (6 template tests require
`FLARE_TEST_TEMPLATE_DIR`; `engram::reader::tests::equal_offsets_in_separate_files_never_coalesce`
failed under an artificially lowered `ulimit -l 65536` and passed 1/1
under default `ulimit -l unlimited`); `helios` feature-matrix `cargo check`
(default, `runtime-core`, `runtime-core,server`) produced 0 warnings in
modified files; `flare` 255 passed, 4 ignored; `flare-cli` 246 passed,
3 ignored; `heliopause` 229 passed, 6 ignored.
- TLA+ formal models and Rust observed-edge conformance (`python3 verification/helios-lifecycle/check.py --tlc-jar /home/luke/.cache/flare-formal/tla2tools-1.7.4.jar --target-dir flare-cli/target`):
all passed (`Lifecycle` 1,710 edges, `RankProtocol` 1,291 edges,
`DispatchRing` 7,940 edges, `OffloadTransfer` 8,490 edges,
`CacheOwnership` 222,817 edges, `Speculation` 13,566 edges,
`ResponseLifecycle` 365,508 edges, `CheckpointReservation` 68 edges,
`RankDispatch`, and all 12 targeted concurrency/lifecycle regression tests).
- Unrun checks: GPU/CUDA tests (`FLARE_RUN_CUDA_TESTS=1`), checkpoint-backed
`image_admission` tests, live VLM core re-export and `flare run` serving,
`FLARE_TEST_TEMPLATE_DIR` template tests, Kani sequential proofs
(`cargo-kani` not installed locally), and mutation tests (`cargo-mutants`
not installed locally).
Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
4fee325 to
f0676b6
Compare
Why
Vision-language models that place their image feature token inside the decoded vocabulary (Nemotron-H, GLM-5.3, Qwen3.8, Qwen3.8-Dense, Inkling2, Kimi3, MiMo-V2, MiniMax-M3, and Step5) can sample that token—or an in-vocabulary atomic image span delimiter—during ordinary text decode because Helios does not mask image feature tokens during decode. When a request later parks for KV cache preemption (
Worker::park_if_preempted),thinking_token_budgetenforcement (Worker::park), or a speculative-reasoning grammar transition (Worker::park_grammar_transition),Worker::park_with_tokensappends the generated continuation tokens to the prompt history and assignsvision_token_indices = -1to every appended position.On readmission, two failures occurred:
helios/src/server/runtime.rs,helios/src/model.rs):Worker::admitcalledAdmission::from_prompt, whosevalidate_prompt_dataenforced a strict bijection(*token == layout.feature_token) == (*index >= 0)and atomicImageSpanmembership across the entiretokensarray. Any decoded in-vocabulary feature or span token causedvalidate_prompt_datato returnErr, which propagated via?out ofWorker::run, markedworker_healthunhealthy, failed every concurrent request on that worker, and permanently terminated theflare-modelworker thread. Errors fromTokenStops::newandTextStops::newinWorker::admitpropagated out ofWorker::runin the same way.ignition/components/vision_state.py): The sharedVisionStateused by 9 VLM recipes keyed bothvalidate_prefillandinjectontokens == self.image_tokenrather thanvision_token_indices >= 0(unlikeqwen38's index-driven injection). Relaxing Helios validation without updatingVisionStatewould let re-prefill of an unindexed decodedimage_tokeneither fail device validation or overwrite its text embedding with an arena feature vector.Separating the immutable initial prompt prefix (
0..initial_prompt_tokens, anchored inCarried::prompt_tokens) from generated continuation tokens (initial_prompt_tokens..tokens.len()) preserves strict multimodal validation on user prompts while allowing decoded continuation tokens to remain ordinary text (index == -1). MakingVisionStateindex-driven aligns re-exported cores on the same invariant across all recipes sharingignition.components.vision_state.Decode-time masking of
feature_tokenon legacy token-keyed cores is intentionally omitted:GrammarMaskgated byGrammarEnabled. EnablingGrammarEnabledbreaks speculative verification (valid &= (~gram_en) | (prefix == 0)) and requiresgrammar_constrained = true, permanently forcing width-1 synchronous decode and disabling 2-frame pipelining.qwen38cores and legacy token-keyedqwen38_densecores carry identicalModelContractmetadata (ImageLayoutKind::Qwen,feature_token = 248056,span = None,ValueSource::ImageFeatureIndex), so Helios cannot distinguish them without model-identity branching or capability flags disallowed bydocs/design-review.mdPrinciples 3 and 13.validate_prefill(ExecutionError::Device { code: 32 },active = False) with zero embedding corruption, zero state mutation, and a healthy worker thread.What changed
1. Index-driven
VisionStatein Ignition (ignition/components/vision_state.py,tests/components/test_vision_state.py)VisionState.__init__requiredimage_token;validate_prefillrequired(~image & (index == -1)) | (image & (index >= 0) & (index < count[slot]))and rejected anyimage_tokenwithindex == -1;injectcopied arena features wherevermetadata.token_ids == self.image_token.VisionState.__init__defaultsimage_token=Nonewhile remaining backward-compatible with all recipe call sites passingimage_token=....validate_prefillkeys onvisual = index >= 0:index == -1is accepted for any token without requiring a boundfeature_slotor matching generation, whilevisualpositions requireindex < count[slot],index < arena.shape[1], matching generation, validfeature_slot, andtokens == self.image_tokenwhenimage_tokenis set.injectkeys replacement on(index >= 0) & (index < arena.shape[1]) & (feature_slot >= 0) & (feature_slot < arena.shape[0]).image_token, negative and out-of-bounds indices, stale nonnegative tail indices whenfeature_slot == -1, andimage_token=None.2. Continuation-aware prompt validation in Helios (
helios/src/model.rs,helios/src/model/admission.rs,helios/src/model/tests.rs)validate_prompt_data,Admission::validate, andAdmission::from_promptapplied strict initial-prompt feature-token and atomic-span checks across the entiretokensslice.validate_continuation_prompt_data(config, tokens, data, initial_prompt_tokens),Admission::validate_continuation, andAdmission::from_continuation. Existingvalidate_prompt_data,Admission::validate, andAdmission::from_promptdelegate withtokens.len(), preserving strict initial-prompt checks. Continuation validation keeps strict feature-index bijection and atomic-span membership on0..initial_prompt_tokens, while requiringvision_token_indices == -1, no spans extending pastinitial_prompt_tokens, and in-vocabulary tokens (< config.contract.vocabulary, blocking out-of-vocabulary sentinels) oninitial_prompt_tokens..tokens.len().ImageSpantokens.3. Per-request admission error isolation (
helios/src/server/runtime.rs,helios/src/server/runtime/phase_tests.rs)Worker::admitcalledAdmission::from_prompt(...)?,TokenStops::new(...)?, andTextStops::new(...)?, terminatingWorker::runon any failure, and assignedself.admissions[slot]before stop-matcher construction completed.Worker::admitcomputesinitial_prompt_tokensfromparked.as_ref().and_then(|parked| parked.carried.prompt_tokens).unwrap_or(incoming.prompt.tokens.len()), callsAdmission::from_continuation, isolatesErrfromAdmission::from_continuation,TokenStops::new, andTextStops::newby callingself.scheduler.cancel(handle)?,incoming.fail(error), settingprogress = true, and continuing the loop, and writesself.admissions[slot]only after all three succeed.-1vision_token_indicesand repeated parking preservingcarried.prompt_tokens),thinking_token_budgetpark/readmission,park_grammar_transitionwith in-vocabulary feature and span tokens, and error isolation across all threeWorker::admitfailure sites alongside a healthy concurrent request with full slot and page reclamation.Compatibility
ModelContractfields changed. Previously exported cores load without re-export.qwen38cores gain full continuation readmission immediately.ignition.components.vision_state.VisionStaterequire re-export to re-prefill unindexed decoded feature tokens as text; until re-exported, such re-prefills fail only the affected request cleanly (ExecutionError::Device { code: 32 }) without corrupting embeddings or terminating the worker thread.Claimed result
flare-modelworker thread upon KV preemption,thinking_token_budget, or grammar-transition readmission, and malformed admission or stop-matcher inputs fail only the affected request with complete scheduler slot and page cleanup.ignition.components.vision_state.VisionStatevalidate and inject visual features solely byvision_token_indices >= 0, keeping decoded continuation feature tokens as ordinary text embeddings.Evidence
tests/components/test_vision_state.py5 passed, 0 failed;tests/components+tests/cli336 passed, 56 skipped (FLARE_RUN_CUDA_TESTSunset).cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --target-dir flare-cli/target --lib -- continuation_prompt_validation vlm_feature_token vlm_feature_and_span worker_admit_isolateshelios --features runtime-core,server --lib: 1,837 passed, 47 ignored, 7 failed (6 template tests requireFLARE_TEST_TEMPLATE_DIR;engram::reader::tests::equal_offsets_in_separate_files_never_coalescefailed under an artificially loweredulimit -l 65536and passed 1/1 when re-run under defaultulimit -l unlimited).heliosfeature-matrixcargo check(default,runtime-core,runtime-core,server): 0 warnings in modified files.flare: 255 passed, 0 failed, 4 ignored.flare-cli: 246 passed, 0 failed, 3 ignored.heliopause: 229 passed, 0 failed, 6 ignored.Lifecycle(1,710 edges),RankProtocol(1,291 edges),DispatchRing(7,940 edges),OffloadTransfer(8,490 edges),CacheOwnership(222,817 edges),Speculation(13,566 edges),ResponseLifecycle(365,508 edges),CheckpointReservation(68 edges),RankDispatch, and all 12 targeted concurrency/lifecycle regression tests.FLARE_RUN_CUDA_TESTS=1), checkpoint-backedimage_admissiontests (FLARE_TEST_SNAPSHOT/FLARE_NEMOTRON_TEST_SNAPSHOT), and live VLM core re-export +flare runserving were not executed on GPU.FLARE_TEST_TEMPLATE_DIR(tests/frontend/prepare_templates.py) were not run.cargo-kaniandcargo-mutantsare not installed on this host, so Kani sequential proofs and mutation tests were not run locally.Discord: lukealonso