Repository navigation
hash: keep hash consistent with isequal - #1543
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1543 +/- ##
==========================================
+ Coverage 85.07% 85.12% +0.04%
==========================================
Files 52 52
Lines 4663 4671 +8
==========================================
+ Hits 3967 3976 +9
+ Misses 696 695 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
DynamicPPL.jl documentation for PR #1543 is available at: |
BenchmarksPerformance Ratio: gradient time divided by log-density time. For very small models these ratios are noisy across runs and machines; raw primal and gradient timings are more reliable. The benchmarks are aimed at DynamicPPL developers and mainly catch obvious allocation or type-stability regressions. See benchmark notes for details. Primal times: EnvironmentJulia Version 1.13.4 Commit c1ac32ab733 (2026-11-13 17:30 UTC) Build Info: Official https://julialang.org release Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 4 × AMD EPYC 7763 64-Core Processor WORD_SIZE: 64 LLVM: libLLVM-20.1.8 (ORCJIT, znver3) GC: Built with stock GC Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores) |
`FixedTransform`, `TransformedValue`, `WithTransforms`, `LinkSome`, `UnlinkSome` and `ParamsWithStats` define `isequal` but used the `objectid`-based default `hash`, so equal values holding separate arrays or sets hashed differently and a `Set` or `Dict` kept both. Other methods hashed what `isequal` ignores: `PartialArray` its storage type and, with a `GrowableArray` mask, `CartesianIndex` positions; `GrowableArray` its wrapper type, although it equals a plain `Array`; `LogProbAccumulator` the type of its log-probability. For example, `LogPriorAccumulator(1)` and `LogPriorAccumulator(1.0)` were equal but hashed differently. Assisted-by: Claude Code <noreply@anthropic.com>
44446ed to
c74dedf
Compare
shravanngoswamii
left a comment
There was a problem hiding this comment.
Equal copies of FixedTransform(Shift([1.0, 2.0])) still hash differently because Shift itself has the same issue.
Should we fix the Bijectors hashes before part 4?
@shravanngoswamii can you try that? |
Split of #1529 (part 3 of 12).
FixedTransform,TransformedValue,WithTransforms,LinkSome,UnlinkSomeandParamsWithStatsdefineisequalbut used the defaulthash, which depends on the identity of the arrays and sets they hold. Equal values holding separate arrays or sets therefore hashed differently, and aSetorDictkept both:Set([TransformedValue([1.0], NoTransform()), TransformedValue([1.0], NoTransform())])had two elements and now has one. Each type now hashes the fields itsisequalcompares.Three existing methods also hashed what
isequalignores, so equal values could hash differently:PartialArrayhashed its storage type, and keyed assigned entries byCartesianIndexwhen its mask was aGrowableArray; it now hashes its size and the linear positions and values of assigned entries.GrowableArrayhashed its wrapper type, although it compares equal to a plainArray.LogProbAccumulatorhashed its numeric type, soLogPriorAccumulator(1)andLogPriorAccumulator(1.0)were equal but hashed differently.Part 4 hashes a model's arguments and bindings, which may contain these values, so their hashes must agree with
isequal. Each type gains a small test, and HISTORY gains a one-line bugfix entry.