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

[CLI]: jax.Array not serializable and not working with wandb.log #4735

Closed
weiyaw opened this issue Jan 6, 2023 · 9 comments
Closed

[CLI]: jax.Array not serializable and not working with wandb.log #4735

weiyaw opened this issue Jan 6, 2023 · 9 comments
Labels
a:cli Area: Client

Comments

@weiyaw
Copy link

weiyaw commented Jan 6, 2023

Describe the bug

Jax has recently introduce a new Array type, but wandb.log no longer works with this array.

This problem will go away after setting jax.config.update('jax_array', False) but this setting is only guaranteed to exist until 15/3/2023.

Some background info:
https://jax.readthedocs.io/en/latest/jax_array_migration.html#jax-array-migration

import jax.numpy as jnp
import wandb
wandb.init()
wandb.log({'test': jnp.array([3])})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/sdk/wandb_run.py", line 292, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/sdk/wandb_run.py", line 255, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/sdk/wandb_run.py", line 1612, in log
    self._log(data=data, step=step, commit=commit)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/sdk/wandb_run.py", line 1394, in _log
    self._partial_history_callback(data, step, commit)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/sdk/wandb_run.py", line 1278, in _partial_history_callback
    self._backend.interface.publish_partial_history(
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/sdk/interface/interface.py", line 556, in publish_partial_history
    item.value_json = json_dumps_safer_history(v)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/util.py", line 920, in json_dumps_safer_history
    return json.dumps(obj, cls=WandBHistoryJSONEncoder, **kwargs)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/site-packages/wandb/util.py", line 887, in default
    return json.JSONEncoder.default(self, obj)
  File "/Users/kenyonn/miniconda3/envs/jax4/lib/python3.9/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Array is not JSON serializable

Additional Files

No response

Environment

WandB version: 0.13.7

OS: MacOS 12.6.1

Python version: 3.9.13

Versions of relevant libraries: jax 0.4.1

Additional Context

No response

@weiyaw weiyaw added the a:cli Area: Client label Jan 6, 2023
@kevinzakka
Copy link

+1, seeing this issue too.

@ramit-wandb
Copy link
Contributor

Hi @weiyaw,

Thanks for pointing this out. I'll make an internal ticket to track this request. Since Array is a new datatype within JAX, it was not supported out of the box.

One of the members from our team will reach out once this is resolved.

Thanks,
Ramit

@sangtanisakshi
Copy link

+1, Also getting the same error on more or less a similar environment.

@dmitryduev
Copy link
Member

Hey folks, the fix for this (#4718) is in main and will be released this week, but in the meantime, would you mind checking that things work for you if installing from main?

@weiyaw
Copy link
Author

weiyaw commented Jan 10, 2023

Thanks @dmitryduev. It's working on my machine.

@kptkin
Copy link
Contributor

kptkin commented Jan 11, 2023

closing since this is fixed with release 0.13.8 if someone experience another issues, please feel free to re-open.

@exalate-issue-sync
Copy link

WandB Internal User commented:
sangtanisakshi commented:
+1, Also getting the same error on more or less a similar environment.

@exalate-issue-sync
Copy link

WandB Internal User commented:
weiyaw commented:
Thanks @dmitryduev. It's working on my machine.

@exalate-issue-sync
Copy link

WandB Internal User commented:
kptkin commented:
closing since this is fixed with release 0.13.8 if someone experience another issues, please feel free to re-open.

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

No branches or pull requests

6 participants