Skip to content

Fix thread safety of debug raw value accumulator (#1337)#1338

Merged
penelopeysm merged 1 commit intomainfrom
py/ts
Mar 26, 2026
Merged

Fix thread safety of debug raw value accumulator (#1337)#1338
penelopeysm merged 1 commit intomainfrom
py/ts

Conversation

@penelopeysm
Copy link
Copy Markdown
Member

Closes #1337

Copy `acc.f` in `Base.copy` for VNTAccumulator/TSVNTAccumulator so that
mutable state (e.g. `repeated_vns::Set{VarName}`) is not shared across
threads.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Benchmark Report

  • this PR's head: 04682e150b82f2b25dc8b0726a831d89378a978b
  • base branch: a1e8f06f4e38c61ba9364201d44b2f6c1950be41

Computer Information

Julia Version 1.11.9
Commit 53a02c0720c (2026-02-06 00:27 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-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

Benchmark Results

┌───────────────────────┬───────┬─────────────┬────────┬───────────────────────────────┬────────────────────────────┬─────────────────────────────────┐
│                       │       │             │        │       t(eval) / t(ref)        │     t(grad) / t(eval)      │        t(grad) / t(ref)         │
│                       │       │             │        │ ─────────┬──────────┬──────── │ ───────┬─────────┬──────── │ ──────────┬───────────┬──────── │
│                 Model │   Dim │  AD Backend │ Linked │     base │  this PR │ speedup │   base │ this PR │ speedup │      base │   this PR │ speedup │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│               Dynamic │    10 │    mooncake │   true │   293.76 │   293.15 │    1.00 │   6.58 │    8.03 │    0.82 │   1932.08 │   2354.42 │    0.82 │
│                   LDA │    12 │ reversediff │   true │  3271.74 │  2934.54 │    1.11 │   2.55 │    3.34 │    0.76 │   8355.42 │   9798.55 │    0.85 │
│   Loop univariate 10k │ 10000 │    mooncake │   true │ 29280.88 │ 30831.57 │    0.95 │   7.38 │    6.55 │    1.13 │ 216051.80 │ 201957.15 │    1.07 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│    Loop univariate 1k │  1000 │    mooncake │   true │  4152.59 │  3138.28 │    1.32 │   5.27 │    6.40 │    0.82 │  21889.12 │  20075.26 │    1.09 │
│      Multivariate 10k │ 10000 │    mooncake │   true │ 44541.07 │ 31630.24 │    1.41 │   6.74 │   10.01 │    0.67 │ 300230.46 │ 316596.51 │    0.95 │
│       Multivariate 1k │  1000 │    mooncake │   true │  3869.31 │  3394.53 │    1.14 │   8.19 │    9.34 │    0.88 │  31671.62 │  31688.73 │    1.00 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│ Simple assume observe │     1 │ forwarddiff │  false │     0.88 │     0.88 │    1.00 │  11.44 │   10.52 │    1.09 │     10.05 │      9.23 │    1.09 │
│           Smorgasbord │   201 │ forwarddiff │  false │   956.99 │   954.32 │    1.00 │  77.17 │   70.98 │    1.09 │  73853.04 │  67733.42 │    1.09 │
│           Smorgasbord │   201 │      enzyme │   true │  1298.14 │  1325.83 │    0.98 │   4.43 │    4.78 │    0.93 │   5752.21 │   6338.05 │    0.91 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│           Smorgasbord │   201 │ forwarddiff │   true │  1313.86 │  1294.91 │    1.01 │  69.55 │   68.04 │    1.02 │  91384.46 │  88110.78 │    1.04 │
│           Smorgasbord │   201 │    mooncake │   true │  1305.51 │  1310.37 │    1.00 │   4.55 │    4.72 │    0.96 │   5936.69 │   6183.67 │    0.96 │
│           Smorgasbord │   201 │ reversediff │   true │  1284.39 │  1307.38 │    0.98 │ 123.62 │  135.17 │    0.91 │ 158770.21 │ 176715.97 │    0.90 │
├───────────────────────┼───────┼─────────────┼────────┼──────────┼──────────┼─────────┼────────┼─────────┼─────────┼───────────┼───────────┼─────────┤
│              Submodel │     1 │    mooncake │   true │     0.87 │     0.88 │    0.99 │  29.28 │   26.78 │    1.09 │     25.57 │     23.56 │    1.09 │
└───────────────────────┴───────┴─────────────┴────────┴──────────┴──────────┴─────────┴────────┴─────────┴─────────┴───────────┴───────────┴─────────┘

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.93%. Comparing base (a1e8f06) to head (04682e1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/accumulators/vnt.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1338   +/-   ##
=======================================
  Coverage   77.93%   77.93%           
=======================================
  Files          50       50           
  Lines        3585     3585           
=======================================
  Hits         2794     2794           
  Misses        791      791           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@penelopeysm penelopeysm merged commit 1285327 into main Mar 26, 2026
22 of 23 checks passed
@penelopeysm penelopeysm deleted the py/ts branch March 26, 2026 22:20
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.

debug raw value acc is not threadsafe

1 participant