keras-team/keras · error · ValueError
Lora is incompatible with embedding constraints. In order to
Error message
Lora is incompatible with embedding constraints. In order to enable lora on this layer, remove the `embeddings_constraint` argument.
What it means
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.
Source
Thrown at keras/src/layers/core/embedding.py:222
def compute_output_shape(self, input_shape):
return (*input_shape, self.output_dim)
def compute_output_spec(self, inputs):
output_shape = self.compute_output_shape(inputs.shape)
ragged = getattr(inputs, "ragged", False)
return KerasTensor(
output_shape, dtype=self.compute_dtype, ragged=ragged
)
def enable_lora(
self,
rank,
lora_alpha=None,
a_initializer="he_uniform",
b_initializer="zeros",
):
if self.embeddings_constraint:
raise ValueError(
"Lora is incompatible with embedding constraints. "
"In order to enable lora on this layer, remove the "
"`embeddings_constraint` argument."
)
if not self.built:
raise ValueError(
"Cannot enable lora on a layer that isn't yet built."
)
if self.lora_enabled:
raise ValueError(
"lora is already enabled. This can only be done once per layer."
)
self._tracker.unlock()
# LoRA weights should be float32 to avoid the risk of underflow or
# overflow during fine-tuning.
# When deploying the model, these weights should be merged with the
# original embedding while maintaining the original embedding's dtype.View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/layers/core/embedding.py:222 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/33b9a6e8da101396.
Report an issue: GitHub.