AGENT SKILL

model-summary-usage

Use torchsummary.summary and torchsummary.summary_string to inspect PyTorch nn.Module shapes, parameter counts, devices, dtypes, and memory estimates.

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

01 前言 Front Matter

name
model-summary-usage
license
MIT
metadata
{ "disco-role": "operating" }
description
Use torchsummary.summary and torchsummary.summary_string to inspect PyTorch nn.Module shapes, parameter counts, devices, dtypes, and memory estimates.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

model-summary-usage

Use this sub-skill when a task needs to call torchsummary.summary or torchsummary.summary_string for a PyTorch nn.Module without reopening the source repository.

Read this when

  • You need a Keras-style printed summary table for a PyTorch model.
  • You need programmatic total/trainable parameter counts from summary_string.
  • The model has one input, multiple inputs, or per-input dtype requirements.
  • A summary run is failing because of CPU/CUDA placement, dtype, input-size, or shape issues.
  • You need to decide whether this lightweight package is enough or whether to use torchinfo for a newer or more advanced model-inspection task.

Do not use this for

  • Editing package source, changing tests, packaging metadata, or release work; route those tasks to repo-maintenance.
  • General PyTorch debugging unrelated to this package's summary calls.
  • Precise memory profiling or complex input/output model introspection; prefer torchinfo or a PyTorch profiler workflow for those cases.

Start here

  1. Confirm the runtime has torchsummary, torch, and numpy available.

  2. Import only the public API:

    from torchsummary import summary, summary_string
    
  3. For CPU-safe usage, pass the device explicitly and move the model yourself:

    import torch
    
    device = torch.device("cpu")
    model = model.to(device)
    summary(model, input_size=(channels, height, width), device=device)
    
  4. Use the bundled smoke helper from this sub-skill directory when you need a quick verification of the installed package:

    python scripts/smoke_summary.py --help
    python scripts/smoke_summary.py --case all --device cpu
    

    From the root generated skill directory, use:

    python sub-skills/model-summary-usage/scripts/smoke_summary.py --case all --device cpu
    

References

  • API reference: exact signatures, return values, input_size, batch_size, device, dtype, hook, and memory-estimate semantics.
  • Workflows: single-input, multiple-input, dtype, device, summary_string, and output-interpretation recipes.
  • Troubleshooting: workflow-specific failures and fixes.
  • Root shared troubleshooting: package install/import and cross-cutting backend issues shared with other sub-skills.

Key facts to preserve

  • Distribution/package name: torchsummary; version evidenced for this skill: 1.5.1.
  • Public exports: summary and summary_string from torchsummary.
  • summary(...) prints the formatted table and returns the parameter-info tuple produced by summary_string(...).
  • summary_string(...) returns (summary_str, (total_params, trainable_params)).
  • input_size excludes the batch dimension. A tuple means one input; a list of tuples means multiple inputs.
  • The default device is CUDA (cuda:0), so CPU-only calls should pass device="cpu" or torch.device("cpu").

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