Skip to content

Fix load_params error reporting expected instead of actual checkpoint type - #754

Open
PratikDhanave wants to merge 1 commit into
google-deepmind:mainfrom
PratikDhanaveFork:fix/checkpoint-error-reports-expected-not-actual
Open

Fix load_params error reporting expected instead of actual checkpoint type#754
PratikDhanave wants to merge 1 commit into
google-deepmind:mainfrom
PratikDhanaveFork:fix/checkpoint-error-reports-expected-not-actual

Conversation

@PratikDhanave

Copy link
Copy Markdown

In gemma/gm/ckpts/_checkpoint.py, load_params validates the caller-provided params:

if params.type != _CheckpointType.NESTED:
    raise ValueError(
        'The input params provided to `load_params()` should be the raw'
        " model params matching the Flax `model.init()['params']` structure."
        f' Got: {_CheckpointType.NESTED}'
    )

The Got: suffix interpolates the constant _CheckpointType.NESTED — the expected value — so the message always reads Got: ...NESTED even though we only reach this branch when params.type is something else. Report params.type (the actual value that failed the check) instead, so the error tells the user what they actually passed.

… type

The guard 'if params.type != _CheckpointType.NESTED' raises a ValueError
whose 'Got: ...' suffix interpolated the constant _CheckpointType.NESTED
(the expected value), so it always printed 'Got: NESTED' regardless of the
real structure. Report params.type -- the value that actually failed the
check -- so the message is actionable.
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

Successfully merging this pull request may close these issues.

1 participant