{"action":"created","issue":{"url":"https://api.github.com/repos/HIPS/firefly-monte-carlo/issues/1","repository_url":"https://api.github.com/repos/HIPS/firefly-monte-carlo","labels_url":"https://api.github.com/repos/HIPS/firefly-monte-carlo/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/HIPS/firefly-monte-carlo/issues/1/comments","events_url":"https://api.github.com/repos/HIPS/firefly-monte-carlo/issues/1/events","html_url":"https://github.com/HIPS/firefly-monte-carlo/pull/1","id":151219487,"number":1,"title":"Fixes pseudo likelihood cache","user":{"login":"feynmanliang","id":990069,"avatar_url":"https://avatars.githubusercontent.com/u/990069?v=3","gravatar_id":"","url":"https://api.github.com/users/feynmanliang","html_url":"https://github.com/feynmanliang","followers_url":"https://api.github.com/users/feynmanliang/followers","following_url":"https://api.github.com/users/feynmanliang/following{/other_user}","gists_url":"https://api.github.com/users/feynmanliang/gists{/gist_id}","starred_url":"https://api.github.com/users/feynmanliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feynmanliang/subscriptions","organizations_url":"https://api.github.com/users/feynmanliang/orgs","repos_url":"https://api.github.com/users/feynmanliang/repos","events_url":"https://api.github.com/users/feynmanliang/events{/privacy}","received_events_url":"https://api.github.com/users/feynmanliang/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-26T19:29:50Z","updated_at":"2016-04-28T10:22:15Z","closed_at":"2016-04-27T18:04:54Z","pull_request":{"url":"https://api.github.com/repos/HIPS/firefly-monte-carlo/pulls/1","html_url":"https://github.com/HIPS/firefly-monte-carlo/pull/1","diff_url":"https://github.com/HIPS/firefly-monte-carlo/pull/1.diff","patch_url":"https://github.com/HIPS/firefly-monte-carlo/pull/1.patch"},"body":"This patch addresses incorrect caching of pseudo-likelihoods for `LogisticModel`. The provided `CacheWithIdx` currently performs caching on both arguments `th` (the parameter values) and `idxs` (the indices of the bright data points). This currently does not handle cases where `idxs2` may be a subset or share data points with `idxs`.\r\n\r\nFor example, if `idxs2` is a subset of `idxs` then (`th`, `idxs`) and (`th`, `idxs2`) are treated as two separate cache misses even though `idxs2` just returns a subset of the pseudo-likelihoods already computed and cached for `idxs`.\r\n\r\nIn our patch, `pylru` is used as an element-wise cache on (`th`, `idx`) where `idx` is a single index rather than an array of indices. This allows sharing of cached elements between likelihood evaluations used for computing MH acceptance probabilities (i.e. the (t+1)st iteration's numerator term P(\\theta_{t} | z^{t+1}_{i}) and the previous iteration's denominator term P(\\theta_{t} | z^{t}_i) can share indices i where z^{t+1}_{i} = 1 = z^{t}_i).\r\n\r\n@xukai92 @blutooth"},"comment":{"url":"https://api.github.com/repos/HIPS/firefly-monte-carlo/issues/comments/215379004","html_url":"https://github.com/HIPS/firefly-monte-carlo/pull/1#issuecomment-215379004","issue_url":"https://api.github.com/repos/HIPS/firefly-monte-carlo/issues/1","id":215379004,"user":{"login":"feynmanliang","id":990069,"avatar_url":"https://avatars.githubusercontent.com/u/990069?v=3","gravatar_id":"","url":"https://api.github.com/users/feynmanliang","html_url":"https://github.com/feynmanliang","followers_url":"https://api.github.com/users/feynmanliang/followers","following_url":"https://api.github.com/users/feynmanliang/following{/other_user}","gists_url":"https://api.github.com/users/feynmanliang/gists{/gist_id}","starred_url":"https://api.github.com/users/feynmanliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feynmanliang/subscriptions","organizations_url":"https://api.github.com/users/feynmanliang/orgs","repos_url":"https://api.github.com/users/feynmanliang/repos","events_url":"https://api.github.com/users/feynmanliang/events{/privacy}","received_events_url":"https://api.github.com/users/feynmanliang/received_events","type":"User","site_admin":false},"created_at":"2016-04-28T10:22:15Z","updated_at":"2016-04-28T10:22:15Z","body":"@dougalm I think this patch is needed for FlyMC to be competitive. Otherwise, the number of likelihood evaluations can exceed regular MCMC.\r\n\r\nStepping brightness variables (`z` and `z_new`) results in two cache misses when computing acceptance probabilities for theta (`th`):`log_pseudo_lik(th_new, z_new)` and `log_pseudo_lik(th_curr, z_new)`.\r\n\r\nIn contrast, full MCMC (i.e. fixing all z_i=1) has `z = z_new` so the call for `log_pseudo_lik(th_curr, z_new)` will be a cache hit because it was computed before transitioning to `th_curr`."}}