AGENT SKILL

variational-inference

Use ZhuSuan for ELBO, IWAE, inclusive KL, importance-sampling likelihoods, normalizing flows, and VAE/BNN/SVGP-style variational workflows.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
variational-inference
license
MIT
metadata
{ "disco-role": "operating" }
description
Use ZhuSuan for ELBO, IWAE, inclusive KL, importance-sampling likelihoods, normalizing flows, and VAE/BNN/SVGP-style variational workflows.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

Variational Inference

Use this sub-skill when the task is about learning latent-variable models with ELBO-style or importance-weighted objectives.

Read this when

  • the user names elbo, importance_weighted_objective, klpq, is_loglikelihood, sgvb, reinforce, vimco, RWS, IWAE, VAE, BNN, or SVGP
  • the task is about variational posteriors, multi-sample objectives, or importance-sampling based marginal likelihood estimates
  • the user wants to stack normalizing flows onto a variational distribution
  • the request is about semi-supervised VAE or sigmoid-belief-network examples

What this sub-skill owns

  • ELBO, inclusive KL, and importance-weighted objectives
  • gradient estimators: SGVB, REINFORCE, VIMCO, and importance-sampling wake-sleep
  • is_loglikelihood for marginal log-likelihood estimation
  • normalizing flows: planar and inverse autoregressive flows
  • the variational example families: VAE, BNN, semi-supervised VAE, SBN, and SVGP

What this sub-skill does not own

  • HMC, SGLD, SGHMC, SGNHT, AIS, or sampling diagnostics
  • core Bayesian-network modeling basics
  • generic TensorFlow training unrelated to probabilistic inference

Start here

  1. Read references/variational-workflows.md for the workflow map.
  2. Read references/api-reference.md for exact objective and flow signatures.
  3. Read references/troubleshooting.md for common estimator and axis mistakes.
  4. Run scripts/vi_smoke.py after environment setup to check ELBO, IWAE, importance-sampling likelihood, flows, and the GP helper path.

Common tasks

Train a VAE / BNN / SVGP

  • Build a generative MetaBayesianNet with latent variables and observations.
  • Build a variational BayesianNet that produces the latent samples and their log probabilities.
  • Use zs.variational.elbo(...) or zs.variational.importance_weighted_objective(...).
  • Optimize lower_bound.sgvb() for reparameterized latents, or lower_bound.reinforce() / lower_bound.vimco() when the latent variables are not reparameterizable.

Add normalizing flows

  • Pull the latent samples and log probabilities from q_net.query(...).
  • Pass them through planar_normalizing_flow(...) or inv_autoregressive_flow(...).
  • Feed the transformed samples and adjusted log probabilities back into the variational objective.

Estimate marginal log likelihood

  • Use zs.is_loglikelihood(...) with the same latent samples and proposal as the variational model.
  • Remember that importance-sampling estimates are only as good as the proposal; they are often used as evaluation metrics, not as the main training target.

Good entry points

  • zhusuan/variational/base.py
  • zhusuan/variational/exclusive_kl.py
  • zhusuan/variational/inclusive_kl.py
  • zhusuan/variational/monte_carlo.py
  • zhusuan/evaluation.py
  • zhusuan/transform.py
  • scripts/vi_smoke.py
  • sub-skills/variational-inference/scripts/gp_helpers.py

Routing hints

  • If the request is only about the core probabilistic graph, route to modeling-primitives.
  • If the request is about posterior sampling, route to mcmc-and-sampling.
  • If the task is about training scripts that merely use TensorFlow optimizers without a probabilistic objective, a non-ZhuSuan skill may fit better.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351