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

Move metadata package to _src. Continue exposing commonly-used symbols. #1602

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions t5x/checkpoint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import jax
import msgpack
import orbax.checkpoint as ocp
from orbax.checkpoint._src.metadata import tree as ocp_tree_metadata # pylint: disable=protected-access
from tensorflow.io import gfile


Expand Down Expand Up @@ -284,12 +285,12 @@ def get_restore_parameters(

def _get_param_info(
name: str,
meta_or_value: Union[Any, ocp.metadata.tree.ValueMetadataEntry],
meta_or_value: Union[Any, ocp_tree_metadata.ValueMetadataEntry],
) -> Union[ocp.type_handlers.ParamInfo, Any]:
if _is_supported_empty_value(meta_or_value):
# Empty node, ParamInfo should not be returned.
return meta_or_value
elif not isinstance(meta_or_value, ocp.metadata.tree.ValueMetadataEntry):
elif not isinstance(meta_or_value, ocp_tree_metadata.ValueMetadataEntry):
# Aggregated value.
skip_deserialize = True
else:
Expand Down
7 changes: 4 additions & 3 deletions t5x/checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import jax.numpy as jnp
import numpy as np
import orbax.checkpoint as ocp
from orbax.checkpoint._src.metadata import tree as ocp_tree_metadata # pylint: disable=protected-access
from t5x import checkpoint_importer
from t5x import checkpoint_utils
from t5x import checkpoints_utils
Expand Down Expand Up @@ -2142,14 +2143,14 @@ def _transform_fn(
del structure_, param_infos_

def _make_orbax_internal_metadata(value: Any, args: ocp.RestoreArgs):
if isinstance(value, ocp.metadata.tree.ValueMetadataEntry):
if isinstance(value, ocp_tree_metadata.ValueMetadataEntry):
if value.value_type == 'scalar':
return ocp.metadata.tree.ValueMetadataEntry(value_type='scalar')
return ocp_tree_metadata.ValueMetadataEntry(value_type='scalar')
if isinstance(args, ocp.ArrayRestoreArgs):
value_type = 'jax.Array'
else:
value_type = 'np.ndarray'
return ocp.metadata.tree.ValueMetadataEntry(value_type=value_type)
return ocp_tree_metadata.ValueMetadataEntry(value_type=value_type)
else:
return value

Expand Down
Loading