{"record":{"id":"25ba27ae51800152","repo":"sgl-project/sglang","slug":"dspark-layer-capture-is-not-available-in-encoder-o","errorCode":null,"errorMessage":"DSPARK layer capture is not available in encoder-only mode","messagePattern":"DSPARK layer capture is not available in encoder-only mode","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/kimi_k3.py","lineNumber":3324,"sourceCode":"        if self.vision_tower.precompile_attention_backend():\n            logger.info(\"Precompiled Kimi-K3 vision FA4 kernel\")\n\n    def get_input_embeddings(self):\n        if self.language_model is None:\n            raise AttributeError(\n                \"get_input_embeddings() is not available in encoder-only mode\"\n            )\n        return self.language_model.model.embed_tokens\n\n    @property\n    def lm_head(self):\n        if self.language_model is None:\n            raise AttributeError(\"lm_head is not available in encoder-only mode\")\n        return self.language_model.lm_head\n\n    def set_dspark_layers_to_capture(self, layer_ids: list[int]) -> None:\n        if self.language_model is None:\n            raise AttributeError(\n                \"DSPARK layer capture is not available in encoder-only mode\"\n            )\n        self.language_model.set_dspark_layers_to_capture(layer_ids)\n\n    def preprocess_mm_for_encoder(\n        self,\n        mm_data,\n        modality,\n        config,\n        *,\n        image_processor=None,\n        use_gpu_preprocessing=False,\n    ):\n        \"\"\"Prepare per-image raw inputs for owner-side EPD preprocessing.\"\"\"\n        if modality != Modality.IMAGE:\n            raise ValueError(\"Kimi-K3 encoder mode supports image input only\")\n        if image_processor is None:\n            raise ValueError(\"Kimi-K3 encoder preprocessing needs an image processor\")","sourceCodeStart":3306,"sourceCodeEnd":3342,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/kimi_k3.py#L3306-L3342","documentation":"set_dspark_layers_to_capture() raises AttributeError when called on a Kimi-K3 model that has no language model (encoder-only mode), since DSPARK layer capture applies to language-model layers only. It is a pass-through to the language model's capture API and cannot work without one.","triggerScenarios":"Calling model.set_dspark_layers_to_capture(layer_ids) on an encoder-only Kimi-K3 instance, typically from speculative-decoding or layer-capture setup that runs on every model.","commonSituations":"Enabling DSPARK/speculative capture in a disaggregated EPD setup where the encoder process loads only the vision tower; generic harness code that calls capture setup unconditionally.","solutions":["Only call set_dspark_layers_to_capture when model.language_model is not None","Configure DSPARK capture on the decoder/prefill server, not the encoder-only instance","Gate the call site behind an encoder-only check"],"exampleFix":"// before\nmodel.set_dspark_layers_to_capture([8, 16, 24])\n\n// after\nif model.language_model is not None:\n    model.set_dspark_layers_to_capture([8, 16, 24])","handlingStrategy":"validation","validationCode":"if model.language_model is not None:\n    model.set_dspark_layers_to_capture(layer_ids)","typeGuard":"def supports_dspark_capture(m) -> bool:\n    return getattr(m, \"language_model\", None) is not None","tryCatchPattern":"try:\n    model.set_dspark_layers_to_capture(ids)\nexcept AttributeError:\n    logger.warning(\"DSPARK capture skipped: encoder-only model\")","preventionTips":["Configure speculative/DSPARK capture only on decoder-side processes","Centralize capability checks instead of probing methods with try/except"],"tags":["kimi-k3","encoder-only","dspark","attribute-error"],"backgroundTag":"attribute-not-available-in-mode","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}