{"action":"created","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1126","repository_url":"https://api.github.com/repos/pymc-devs/pymc3","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1126/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1126/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1126/events","html_url":"https://github.com/pymc-devs/pymc3/issues/1126","id":156346708,"number":1126,"title":"NUTS is slow","user":{"login":"alxempirical","id":16612448,"avatar_url":"https://avatars.githubusercontent.com/u/16612448?v=3","gravatar_id":"","url":"https://api.github.com/users/alxempirical","html_url":"https://github.com/alxempirical","followers_url":"https://api.github.com/users/alxempirical/followers","following_url":"https://api.github.com/users/alxempirical/following{/other_user}","gists_url":"https://api.github.com/users/alxempirical/gists{/gist_id}","starred_url":"https://api.github.com/users/alxempirical/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxempirical/subscriptions","organizations_url":"https://api.github.com/users/alxempirical/orgs","repos_url":"https://api.github.com/users/alxempirical/repos","events_url":"https://api.github.com/users/alxempirical/events{/privacy}","received_events_url":"https://api.github.com/users/alxempirical/received_events","type":"User","site_admin":false},"labels":[{"id":76646,"url":"https://api.github.com/repos/pymc-devs/pymc3/labels/defects","name":"defects","color":"e10c02","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2016-05-23T19:21:37Z","updated_at":"2016-12-13T18:54:03Z","closed_at":null,"body":"I'm running the script below with 2,000 samples.  It's surprisingly slow, a bit under 9s / sample under `Python 2.7.11 :: Anaconda custom (x86_64)` on a Mid-2015 MacBook Pro with 2.5GHz CPUs (four of them, but the sampler seems to be single-threaded.)  I'd be grateful for any suggestions about how to speed it up.\n\n``` python\nfrom pymc3 import Model, Normal, Gamma, Lognormal, Exponential, NUTS, sample, find_MAP, traceplot\n\nfrom load_table import walltime, numsims, numconstraints, numtargets\n\n\ndef LogNormalInvGamma(mu, alpha, beta, n, name):\n    tau = Gamma('tau_' + name, alpha=alpha, beta=beta)\n    mu = Normal('mu_' + name, mu=mu, tau=(n * tau))\n    return Lognormal(name, mu=mu, tau=tau)\n\n\nmodel = Model()\n\nwith model:\n\n    # Equation (3) in the doc string.  But remember, comments go stale!\n    C_1 = LogNormalInvGamma(mu=0, alpha=1, beta=1,\n                            n=Exponential('C_1_DOF', 1),\n                            name='constraints')\n\n    # Equation (4)\n    C_2 = LogNormalInvGamma(mu=0, alpha=1, beta=1,\n                            n=Exponential('C_2_DOF', 1),\n                            name='targets')\n\n    # Now we model C_0 as the Lognormal which varies around the rest of\n    # Equation (1) / Equation (5)\n    C_0_mu = (C_1 * numconstraints) + (C_2 * numsims * numtargets)\n    walltime_model = Lognormal('walltime',\n                               mu=C_0_mu,\n                               tau=Gamma('tau_const', 1, 1),  # 𝞽₀ in Equ (2)\n                               observed=walltime)\n\n    # The section below is run in a separate module, which imports the model constructed above.\n    # Probably not relevant, but I don't really know why it's taking so long.\n\n    # Rough computation of MAP for the model.\n    map_estimate = find_MAP(model=model.model, fmin=optimize.fmin_powell)\n\n    # Draw 2,000 posterior samples\n    trace = sample(2000, start=map_estimate)\n```\n"},"comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments/266827423","html_url":"https://github.com/pymc-devs/pymc3/issues/1126#issuecomment-266827423","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1126","id":266827423,"user":{"login":"jsalvatier","id":270513,"avatar_url":"https://avatars.githubusercontent.com/u/270513?v=3","gravatar_id":"","url":"https://api.github.com/users/jsalvatier","html_url":"https://github.com/jsalvatier","followers_url":"https://api.github.com/users/jsalvatier/followers","following_url":"https://api.github.com/users/jsalvatier/following{/other_user}","gists_url":"https://api.github.com/users/jsalvatier/gists{/gist_id}","starred_url":"https://api.github.com/users/jsalvatier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsalvatier/subscriptions","organizations_url":"https://api.github.com/users/jsalvatier/orgs","repos_url":"https://api.github.com/users/jsalvatier/repos","events_url":"https://api.github.com/users/jsalvatier/events{/privacy}","received_events_url":"https://api.github.com/users/jsalvatier/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T18:54:03Z","updated_at":"2016-12-13T18:54:03Z","body":"I'm actually surprised that compute_energy is taking up 30% the first time its called since the energy is computed in leapfrog which is computed many times. Something unintuitive is going on there. You should post the profile for compute_energy. \r\n\r\nAlso, its possible we could save substantial compute by only ever computing differences in energies. \r\n\r\nOne way we could do that is by making the current energy function compute the energy relative to a dummy state (maybe the start state passed to NUTS at init). That seems kind of inelegant, but I think it would work. Not sure how much it would save."}}
{"actor":{"display_login":"jsalvatier"}}