modeling-basics
Author and debug basic Pyro models, primitives, parameter state, validation, seeds, plates, and PyroModule parameters.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- modeling-basics
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Author and debug basic Pyro models, primitives, parameter state, validation, seeds, plates, and PyroModule parameters.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/modeling-primitives.md10.5 KB
- 参考文档references/modules-and-parameters.md12.9 KB
- 参考文档references/troubleshooting.md10.4 KB
03 SKILL.md 正文
Modeling Basics for Pyro
Use this sub-skill when a task asks you to author or debug a basic Pyro program:
stochastic functions, pyro.sample, pyro.param, observed data, pyro.plate,
subsampling, parameter-store lifecycle, validation settings, RNG seeding,
PyroModule, PyroParam, PyroSample, or pyro.render_model prerequisites.
This guidance targets the pyro-ppl 1.9.1 package family imported as pyro.
It is self-contained for runtime use.
Route first
- For primitive usage, model/guide skeletons, observations,
obs_mask, plates, validation, seeds, site names, and rendering prerequisites, read references/modeling-primitives.md. - For
pyro.param,ParamStoreDict, constraints, save/load state,pyro.module,PyroModule,PyroParam,PyroSample, andmodule_local_params, read references/modules-and-parameters.md. - For warnings and failures such as duplicate sample names, observation warnings, parameter leakage, plate shape mismatches, missing Graphviz, or confusing validation toggles, read references/troubleshooting.md.
Reroute boundaries
- Deep distribution choice, event/batch/sample shape algebra, transforms, and
support constraints:
../distributions-and-shapes/SKILL.md. - SVI training loops, ELBO choice, autoguides, and optimizer recipes:
../svi-and-autoguides/SKILL.md. - HMC/NUTS/MCMC, posterior predictive, and prediction APIs:
../mcmc-and-prediction/SKILL.md. - Poutine handler composition, trace/replay/condition/block, enumeration,
reparameterizers, and
max_plate_nesting:../effect-handlers-and-enumeration/SKILL.md.
Basic operating rules
- Start repeated experiments, unit tests, and independent training runs with
pyro.clear_param_store()unless you intentionally want to reuse existing parameters. - Keep validation on while developing:
pyro.enable_validation(True). Usewith pyro.validation_enabled(False): ...only around mature hot paths. - Seed reproducible snippets with
pyro.set_rng_seed(seed)before generating synthetic data or initializing parameters. - Give every sample site a unique name within a single execution trace. Model and guide latent sites should share names; observed model sites usually have no guide site.
- Use
pyro.plateonly for conditionally independent batch dimensions. If the error is mainly aboutbatch_shape,event_shape,.to_event(), orlog_probshape, reroute to the shapes sub-skill. - Prefer
PyroModule/PyroParam/PyroSamplefor module-style models. Use oldpyro.module(name, nn_module, update_module_params=False)mainly for registering an ordinarytorch.nn.Modulewith the global parameter store.
Entry points to recognize
pyro.sample(name, fn, *args, obs=None, obs_mask=None, infer=None, **kwargs)pyro.param(name, init_tensor=None, constraint=constraints.real, event_dim=None)pyro.plate(name, size=None, subsample_size=None, subsample=None, dim=None, use_cuda=None, device=None)pyro.module(name, nn_module, update_module_params=False)PyroModule(name=""),PyroParam(init_value=None, constraint=constraints.real, event_dim=None),PyroSample(prior)pyro.settings.get(),pyro.settings.set(...),pyro.settings.context(...)pyro.enable_validation(...),pyro.validation_enabled(...),pyro.set_rng_seed(...)
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).