Skip to content

do not pickle cached hash of arrays - #563

Merged
inducer merged 10 commits into
mainfrom
pickle-hash
Dec 4, 2024
Merged

do not pickle cached hash of arrays#563
inducer merged 10 commits into
mainfrom
pickle-hash

Conversation

@matthiasdiener

@matthiasdiener matthiasdiener commented Nov 21, 2024

Copy link
Copy Markdown
Contributor

Prevents errors of the type:

pytato.distributed.verify.MissingSendError: no send for 'CommunicationOpIdentifier(src_rank=1, dest_rank=0, comm_tag=('fluid', (<class 'mirgecom.diffusion._DiffusionStateTag'>, (<class 'y3prediction.prediction._SmoothCharDiffFluidCommTag'>, Placeholder(shape=(), dtype='int64', name='_actx_in_1'))), (0,)))'

(see e.g. https://github.com/illinois-ceesd/mirgecom/actions/runs/11958222838/job/33337251412?pr=926)

cc @MTCam

Followup of #521.

Please squash

@matthiasdiener matthiasdiener self-assigned this Nov 21, 2024
Comment thread pytato/array.py Outdated
@matthiasdiener
matthiasdiener changed the base branch from main to pymbolic-2024.2 November 21, 2024 23:11

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree that this needs to be fixed. Just a few nits to pick below.

Comment thread pytato/array.py Outdated
Comment thread pytato/array.py Outdated
Comment thread pytato/array.py Outdated
Comment thread pytato/array.py Outdated
Base automatically changed from pymbolic-2024.2 to main November 22, 2024 19:46
@matthiasdiener
matthiasdiener marked this pull request as ready for review November 25, 2024 20:13
@matthiasdiener
matthiasdiener marked this pull request as draft November 25, 2024 20:37
@matthiasdiener
matthiasdiener marked this pull request as ready for review November 25, 2024 20:43
Comment thread pytato/array.py Outdated
@matthiasdiener

matthiasdiener commented Dec 2, 2024

Copy link
Copy Markdown
Contributor Author

A somewhat unorthodox thought - should we even cache the hash of dataclasses, or could we rely on that any "large" field of the dataclass (say, an immutabledict) already caches their own hash?

What dataclasses does to generate a hash is to create a tuple of field values and hash that tuple:
https://github.com/python/cpython/blob/a8536102828ac70000fc6b4c67e0b439ab0ddf98/Lib/dataclasses.py#L886-L892

In case caching the hash is not needed, neither the custom hashing nor the caching of the hash would be necessary (but we would have to set unsafe_hash=True to enable hashing when frozen=False for optimized executions).

This would also affect #566.

@matthiasdiener

Copy link
Copy Markdown
Contributor Author

A somewhat unorthodox thought - should we even cache the hash of dataclasses, or could we rely on that any "large" field of the dataclass (say, an immutabledict) already caches their own hash?

Nevermind, for recursive data structures like the DAG we will need cached hashes.

@matthiasdiener

Copy link
Copy Markdown
Contributor Author

A gentle ping for a review @inducer

@inducer
inducer merged commit d57cb0c into main Dec 4, 2024
@inducer
inducer deleted the pickle-hash branch December 4, 2024 15:26
@inducer

inducer commented Dec 4, 2024

Copy link
Copy Markdown
Owner

Thanks, LGTM!

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.

2 participants