mcmc-and-prediction
Run Pyro HMC/NUTS/MCMC diagnostics and prior/posterior predictive sampling workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- mcmc-and-prediction
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Run Pyro HMC/NUTS/MCMC diagnostics and prior/posterior predictive sampling workflows.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/mcmc-workflows.md11.9 KB
- 参考文档references/prediction-workflows.md7.9 KB
- 参考文档references/troubleshooting.md8.4 KB
- 脚本scripts/eight_schools_mcmc_smoke.py4.9 KB
03 SKILL.md 正文
MCMC And Prediction
Use this sub-skill when the user is running, tuning, or debugging Pyro
Hamiltonian Monte Carlo workflows (NUTS, HMC, MCMC.run(),
get_samples(), summary(), diagnostics()) or drawing prior/posterior
predictive samples with Predictive, WeighedPredictive, or MHResampler.
Route First
- For NUTS/HMC setup, warmup/sample/chain choices, constrained-site initialization, transforms, diagnostics, and the eight-schools pattern, read references/mcmc-workflows.md.
- For prior predictive, posterior predictive from MCMC samples, deterministic and observed return sites, sample shapes, guide-based predictive, weighted predictive, and resampling, read references/prediction-workflows.md.
- For divergences, invalid initial parameters/support, max tree depth, multiprocessing chains, memory, discrete latent variables, progress bars, JIT, and predictive shape surprises, read references/troubleshooting.md.
- To confirm that a small self-contained CPU NUTS workflow runs in the active
package environment, run
scripts/eight_schools_mcmc_smoke.py.
Start with
python scripts/eight_schools_mcmc_smoke.py --help; use--disable-progbarin non-interactive logs.
Best-Fit Tasks
Use this sub-skill for requests like:
- "run NUTS/HMC on this Pyro model";
- "choose
num_samples,warmup_steps,num_chains, ortarget_accept_prob"; - "initialize a positive/simplex/bounded latent site for MCMC";
- "read
mcmc.summary()ormcmc.diagnostics()and fix divergences"; - "draw posterior predictive samples for observations or deterministic sites";
- "use
Predictivewith MCMC samples, an SVI guide, weighted samples, orMHResampler".
Boundaries And Reroutes
- Model primitives,
pyro.sample,pyro.param,pyro.plate, observations,pyro.deterministic, seeds, and parameter-store basics: route to../modeling-basics/. - Distribution choice, support constraints,
.to_event(), and detailed batch/event/plate shape algebra: route to../distributions-and-shapes/. - SVI training, ELBO choice, autoguides, optimizers, and guide fitting before
guide-based predictive: route to
../svi-and-autoguides/. - Handler ordering for
condition,replay,trace,block, masking/scaling,config_enumerate,infer_discrete, and enumeration dimension allocation: route to../effect-handlers-and-enumeration/. - Long domain examples such as epidemiological HMC, neural transport HMC, or optional contrib integrations should be treated as reference patterns, not as required runtime scripts. Optional CUDA, funsor, Horovod, Lightning, Graphviz, torchvision, pandas, and scanpy support is unverified in the minimum runtime.
High-Value Checks Before Answering
- Confirm the model has continuous latent state for HMC/NUTS; discrete latent sites must be observed, enumerated/marginalized correctly, or rerouted.
- Keep validation on while debugging: use
MCMC(..., disable_validation=False)and fix support/shape errors before tuning sampler parameters. - Use constrained values with
init_strategy=init_to_value(...); use unconstrained tensors only when explicitly passinginitial_params. - Inspect
mcmc.diagnostics()fordivergences,acceptance rate,n_eff, andr_hat; do not judge convergence from a tiny smoke run. - For prediction, decide whether each site should be conditioned from
posterior_samples, sampled anew, or explicitly returned viareturn_sites. - For
parallel=Truepredictive or multi-chain MCMC, ensure model functions are plate-annotated and multiprocessing-safe before blaming Pyro internals.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).