pyro
Use Pyro probabilistic programming APIs for models, distributions, SVI, MCMC, poutine, enumeration, and contrib workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- pyro
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Pyro probabilistic programming APIs for models, distributions, SVI, MCMC, poutine, enumeration, and contrib workflows.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-cheatsheet.md5.5 KB
- 参考文档references/repo-provenance.md2.8 KB
- 参考文档references/repo-routing-metadata.json329 B
- 参考文档references/troubleshooting.md6.3 KB
- 脚本scripts/check_pyro_environment.py5.6 KB
03 SKILL.md 正文
Pyro Repo Skill
Use this repo skill when the task involves the pyro-ppl package imported as
pyro: probabilistic models, distributions, stochastic variational inference,
HMC/NUTS/MCMC, posterior prediction, poutine effect handlers, discrete
enumeration, reparameterizers, PyroModule, or Pyro contributed modules.
This skill targets the Pyro 1.9.1 API family. It is self-contained for package use; do not depend on a source checkout, original examples, original tests, or notebooks at runtime.
Install and Import Check
Pyro's distribution name is pyro-ppl and the import name is pyro:
python -m pip install pyro-ppl
python - <<'PY'
import pyro, torch
print(pyro.__version__)
print(torch.__version__, torch.cuda.is_available())
PY
For a safe diagnostic that also reports optional integrations, run
scripts/check_pyro_environment.py. Start
with python scripts/check_pyro_environment.py --help; use --smoke to run a
tiny CPU SVI check.
Route by Task
- Basic stochastic functions,
pyro.sample,pyro.param, observed sites,pyro.plate, parameter-store state, validation, RNG seeds,PyroModule,PyroParam, andPyroSample: read sub-skills/modeling-basics/SKILL.md. - Distribution selection, constraints/transforms,
.to_event(),Independent, HMM/zero-inflated/stable/matching distributions, and event/batch/plate shape debugging: read sub-skills/distributions-and-shapes/SKILL.md. - SVI training loops, ELBO choice, autoguides, Pyro optimizers, vanilla PyTorch optimizer loops, minibatching, JIT/vectorized particles, and SVI troubleshooting: read sub-skills/svi-and-autoguides/SKILL.md.
- HMC/NUTS/MCMC runs, initialization, warmup/sample/chain choices, diagnostics,
Predictive,WeighedPredictive, and posterior/prior predictive shapes: read sub-skills/mcmc-and-prediction/SKILL.md. - Poutine handlers, trace/condition/replay/block/scale/mask/seed/substitute,
discrete enumeration,
TraceEnum_ELBO,infer_discrete,config_enumerate, reparameterizers, and inference-tiedpyro.ops: read sub-skills/effect-handlers-and-enumeration/SKILL.md. pyro.contrib, MiniPyro/generic backend, forecasting, GP, epidemiology, tracking, easyguide, CEVAE, Funsor, Horovod, Lightning, domain examples, and optional dependency policy: read sub-skills/contrib-and-domain-workflows/SKILL.md.
For a compact root API map and verified signature highlights, read references/api-cheatsheet.md. For install/import, backend, optional dependency, validation, and routing failures, read references/troubleshooting.md. For staleness checks against a repository checkout, read references/repo-provenance.md.
Fast Decision Rules
- If the user has an error, ask first for the Pyro version, PyTorch version, CPU/CUDA backend, and a minimal model/guide snippet unless already present.
- Turn on validation while debugging:
pyro.enable_validation(True). - Clear parameter state between independent experiments:
pyro.clear_param_store(). - For any shape or plate problem, trace the model and inspect
trace.format_shapes()before changing model structure. - Do not use HMC/NUTS directly on discrete latent variables. Enumerate, marginalize, or use another inference strategy.
- Treat CUDA, Funsor, Horovod, Lightning, Graphviz, torchvision, pandas, scanpy, and long example/tutorial dependencies as optional until the user's active environment proves support.
- Prefer tiny synthetic tensors and this skill's bundled smoke scripts before attempting long training, downloads, plotting, or GPU-specific runs.
What Not to Use This Skill For
- Generic PyTorch training that does not use Pyro primitives or distributions.
- PyMC, NumPyro, Bean Machine, Stan, or TensorFlow Probability code unless the task is explicitly translating concepts to Pyro.
- Full scientific reproduction of every Pyro tutorial/example; use this skill to implement or debug the package workflow, then request task-specific data, runtime, and budget.
- Maintainer release, benchmark, profiling, Docker, or documentation-build work unless the user explicitly asks to edit the Pyro repository.
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).