jax-interop-and-advanced
Use this dm-haiku sub-skill for Haiku-aware JAX transform wrappers, nested transform lifting, data-structure utilities, mixed precision, summaries, visualization, config, and testing helpers.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- jax-interop-and-advanced
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use this dm-haiku sub-skill for Haiku-aware JAX transform wrappers, nested transform lifting, data-structure utilities, mixed precision, summaries, visualization, config, and testing helpers.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/jax-transform-wrappers.md11.8 KB
- 参考文档references/troubleshooting.md10.2 KB
- 参考文档references/utilities-reference.md10.0 KB
- 脚本scripts/haiku_jax_transform_smoke.py4.1 KB
03 SKILL.md 正文
JAX interop and advanced Haiku utilities
Use this sub-skill when the task involves Haiku-specific wrappers around JAX transforms or advanced support utilities rather than ordinary layer selection or basic hk.transform signatures.
Read this when
- A Haiku function uses
hk.get_parameter,hk.get_state,hk.set_state, orhk.next_rng_keyinsidevmap,scan,grad,remat, control flow, or shape evaluation. - You need to rewrite raw
jax.vmap,jax.lax.scan,jax.remat, or JAX control flow used inside a transformed Haiku function. - You need
hk.lift,hk.lift_with_state,hk.transparent_lift, orhk.layer_stackfor nested transforms, ensembles, or repeated per-layer blocks. - You need to filter, partition, merge, traverse, count, or convert Haiku parameter/state dictionaries for freezing or optimizer grouping.
- You need Haiku mixed precision, DOT graphs, summaries,
jaxpr_info, configuration flags, orhk.testing.transform_and_run.
Route elsewhere
- For choosing between
hk.transform,hk.transform_with_state,hk.without_apply_rng, stateful apply signatures, or multi-transform basics, use thecore-transformssub-skill. - For ordinary
hk.Moduleauthoring, parameter/state/RNG direct APIs, naming, and interceptors, use theparams-state-rngsub-skill. - For common layer catalogs,
hk.nets, RNNs, attention, convolution, normalization, and example-derived model-building patterns, use themodules-and-networkssub-skill. - For
haiku.experimental.flaxAPIs and variable collection mapping between Haiku and Flax, use theflax-interopsub-skill.
Bundled references and script
- Read references/jax-transform-wrappers.md when replacing raw JAX transforms/control flow, choosing
hk.vmap/hk.scan/hk.remat, usinghk.lift*, or applyinghk.layer_stack. - Read references/utilities-reference.md when manipulating Haiku parameter/state structures, using mixed precision, producing summaries/graphs, tuning config flags, or writing small Haiku tests.
- Read references/troubleshooting.md when you see tracer leaks, state/RNG leakage, lift name collisions, optional visualization/JAX2TF dependency failures, mixed precision contamination, or partition/merge mistakes.
- Run scripts/haiku_jax_transform_smoke.py to validate that the current environment can execute safe
hk.vmap,hk.scan, andhk.data_structures.partition/mergeexamples on synthetic arrays without Graphviz, TensorFlow, or datasets.
Operating rules
- Prefer raw
jax.*transforms outside Haiku after a function has been transformed into pureinit/applyfunctions. - Inside a transformed Haiku function, use the Haiku wrapper (
hk.vmap,hk.scan,hk.remat,hk.cond, and friends) whenever the mapped/scanned/rematted/branched function touches Haiku params, state, RNG, or modules. - Keep parameter and state structure stable across JAX control-flow branches and loop iterations. If a branch or loop might not run during init, create needed modules unconditionally under
hk.running_init(). - Treat advanced helpers as scoped tools: clear or context-manage mixed precision policies, keep Graphviz/TensorFlow rendering optional, and run synthetic smoke checks before relying on advanced wrappers in larger experiments.
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).