google / google/meridian

Channel-ordered (mu, sigma) tuples not saved via Serde package

Open
#1,404 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
297
Avg merge
1d 21h
Merged PRs (30d)
47

Description

I am trying to save a model I created as a .binpb file. I had used custom priors for each channel that were saved as a tuple, the model runs and can be saved as a .pkl file, but when I run meridian_serde.save_meridian(mmm, file_path), I get the following error:

2 meridian_serde.save_meridian(mmm, file_path)

5 frames
/usr/local/lib/python3.12/dist-packages/schema/serde/distribution.py in _to_parameter_value_proto(self, param_name, value, dist)
260
261 # Handle unsupported types.
--> 262 raise TypeError(f"Unsupported type: {type(value)}, {value}")
263
264 def _from_distribution_proto(

TypeError: Unsupported type: <class 'tuple'>, (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure through meridian_serde.save_meridian(mmm, file_path) using the channel-ordered tuple priors, then inspect schema/serde/distribution.py around _to_parameter_value_proto. Compare the successful .pkl save with the failing .binpb path; done means models using these tuple-valued custom priors can be saved as .binpb without the Unsupported type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.