Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.6 bug: AttributeError: 'GPT2CausalLM' object has no attribute 'compiled' #916

Closed
sirfz opened this issue Sep 19, 2023 · 2 comments
Closed

Comments

@sirfz
Copy link

sirfz commented Sep 19, 2023

Not sure if this affects other models but in v0.1.6 the .summary() method is broken on GPT2CausalLM. Downgrading to keras_core v0.1.5 resolves the issue.

Versions:

  • keras_core 0.1.6
  • tensorflow 2.13.0
  • keras 2.13.1
  • keras_nlp 0.6.1

To reproduce:

import keras_nlp

gpt2_lm = keras_nlp.models.GPT2CausalLM.from_preset("gpt2_base_en")
gpt2_lm.summary()

Error output:

In [3]: gpt2_lm.summary()
Preprocessor: "gpt2_causal_lm_preprocessor"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Tokenizer (type)                                   ┃                                             Vocab # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ gpt2_tokenizer (GPT2Tokenizer)                     │                                              50,257 │
└────────────────────────────────────────────────────┴─────────────────────────────────────────────────────┘
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 gpt2_lm.summary()

File /opt/tensorflow/lib/python3.10/site-packages/keras_nlp/src/models/task.py:311, in Task.summary(self, line_length, positions, print_fn, **kwargs)
    308         print_fn(console.end_capture(), line_break=False)
    310 # Hardcode summary from keras_core for now.
--> 311 keras_core.Model.summary(
    312     self,
    313     line_length=line_length,
    314     positions=positions,
    315     print_fn=print_fn,
    316     **kwargs,
    317 )

File /opt/tensorflow/lib/python3.10/site-packages/keras_core/src/utils/traceback_utils.py:123, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    120     filtered_tb = _process_traceback_frames(e.__traceback__)
    121     # To get the full stack trace, call:
    122     # `keras_core.config.disable_traceback_filtering()`
--> 123     raise e.with_traceback(filtered_tb) from None
    124 finally:
    125     del filtered_tb

File /opt/tensorflow/lib/python3.10/site-packages/keras_core/src/utils/summary_utils.py:311, in print_summary(model, line_length, positions, print_fn, expand_nested, show_trainable, layer_range)
    308 non_trainable_count = count_params(model.non_trainable_weights)
    309 non_trainable_memory_size = weight_memory_size(model.non_trainable_weights)
--> 311 if model.compiled and model.optimizer and model.optimizer.built:
    312     optimizer_weight_count = count_params(model.optimizer.variables)
    313     optimizer_memory_size = weight_memory_size(model.optimizer.variables)
@mattdangerw
Copy link
Member

Thanks for the bug, we landed a fix for this on the keras-nlp side last week, we just need to cut a new keras-nlp release with this fix. Should do shortly!

keras-team/keras-hub#1244

@mattdangerw
Copy link
Member

Release is out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants