{"record":{"id":"6108d5cbeb7b0b6e","repo":"huggingface/transformers","slug":"assisted-generate-is-not-supported-with-static-cac","errorCode":null,"errorMessage":"assisted generate is not supported with Static cache classes`","messagePattern":"assisted generate is not supported with Static cache classes`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/generation/utils.py","lineNumber":3626,"sourceCode":"            model_kwargs:\n                Additional model specific keyword arguments will be forwarded to the `forward` function of the model.\n                If model is an encoder-decoder model the kwargs should include `encoder_outputs`.\n\n        Return:\n            [`~generation.GenerateDecoderOnlyOutput`], [`~generation.GenerateEncoderDecoderOutput`] or\n            `torch.LongTensor`: A `torch.LongTensor` containing the generated tokens (default behaviour) or a\n            [`~generation.GenerateDecoderOnlyOutput`] if `model.config.is_encoder_decoder=False` and\n            `return_dict_in_generate=True` or a [`~generation.GenerateEncoderDecoderOutput`] if\n            `model.config.is_encoder_decoder=True`.\n        \"\"\"\n        # The cache must be dynamic for assisted generation, and the check must happen AFTER preparing cache\n        if not model_kwargs[\"use_cache\"]:\n            raise ValueError(\"assisted generate requires `use_cache=True`\")\n        if (\n            generation_config.cache_implementation in [\"static\", \"hybrid\", \"sliding_window\"]\n            or type(model_kwargs.get(\"past_key_values\")) is StaticCache\n        ):\n            raise ValueError(\"assisted generate is not supported with Static cache classes`\")\n\n        # Make sure we can record past on the cache\n        cache = model_kwargs.get(\"past_key_values\")\n        if cache is None:\n            raise RuntimeError(\"assisted decoding requires a cache\")\n        cache.activate_past_recording()\n\n        # Get the candidate generator, given the parameterization\n        candidate_generator = self._get_candidate_generator(\n            generation_config=generation_config,\n            input_ids=input_ids,\n            inputs_tensor=inputs_tensor,\n            assistant_model=assistant_model,\n            logits_processor=logits_processor,\n            target_tokenizer=tokenizer,\n            assistant_tokenizer=assistant_tokenizer,\n            model_kwargs=model_kwargs,\n        )","sourceCodeStart":3608,"sourceCodeEnd":3644,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/generation/utils.py#L3608-L3644","documentation":"Error \"assisted generate is not supported with Static cache classes`\" thrown in huggingface/transformers.","triggerScenarios":"Raised in assisted generation when the cache implementation is a Static cache class.","commonSituations":"Combining cache_implementation='static' (or StaticCache) with assistant_model speculative decoding.","solutions":["Set `cache_implementation='dynamic'` (or leave default) instead of a Static cache for assisted generation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}