AGENT SKILL

framework-integrations

Use optional einops backends, Array API functions, framework layers, EinMix, and framework-specific diagnostics without overclaiming accelerator support.

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

01 前言 Front Matter

name
framework-integrations
license
MIT
metadata
{ "disco-role": "operating" }
description
Use optional einops backends, Array API functions, framework layers, EinMix, and framework-specific diagnostics without overclaiming accelerator support.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

Framework Integrations

Use this sub-skill when a task asks how einops works with tensor libraries, Array API objects, framework layers, EinMix, torch scripting/compilation, or missing optional backend diagnostics. Core shape recipes stay in tensor-operations; named einsum, pack, and unpack stay in named-einsum-and-packing.

When To Load

  • A user has a NumPy, PyTorch, TensorFlow/Keras, JAX, CuPy, Paddle, OneFlow, PyTensor, MLX, tinygrad, or Array API tensor and wants the right einops entry point.
  • A user asks whether einops supports a backend, symbolic tensors, framework layers, gradients, tracing, scripting, or torch.compile.
  • A user wants einops.layers.torch.Rearrange, einops.layers.tensorflow.Reduce, Flax modules, Paddle/OneFlow layers, or EinMix in model code.
  • A user hits Tensor type unknown to einops, missing optional framework imports, Keras serialization questions, Array API limitations, or accelerator confusion.

Boundary Rules

Stay here for framework integration. Route away for:

Operational Guidance

  1. Start from the public package install:

    pip install einops
    

    einops itself declares no runtime dependencies. Install tensor frameworks separately, in versions appropriate for the user's project.

  2. Import the framework before passing its tensors to einops. Backends are lazy and are only registered when their framework module is already imported.

    import torch
    from einops import rearrange
    
    x = torch.randn(2, 3, 4)
    y = rearrange(x, "batch channel time -> batch time channel")
    
  3. Use the regular top-level functions for most tensor objects. Use einops.array_api only when the tensor follows the Python Array API standard and exposes __array_namespace__.

  4. In model definitions, prefer framework layers when the transform should be a serializable or traceable layer:

    from einops.layers.torch import Rearrange, Reduce
    
  5. Use EinMix when a linear layer plus rearrangement/einsum weight management is the real abstraction, not merely when a simple reshape is needed.

  6. Treat accelerator support honestly. einops delegates tensor computation to the installed framework. A CPU smoke check proves pattern logic, not CUDA, ROCm, MPS, or vendor accelerator runtime.

Reference Map

Quick Diagnostics

Check a framework tensor failure:

import torch  # or tensorflow, jax.numpy, cupy, paddle, oneflow, pytensor, mlx.core
from einops import rearrange

# If this still raises "Tensor type unknown to einops", inspect the tensor type
# and whether the framework import matches the object being passed.

Run bundled checks after installing public dependencies:

python sub-skills/framework-integrations/scripts/array_api_smoke.py --help
python sub-skills/framework-integrations/scripts/array_api_smoke.py
python sub-skills/framework-integrations/scripts/layer_smoke.py --help
python sub-skills/framework-integrations/scripts/layer_smoke.py
python sub-skills/framework-integrations/scripts/layer_smoke.py --framework torch

If an optional framework is absent, the scripts report a clear skip/failure message instead of assuming the source checkout has that framework installed.

Evidence Summary

This sub-skill distills public evidence from README.md, einops/_backends.py, einops/_torch_specific.py, einops/array_api.py, einops/layers/*, einops/tests/test_array_api.py, einops/tests/test_layers.py, einops/tests/test_other.py, and the EinMix tutorial headings and examples. Installed-package inspection verified core imports and signatures; optional framework runtime verification is deliberately left to the user's installed framework environment.

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