-
Notifications
You must be signed in to change notification settings - Fork 103
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR adds a new FAQ section to the Turing.jl website and updates the navigation menu to include a link to it.
- Added a “FAQ” entry in the site navigation
- Created
faq/index.qmd
with a set of common Q&A on using Turing.jl
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
_quarto.yml | Inserted a navigation entry for the FAQ |
faq/index.qmd | Added FAQ page with detailed user guidance |
Comments suppressed due to low confidence (1)
_quarto.yml:27
- Indentation of the new navigation entry does not match the surrounding items and could break the YAML. Align the
- href: faq/
and itstext:
line with the other menu entries.
- href: faq/
Preview the changes: https://turinglang.org/docs/pr-previews/608 |
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.
This is a nice start, I think there are a few places where it's necessary to go into more detail, which I've commented on.
General comment for the entire PR: for the URLs, you can use the meta variables defined in _quarto.yml
, i.e. [text]({{< meta usage-automatic-differentiation >}})
to avoid hardcoding relative paths (useful if you want to move pages around, which has happened a couple of times).
Co-authored-by: Penelope Yong <penelopeysm@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Penelope Yong <penelopeysm@gmail.com>
…ing.jl models and parallelism usage
I think I've addressed the comments @penelopeysm |
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.
Looking good! Thanks for expanding on the points here. A few more comments, which hopefully aren't too complicated to deal with.
@model function f(x) | ||
Threads.@threads for i in eachindex(x) | ||
x[i] ~ Normal() # UNSAFE: Assume statements in threads can crash! | ||
end | ||
end |
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.
In this model, x
is observed so it's fine. 'assume' means that it's a random parameter, so for example something like this:
@model function f(x) | |
Threads.@threads for i in eachindex(x) | |
x[i] ~ Normal() # UNSAFE: Assume statements in threads can crash! | |
end | |
end | |
@model function f(y) | |
x = Vector{Float64}(undef, length(y)) | |
Threads.@threads for i in eachindex(y) | |
x[i] ~ Normal() # UNSAFE: `assume` statements in @threads can crash! | |
y[i] ~ Normal(x[i]) # `observe` statements are okay | |
end | |
end |
- **Multithreaded sampling**: Use `MCMCThreads()` to run one chain per thread | ||
- **Distributed sampling**: Use `MCMCDistributed()` for distributed computing | ||
|
||
See the [Core Functionality guide](../core-functionality/#sampling-multiple-chains) for examples. |
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.
See the [Core Functionality guide](../core-functionality/#sampling-multiple-chains) for examples. | |
See the [Core Functionality guide]({{< meta core-functionality >}}/#sampling-multiple-chains) for examples. |
The key insight is that `filldist` 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 `~`, but whether you're dealing with separate distributions (`.~` with univariate) or a single distribution over multiple values (`~` with multivariate or `filldist`). | ||
|
||
To understand more about how Turing determines whether a variable is treated as random or observed, see: | ||
- [Core Functionality](../core-functionality/) - basic explanation of the `~` notation and conditioning |
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.
- [Core Functionality](../core-functionality/) - basic explanation of the `~` notation and conditioning | |
- [Core Functionality]({{< meta core-functionality >}}) - basic explanation of the `~` notation and conditioning |
|
||
For debugging both statistical and syntactical issues: | ||
- [Troubleshooting Guide]({{< meta usage-troubleshooting >}}) - common errors and their solutions | ||
- For more advanced debugging, DynamicPPL provides `DynamicPPL.DebugUtils` for inspecting model internals |
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.
- For more advanced debugging, DynamicPPL provides `DynamicPPL.DebugUtils` for inspecting model internals | |
- For more advanced debugging, DynamicPPL provides [the `DynamicPPL.DebugUtils` module](https://turinglang.org/DynamicPPL.jl/stable/api/#Debugging-Utilities) for inspecting model internals |
Friendly link
|
||
Key syntactic differences include: | ||
|
||
- **Parameter blocks**: Stan requires explicit `data`, `parameters`, `transformed parameters`, and `model` blocks. In Turing, everything is defined within the `@model` macro |
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.
- **Parameter blocks**: Stan requires explicit `data`, `parameters`, `transformed parameters`, and `model` blocks. In Turing, everything is defined within the `@model` macro | |
- **Parameter blocks**: Stan requires explicit `data`, `parameters`, and `model` blocks. In Turing, everything is defined within the `@model` macro |
transformed parameters
isn't mandatory
# Turing | ||
@model function my_model(y) | ||
mu ~ Normal(0, 1) | ||
sigma ~ truncated(Normal(0, 1), 0, Inf) |
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.
sigma ~ truncated(Normal(0, 1), 0, Inf) | |
sigma ~ truncated(Normal(0, 1); lower=0) |
truncated(d, 0, Inf)
causes issues with AD (https://turinglang.org/docs/usage/troubleshooting/#nan-gradient has an illustration of this).
parameters { | ||
real mu; | ||
real<lower=0> sigma; | ||
} | ||
model { | ||
y ~ normal(mu, sigma); | ||
} | ||
``` |
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.
So I'm not a super duper expert on Stan, but I think that these parameters don't have priors assigned and thus have completely flat priors (i.e. the prior probability is always 1 for any value of mu and any value of sigma > 0). That would make this not equivalent to the Turing model which has non-flat priors. I think you would need to specify mu ~ normal(0, 1);
and sigma ~ normal(0, 1);
if you want to include a prior probability that is equivalent to the Turing model below it.
This pull request adds a new FAQ section to the Turing.jl website and updates the navigation menu to include a link to the FAQ page. The FAQ section provides answers to common questions about using Turing.jl, covering topics such as random variables, implementing samplers, parallelism, debugging, syntax differences, automatic differentiation backends, and performance issues.
Website Navigation Update:
_quarto.yml
: Added a new link to the FAQ page in the website's navigation menu.FAQ Section Addition:
faq/index.qmd
: Created a new FAQ page with detailed answers to common questions about Turing.jl. Topics include variable treatment, sampler implementation, parallelism, type stability, debugging, syntax differences, automatic differentiation backends, and performance debugging.Relevant Issues: