Skip to content

Commit 5c1cce4

Browse files
Publish docs @ 89f360d
1 parent c450913 commit 5c1cce4

File tree

8 files changed

+346
-270
lines changed

8 files changed

+346
-270
lines changed

faq/index.html

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,21 @@ <h2 class="anchored" data-anchor-id="why-is-this-variable-being-treated-as-rando
781781
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>m2 <span class="op">=</span> <span class="fu">f2</span>() <span class="op">|</span> (<span class="pp">@varname</span>(x[<span class="fl">1</span>]) <span class="op">=&gt;</span> <span class="fl">1.0</span>)</span>
782782
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="fu">sample</span>(m2, <span class="fu">NUTS</span>(), <span class="fl">100</span>) <span class="co"># This doesn't work!</span></span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
783783
<p>The key insight is that <code>filldist</code> creates a single distribution (not N independent distributions), which is why you cannot condition on individual elements. The distinction is not just about what appears on the LHS of <code>~</code>, but whether you’re dealing with separate distributions (<code>.~</code> with univariate) or a single distribution over multiple values (<code>~</code> with multivariate or <code>filldist</code>).</p>
784-
<p>To understand more about how Turing determines whether a variable is treated as random or observed, see: - <a href="../core-functionality">Core Functionality</a> - basic explanation of the <code>~</code> notation and conditioning</p>
784+
<p>To understand more about how Turing determines whether a variable is treated as random or observed, see:</p>
785+
<ul>
786+
<li><a href="../core-functionality">Core Functionality</a> - basic explanation of the <code>~</code> notation and conditioning</li>
787+
</ul>
785788
</section>
786789
<section id="can-i-use-parallelism-threads-in-my-model" class="level2">
787790
<h2 class="anchored" data-anchor-id="can-i-use-parallelism-threads-in-my-model">Can I use parallelism / threads in my model?</h2>
788791
<p>Yes, but with important caveats! There are two types of parallelism to consider:</p>
789792
<section id="parallel-sampling-multiple-chains" class="level3">
790793
<h3 class="anchored" data-anchor-id="parallel-sampling-multiple-chains">1. Parallel Sampling (Multiple Chains)</h3>
791-
<p>Turing.jl fully supports sampling multiple chains in parallel: - <strong>Multithreaded sampling</strong>: Use <code>MCMCThreads()</code> to run one chain per thread - <strong>Distributed sampling</strong>: Use <code>MCMCDistributed()</code> for distributed computing</p>
794+
<p>Turing.jl fully supports sampling multiple chains in parallel:</p>
795+
<ul>
796+
<li><strong>Multithreaded sampling</strong>: Use <code>MCMCThreads()</code> to run one chain per thread</li>
797+
<li><strong>Distributed sampling</strong>: Use <code>MCMCDistributed()</code> for distributed computing</li>
798+
</ul>
792799
<p>See the <a href="../core-functionality/#sampling-multiple-chains">Core Functionality guide</a> for examples.</p>
793800
</section>
794801
<section id="threading-within-models" class="level3">
@@ -801,17 +808,30 @@ <h3 class="anchored" data-anchor-id="threading-within-models">2. Threading Withi
801808
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> y[i] <span class="op">~</span> <span class="fu">Normal</span>(x[i]) <span class="co"># `observe` statements are okay</span></span>
802809
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">end</span></span>
803810
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="kw">end</span></span></code></pre></div><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></div>
804-
<p><strong>Important limitations:</strong> - <strong>Observe statements</strong>: Generally safe to use in threaded loops - <strong>Assume statements</strong> (sampling statements): Often crash unpredictably or produce incorrect results - <strong>AD backend compatibility</strong>: Many AD backends don’t support threading. Check the <a href="https://turinglang.org/ADTests/">multithreaded column in ADTests</a> for compatibility</p>
811+
<p><strong>Important limitations:</strong></p>
812+
<ul>
813+
<li><strong>Observe statements</strong>: Generally safe to use in threaded loops</li>
814+
<li><strong>Assume statements</strong> (sampling statements): Often crash unpredictably or produce incorrect results</li>
815+
<li><strong>AD backend compatibility</strong>: Many AD backends don’t support threading. Check the <a href="https://turinglang.org/ADTests/">multithreaded column in ADTests</a> for compatibility</li>
816+
</ul>
805817
<p>For safe parallelism within models, consider vectorized operations instead of explicit threading.</p>
806818
</section>
807819
</section>
808820
<section id="how-do-i-check-the-type-stability-of-my-turing-model" class="level2">
809821
<h2 class="anchored" data-anchor-id="how-do-i-check-the-type-stability-of-my-turing-model">How do I check the type stability of my Turing model?</h2>
810-
<p>Type stability is crucial for performance. Check out: - <a href="../usage/performance-tips">Performance Tips</a> - includes specific advice on type stability - Use <code>DynamicPPL.DebugUtils.model_warntype</code> to check type stability of your model</p>
822+
<p>Type stability is crucial for performance. Check out:</p>
823+
<ul>
824+
<li><a href="../usage/performance-tips">Performance Tips</a> - includes specific advice on type stability</li>
825+
<li>Use <code>DynamicPPL.DebugUtils.model_warntype</code> to check type stability of your model</li>
826+
</ul>
811827
</section>
812828
<section id="how-do-i-debug-my-turing-model" class="level2">
813829
<h2 class="anchored" data-anchor-id="how-do-i-debug-my-turing-model">How do I debug my Turing model?</h2>
814-
<p>For debugging both statistical and syntactical issues: - <a href="../usage/troubleshooting">Troubleshooting Guide</a> - common errors and their solutions - For more advanced debugging, DynamicPPL provides <a href="https://turinglang.org/DynamicPPL.jl/stable/api/#Debugging-Utilities">the <code>DynamicPPL.DebugUtils</code> module</a> for inspecting model internals</p>
830+
<p>For debugging both statistical and syntactical issues:</p>
831+
<ul>
832+
<li><a href="../usage/troubleshooting">Troubleshooting Guide</a> - common errors and their solutions</li>
833+
<li>For more advanced debugging, DynamicPPL provides <a href="https://turinglang.org/DynamicPPL.jl/stable/api/#Debugging-Utilities">the <code>DynamicPPL.DebugUtils</code> module</a> for inspecting model internals</li>
834+
</ul>
815835
</section>
816836
<section id="what-are-the-main-differences-between-turing-bugs-and-stan-syntax" class="level2">
817837
<h2 class="anchored" data-anchor-id="what-are-the-main-differences-between-turing-bugs-and-stan-syntax">What are the main differences between Turing, BUGS, and Stan syntax?</h2>
@@ -845,11 +865,22 @@ <h2 class="anchored" data-anchor-id="what-are-the-main-differences-between-turin
845865
</section>
846866
<section id="which-automatic-differentiation-backend-should-i-use" class="level2">
847867
<h2 class="anchored" data-anchor-id="which-automatic-differentiation-backend-should-i-use">Which automatic differentiation backend should I use?</h2>
848-
<p>The choice of AD backend can significantly impact performance. See: - <a href="../usage/automatic-differentiation">Automatic Differentiation Guide</a> - comprehensive comparison of ForwardDiff, Mooncake, ReverseDiff, and other backends - <a href="../usage/performance-tips#choose-your-ad-backend">Performance Tips</a> - quick guide on choosing backends - <a href="https://turinglang.org/ADTests/">AD Backend Benchmarks</a> - performance comparisons across various models</p>
868+
<p>The choice of AD backend can significantly impact performance. See:</p>
869+
<ul>
870+
<li><a href="../usage/automatic-differentiation">Automatic Differentiation Guide</a> - comprehensive comparison of ForwardDiff, Mooncake, ReverseDiff, and other backends</li>
871+
<li><a href="../usage/performance-tips#choose-your-ad-backend">Performance Tips</a> - quick guide on choosing backends</li>
872+
<li><a href="https://turinglang.org/ADTests/">AD Backend Benchmarks</a> - performance comparisons across various models</li>
873+
</ul>
849874
</section>
850875
<section id="i-changed-one-line-of-my-model-and-now-its-so-much-slower-why" class="level2">
851876
<h2 class="anchored" data-anchor-id="i-changed-one-line-of-my-model-and-now-its-so-much-slower-why">I changed one line of my model and now it’s so much slower; why?</h2>
852-
<p>Small changes can have big performance impacts. Common culprits include: - Type instability introduced by the change - Switching from vectorized to scalar operations (or vice versa) - Inadvertently causing AD backend incompatibilities - Breaking assumptions that allowed compiler optimizations</p>
877+
<p>Small changes can have big performance impacts. Common culprits include:</p>
878+
<ul>
879+
<li>Type instability introduced by the change</li>
880+
<li>Switching from vectorized to scalar operations (or vice versa)</li>
881+
<li>Inadvertently causing AD backend incompatibilities</li>
882+
<li>Breaking assumptions that allowed compiler optimizations</li>
883+
</ul>
853884
<p>See our <a href="../usage/performance-tips">Performance Tips</a> and <a href="../usage/troubleshooting">Troubleshooting Guide</a> for debugging performance regressions.</p>
854885

855886

0 commit comments

Comments
 (0)