Skip to content

[EXPERIMENT][WIP] fix(VocabDecoderStep): avoid zero-dim Const when skip_special_tokens=False - #677

Draft
mlukasze wants to merge 1 commit into
openvinotoolkit:masterfrom
mlukasze:fix/skip-special-tokens-zero-dim-crash
Draft

[EXPERIMENT][WIP] fix(VocabDecoderStep): avoid zero-dim Const when skip_special_tokens=False#677
mlukasze wants to merge 1 commit into
openvinotoolkit:masterfrom
mlukasze:fix/skip-special-tokens-zero-dim-crash

Conversation

@mlukasze

Copy link
Copy Markdown

⚠️ AUTOMATICALLY GENERATED BY OMEGA AGENT — REQUIRES HUMAN REVIEW ⚠️
This PR was created by an AI agent as part of automated model enablement.
A human maintainer must review and approve it before it can be considered for merge.
Do NOT merge without human review and sign-off.

Summary

When converting a detokenizer with skip_special_tokens=False, VocabDecoderStep.get_ov_subgraph() builds a Slice with stop=0, which constant-folds to a zero-dimensional Const wired into VocabDecoder port-4 (the skip-tokens list). When such a detokenizer is loaded together with a stateful model that has KV-cache ReadValue/Assign nodes (e.g. via openvino_genai.VLMPipeline/LLMPipeline), the Intel CPU plugin crashes with:

Check 'edge' failed at src/core/src/node.cpp:712: Node ReadValueXXXX contains dead weak ptr

Fix

When do_skip_tokens=False, omit port-4 entirely and use the 4-input VocabDecoder form (the op already treats a missing skip-tokens input as "skip nothing" via the empty m_skip_tokens attribute), instead of creating a zero-dim Const. This eliminates the zero-dim constant that triggers the plugin crash, with no behavioural change (skip_special_tokens=False already means "skip nothing").

Test

Adds a regression test asserting that a detokenizer converted with skip_special_tokens=False produces no zero-dimensional Const feeding the VocabDecoder, and round-trips special tokens correctly.

Context

Found while enabling opendatalab/MinerU2.5-Pro-2604-1.2B (a Qwen2-VL document-parsing VLM) for OpenVINO. That model relies on custom structural special tokens (<fcel>, <ched>, <|md_start|>, …) in its generated Markdown; skip_special_tokens=False is required to preserve them in VLMPipeline output.

Follow-up

A separate hardening could be made in the OpenVINO CPU plugin to tolerate zero-dim Const inputs to custom ops gracefully rather than crashing; tracked as a follow-up issue. This PR fixes the issue at the tokenizer-graph layer, which is the correct place.

…False

When skip_special_tokens=False (do_skip_tokens=False), the previous code
used a Slice with stop=0 to produce an empty output, which constant-folds
to a zero-dimension Constant node as VocabDecoder port-4.  This zero-dim
Const triggers a crash in the Intel CPU plugin:

    Check 'edge' failed at node.cpp:712:
    Node ReadValue_XXXX contains dead weak ptr

when the detokenizer is loaded alongside a stateful language model in
VLMPipeline (KV-cache ReadValue/Assign nodes have their Variable registry
corrupted by the zero-dim Const compilation).

Fix: when do_skip_tokens=False, simply omit port-4 entirely.  VocabDecoder
already supports 4-input form (falls back to empty m_skip_tokens attribute
== skip nothing), so this is semantically correct and avoids the crash.

This also removes the never-used "runtime on/off toggle" mechanism
(it was broken: a constant stop value means no actual runtime switch).

Tested with: opendatalab/MinerU2.5-Pro-2604-1.2B (Qwen2-based VLM)
which requires skip_special_tokens=False to preserve document-structure
tokens (<fcel>, <nl>, <|md_start|>, etc.) in VLMPipeline output.
@apaniukov

Copy link
Copy Markdown
Collaborator

skip_special_tokens parameter can be dynamically adjusted after export in GenAI: https://github.com/openvinotoolkit/openvino.genai/blob/61ed04788e5b7476d5c877f928fae90d245973c7/tests/python_tests/test_tokenizer.py#L353

Deleting special tokens constant from the graph will break this functionality.
PR for the CPU plugin is better solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants