-
Notifications
You must be signed in to change notification settings - Fork 104
Add FAQ section to improve user guidance #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AoifeHughes
wants to merge
1
commit into
main
Choose a base branch
from
faq
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
title: "Frequently Asked Questions" | ||
description: "Common questions and answers about using Turing.jl" | ||
--- | ||
|
||
## Why is this variable being treated as random instead of observed? | ||
|
||
This is a common source of confusion. In Turing.jl, you can only manipulate expressions that explicitly appear on the left-hand side (LHS) of a `~` statement. | ||
|
||
For example, if your model contains: | ||
```julia | ||
x ~ filldist(Normal(), 2) | ||
``` | ||
|
||
You cannot directly condition on `x[2]` using `condition(model, @varname(x[2]) => 1.0)` because `x[2]` never appears on the LHS of a `~` statement. Only `x` as a whole appears there. | ||
|
||
To understand more about how Turing determines whether a variable is treated as random or observed, see: | ||
- [Compiler Design Overview](../developers/compiler/design-overview/) - explains the heuristics Turing uses | ||
- [DynamicPPL Transformations](../developers/transforms/dynamicppl/) - details about variable transformations and the `@varname` macro | ||
- [Core Functionality](../core-functionality/) - basic explanation of the `~` notation and conditioning | ||
|
||
## How do I implement a sampler for a Turing.jl model? | ||
|
||
We have comprehensive guides on implementing custom samplers: | ||
- [Implementing Samplers Tutorial](../developers/inference/implementing-samplers/) - step-by-step guide on implementing samplers in the AbstractMCMC framework | ||
- [AbstractMCMC-Turing Interface](../developers/inference/abstractmcmc-turing/) - how to integrate your sampler with Turing | ||
- [AbstractMCMC Interface](../developers/inference/abstractmcmc-interface/) - the underlying interface documentation | ||
|
||
## Can I use parallelism / threads in my model? | ||
|
||
Yes! Turing.jl supports both multithreaded and distributed sampling. See the [Core Functionality guide](../core-functionality/#sampling-multiple-chains) for detailed examples showing: | ||
- Multithreaded sampling using `MCMCThreads()` | ||
- Distributed sampling using `MCMCDistributed()` | ||
|
||
## How do I check the type stability of my Turing model? | ||
|
||
Type stability is crucial for performance. Check out: | ||
- [Performance Tips](../usage/performance-tips/) - includes specific advice on type stability | ||
- [Automatic Differentiation](../usage/automatic-differentiation/) - contains benchmarking utilities using `DynamicPPL.TestUtils.AD` | ||
|
||
## How do I debug my Turing model? | ||
|
||
For debugging both statistical and syntactical issues: | ||
- [Troubleshooting Guide](../usage/troubleshooting/) - common errors and their solutions | ||
- For more advanced debugging, DynamicPPL provides `DynamicPPL.DebugUtils` for inspecting model internals | ||
|
||
## What are the main differences between Turing vs BUGS vs Stan syntax? | ||
|
||
While there are many syntactic differences, key advantages of Turing include: | ||
- **Julia ecosystem**: Full access to Julia's profiling and debugging tools | ||
- **Parallel computing**: Much easier to use distributed and parallel computing inside models | ||
- **Flexibility**: Can use arbitrary Julia code within models | ||
- **Extensibility**: Easy to implement custom distributions and samplers | ||
|
||
## Which automatic differentiation backend should I use? | ||
|
||
The choice of AD backend can significantly impact performance. See: | ||
- [Automatic Differentiation Guide](../usage/automatic-differentiation/) - comprehensive comparison of ForwardDiff, Mooncake, ReverseDiff, and other backends | ||
- [Performance Tips](../usage/performance-tips/#choose-your-ad-backend) - quick guide on choosing backends | ||
- [AD Backend Benchmarks](https://turinglang.org/ADTests/) - performance comparisons across various models | ||
|
||
For more specific recommendations, check out the [DifferentiationInterface.jl tutorial](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterfaceTest/stable/tutorial/). | ||
|
||
## I changed one line of my model and now it's so much slower; why? | ||
|
||
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 | ||
|
||
See our [Performance Tips](../usage/performance-tips/) and [Troubleshooting Guide](../usage/troubleshooting/) for debugging performance regressions. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The phrasing “differences between Turing vs BUGS vs Stan” is awkward. Consider rewording to “differences between Turing, BUGS, and Stan syntax.”
Copilot uses AI. Check for mistakes.