distributions-and-shapes
Choose Pyro distributions and debug batch, event, plate, support, and transform shapes.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- distributions-and-shapes
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Choose Pyro distributions and debug batch, event, plate, support, and transform shapes.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/distribution-catalog.md13.8 KB
- 参考文档references/shapes-and-plates.md11.9 KB
- 参考文档references/troubleshooting.md17.6 KB
03 SKILL.md 正文
Distributions And Shapes
Use this sub-skill when the user needs to choose a pyro.distributions
distribution, reason about sample_shape, batch_shape, event_shape, or
pyro.plate dimensions, add constraints/transforms, or debug log_prob, support,
validation, NaN/Inf, HMM, stable, zero-inflated, mixture, matching, or CUDA shape
issues.
Route First
- For distribution selection, Pyro-specific distribution families, constructor signatures, constraints/transforms, LKJ, HMM, matching, stable, mixture, and optional SciPy caveats, read references/distribution-catalog.md.
- For shape algebra,
platedimension placement,.to_event()/Independent, observation shape checks, trace shape diagnostics, and HMM/zero-inflated shape recipes, read references/shapes-and-plates.md. - For concrete recovery steps after errors such as invalid support, argument
constraint violations, invalid
log_probshape, NaNs/Infs, CUDA device mismatches, SciPy-dependent helper failures, and HMM duration/broadcast mistakes, read references/troubleshooting.md.
Best-Fit Tasks
Use this sub-skill for requests like:
- "which Pyro distribution should I use for zero-inflated counts, correlations, an HMM, a stable process, a matching, or a mixture?";
- "why does
log_prob()have the wrong shape underplate?"; - "should this tensor dimension be a batch dim, event dim, or plate dim?";
- "fix
ValueError: invalid log_prob shape,expected value argument...,components event_shape disagree, or an HMMdurationmismatch"; - "use
constraints,transform_to,biject_to, orTransformedDistributionsafely"; - "make the same distribution code work on CPU and optional CUDA".
Boundaries And Reroutes
- Basic
pyro.sample,pyro.param,pyro.plateintroductions, parameter-store lifecycle,PyroModule, and observation basics: route to../modeling-basics/. - SVI, ELBO choice, autoguides, optimizers, and training-loop decisions: route to
../svi-and-autoguides/after this sub-skill has resolved distribution and shape contracts. - MCMC/NUTS/HMC, initialization strategies, posterior prediction, and predictive
sample shapes: route to
../mcmc-and-prediction/after this sub-skill has resolved support and transform constraints. - Poutine handler composition, enumeration,
config_enumerate,infer_discrete,TraceEnum_ELBO, and enum dimension allocation: route to../effect-handlers-and-enumeration/. - Domain-specific contributed workflows and optional integrations such as funsor,
Horovod, Lightning, Graphviz, torchvision, pandas, scanpy, or zuko: route to
../contrib-and-domain-workflows/and treat them as optional unless the active environment proves support.
High-Value Checks Before Answering
- Start with the support and event type: real scalar, positive scalar, simplex, vector, matrix/correlation, integer count, category, sequence/HMM, matching, or transformed variable.
- Inspect
d.batch_shape,d.event_shape,d.shape(sample_shape), andd.log_prob(value).shapebefore proposing aplateor.to_event()fix. - Keep Pyro validation enabled while debugging; pass
validate_args=Truefor a single suspect distribution if global validation is uncertain. - Every non-event batch dimension in a Pyro sample site must be declared by an
enclosing
pyro.plateor deliberately reinterpreted with.to_event(). - For observed data, require
obsto broadcast tofn.batch_shape + fn.event_shape;obs_maskbroadcasts only tofn.batch_shape. - Treat CUDA, SciPy-backed helpers, and flow/domain extras as optional; do not claim they are available merely because CPU Pyro imports.
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).