Skip to content

Fix laser equality/hashing and actually run the thread-safety test#55

Merged
SebastianM-C merged 3 commits into
masterfrom
claude/multi-threading-review-9hat4i
Jul 13, 2026
Merged

Fix laser equality/hashing and actually run the thread-safety test#55
SebastianM-C merged 3 commits into
masterfrom
claude/multi-threading-review-9hat4i

Conversation

@SebastianM-C

Copy link
Copy Markdown
Owner

Follow-up fixes from a review of the multi-threading implementation (the TaskLocalValue-based scratch caches introduced in #54 are sound; these are the issues found around them).

Changes

Run the thread-safety test in CI

test/threads.jl existed and the CI matrix runs with JULIA_NUM_THREADS: 1/2 specifically for it, but test/runtests.jl never included it — so the regression fixed in #54 had no test coverage. It is now part of the test suite (@safetestset "Threads").

Exclude the task-local scratch cache from ==, isequal and hash

The cache only holds transient intermediate results of the last field evaluation, so including it made equality and hashing depend on the evaluation history of the current task: a laser's hash changed after every E/B call (breaking lasers as Dict/Set keys), two identical lasers compared unequal if only one had been evaluated, and merely comparing or hashing a laser allocated a cache for the calling task.

The new implementations compare/hash all fields except cache. This also:

  • fixes a copy-paste bug in isequal, which compared geometry(a) against mutable_cache(b) and therefore always returned false;
  • makes the laser parameters (λ, a₀, ϕ₀, w₀, …) part of equality — previously two lasers differing only in ϕ₀ compared equal.

Bump minimum Julia version to 1.10

The declared julia = "1" compat was already unsatisfiable in practice since TaskLocalValues requires a newer Julia. The package version in Project.toml is left untouched — bump it as you see fit when releasing.

Notes

  • The existing setup_laser equality tests in test/setup.jl still pass with the stricter ==.
  • Not included (happy to do as a follow-up): hoisting the laser.cache[] lookup so each field evaluation does one task-local lookup instead of ~11, and the longer-term refactor to pass an immutable intermediates struct instead of mutating a cache.

🤖 Generated with Claude Code

https://claude.ai/code/session_012Hx2cg1rQe5TmeWiy31HCv


Generated by Claude Code

claude and others added 3 commits July 13, 2026 21:35
- Include test/threads.jl in the test suite; the CI threads matrix never
  actually exercised it.
- Exclude the task-local scratch cache from ==, isequal and hash: it only
  holds transient intermediate results, so including it made equality and
  hashes depend on the evaluation history of the current task (and hashing
  allocated a cache as a side effect). This also fixes a copy-paste bug in
  isequal which compared geometry(a) against mutable_cache(b), and makes
  the laser parameters (e.g. phi0) part of equality.
- Bump the minimum Julia version to 1.10; the declared julia = "1" compat
  was already unsatisfiable since TaskLocalValues requires a newer Julia.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Hx2cg1rQe5TmeWiy31HCv
On the 1.13 pre-release JET reports runtime dispatch from upstream code
(Base printing/broadcast internals, StaticArrays construction) as well as
inference regressions surfacing at LaserTypes call sites, so restrict the
QA testset to release versions of Julia.

Also fix the CI job name template (matrix.julia-version -> matrix.version)
so the Julia version shows up in job names.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Hx2cg1rQe5TmeWiy31HCv
@SebastianM-C SebastianM-C merged commit 20fae6a into master Jul 13, 2026
14 checks passed
@SebastianM-C SebastianM-C deleted the claude/multi-threading-review-9hat4i branch July 13, 2026 22:27
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