Skip to content

Add a kwarg to choose if a model loaded from the preset should be compiled or not #1735

Closed
@markomitos

Description

Is your feature request related to a problem? Please describe.
When trying toconvert a loaded Gemma 2 model from a preset into a TensorFlow Federated model I ran into the issue that I need the model to not be compiled when loaded from a preset.

Describe the solution you'd like
I want a boolean kwarg in the keras_nlp.models.GemmaCausalLM.from_preset method that can be further passed down to the model here:
/~https://github.com/keras-team/keras-nlp/blob/c1afb070ded549d0c18fad812f04d4604553fd59/keras_nlp/src/models/task.py#L273

That way there can be an if statement here:
/~https://github.com/keras-team/keras-nlp/blob/c1afb070ded549d0c18fad812f04d4604553fd59/keras_nlp/src/models/causal_lm.py#L77
Which can determine if the model should be compiled or not depending on the kwarg passed. This can be true by default, that way it will not affect any existing code.

Describe alternatives you've considered
Alternatively you could elimate the compilation from the preset loading all toghether however I think this would affect to much existing code and it is not neccessary for this feature.

Additional context
My use case is that I am trying to add keras 3 support to TensorFlow Federated and I want to load a preexisting model and convert it to a TensorFlow Federated Model. When I removed the compile from the source code this worked without issues.

Metadata

Labels

GemmaGemma model specific issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions