The reason for this error is that the class definition is missing the config_class
class CustomModel(PreTrainedModel):
config_class = CustomConfig
def __init__(self, config, ...
...
There is an example in the guide in the original question.