{"record":{"id":"33b9a6e8da101396","repo":"keras-team/keras","slug":"lora-is-incompatible-with-embedding-constraints-i","errorCode":null,"errorMessage":"Lora is incompatible with embedding constraints. In order to enable lora on this layer, remove the `embeddings_constraint` argument.","messagePattern":"Lora is incompatible with embedding constraints\\. In order to enable lora on this layer, remove the `embeddings_constraint` argument\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/core/embedding.py","lineNumber":222,"sourceCode":"    def compute_output_shape(self, input_shape):\n        return (*input_shape, self.output_dim)\n\n    def compute_output_spec(self, inputs):\n        output_shape = self.compute_output_shape(inputs.shape)\n        ragged = getattr(inputs, \"ragged\", False)\n        return KerasTensor(\n            output_shape, dtype=self.compute_dtype, ragged=ragged\n        )\n\n    def enable_lora(\n        self,\n        rank,\n        lora_alpha=None,\n        a_initializer=\"he_uniform\",\n        b_initializer=\"zeros\",\n    ):\n        if self.embeddings_constraint:\n            raise ValueError(\n                \"Lora is incompatible with embedding constraints. \"\n                \"In order to enable lora on this layer, remove the \"\n                \"`embeddings_constraint` argument.\"\n            )\n        if not self.built:\n            raise ValueError(\n                \"Cannot enable lora on a layer that isn't yet built.\"\n            )\n        if self.lora_enabled:\n            raise ValueError(\n                \"lora is already enabled. This can only be done once per layer.\"\n            )\n        self._tracker.unlock()\n\n        # LoRA weights should be float32 to avoid the risk of underflow or\n        # overflow during fine-tuning.\n        # When deploying the model, these weights should be merged with the\n        # original embedding while maintaining the original embedding's dtype.","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/core/embedding.py#L204-L240","documentation":"Error \"Lora is incompatible with embedding constraints. In order to enable lora on this layer, remove the `embeddings_constraint` argument.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/core/embedding.py:222 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}