Use of thread-local variables in AbstractMCMC

Open
#128 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
julia

Research direction

Start by reviewing the AbstractMCMC parallel-sampling interface and the Julia threadid() guidance linked in the issue. The issue needs a maintainer decision on the supported strategy for per-task mutable likelihood data; done should be a documented, concurrency-safe approach that preserves useful parallelism.

Written by the indexing model from the issue text.

Description

I need to sample a distribution for which the calculation of the log-likelihood is particularly time consuming. To speed-up calculations, it is beneficial to pass to the likelihood mutable data that (1) partially contain pre-computed values and (2) can be modified by the log-likelihood depending on the specific set of parameters passed to each call.

It would be relatively easy to implement this on a sequential (non-parallel) execution of a sampling, since I could attach the mutable data to the object representing the distribution. Problems arise however for parallel processing: in this case I would need to have n copies of the mutable data, one for each task.

One way could be to store n-copies of the data and access them in each log-likelihood call using the threadid(), but as clarified here this is no longer correct.

Another possibility would be to use a lock, but this would cancel much of the benefits of going parallel, as the mutable data are used during all the loglikelihood computation.

Dominant language
Julia
Stars
108
Forks
20
Avg merge
45m
Merged PRs (30d)
2

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.

More from TuringLang/AbstractMCMC.jl

All issues in TuringLang/AbstractMCMC.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.