Skip to content
Agentmart
Submit a tool

quark-onnx-subgraph-partitioner

Partition an ONNX model graph into named functional subgraphs and emit a subgraph_partition.json file.

Skill by amd

IndexedMIT★ 186
Write a review

Chalk Labs

Need help deploying quark-onnx-subgraph-partitioner?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/amd-quark-onnx-subgraph-partitioner-b59f39

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Partition an ONNX model graph into named functional subgraphs and emit a subgraph_partition.json file. Use when the user wants to understand a model's high-level structure, document its architectural blocks, or prepare a partition for downstream workflows (mixed-precision quantization, layer-wise profiling, partial deployment, graph visualization). Triggers on "partition my ONNX model", "generate a subgraph JSON", "which nodes belong to the attention blocks", "show me the model architecture", "split the model into blocks", "group layers for AMP", or any request that needs a named block decomposition of an ONNX graph. Handles any ONNX architecture: CNNs (ResNet, EfficientNet, YOLOv5/v8, DenseNet, MobileNet), Transformers (BERT, ViT, Swin, LLMs), multi-modal (CLIP, BLIP), detection models with FPN/PAN necks, BEV perception models (BEVFormer), and custom or unfamiliar architectures identified from node-name prefixes and op sequences.

Use cases: documents, data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Python package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/quark-onnx-subgraph-partitioner

What's inside

Skill name
quark-onnx-subgraph-partitioner
Description
Partition an ONNX model graph into named functional subgraphs and emit a subgraph_partition.json file. Use when the user wants to understand a model's high-level structure, document its architectural blocks, or prepare a partition for downstream workflows (mixed-precision quantization, layer-wise profiling, partial deployment, graph visualization). Triggers on "partition my ONNX model", "generate a subgraph JSON", "which nodes belong to the attention blocks", "show me the model architecture", "split the model into blocks", "group layers for AMP", or any request that needs a named block decomposition of an ONNX graph. Handles any ONNX architecture: CNNs (ResNet, EfficientNet, YOLOv5/v8, DenseNet, MobileNet), Transformers (BERT, ViT, Swin, LLMs), multi-modal (CLIP, BLIP), detection models with FPN/PAN necks, BEV perception models (BEVFormer), and custom or unfamiliar architectures identified from node-name prefixes and op sequences.
License
MIT
Instructions
214 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts

Files (3)

  • SKILL.md
  • inspect_model.py
  • validate_partition.py

SKILL.md (first lines)

# quark-onnx-subgraph-partitioner

## Purpose

Produce a `subgraph_partition.json` that groups ONNX graph nodes into named
functional blocks (stem, backbone stage, attention layer, FFN, FPN neck, etc.).
The partition can serve as input to AMP sensitivity analysis, layer-wise
profiling, partial deployment, or graph documentation.

Two helper scripts live alongside this file:

```bash
SKILL_DIR=skills/_legacy_impl/l1-atomic/onnx/quark-onnx-subgraph-partitioner
```

## Inputs

- Model path — a single `.onnx` file supplied as `$ARGUMENTS`
- Optional architecture hints from the user (layer count, naming convention,
  block granularity preference)

## Outputs: subgraph_partition.json

Schema: [`subgraph_partition.schema.json`](../../shared/contracts/subgraph_partition.schema.json)

```json
{
  "quantized":     false,
  "num_subgraphs": 4,
  "subgraphs": [
    {
      "name": "backbone_stem",
      "description": "Initial stride-2 Conv → SiLU activation, produces P1 features",
      "start_nodes": ["/model.0/conv/Conv"],
      "end_nodes":   ["/model.0/act/Mul"]
    },
    {
      "name": "attention_layer_0",
      "description": "Full encoder layer 0: self-attention + FFN + LayerNorm + residuals",
      "start_nodes": ["/encoder/layer.0/attention/self/query/MatMul"],
      "end_nodes":   ["/encoder/layer.0/output/LayerNorm"]
    }
  ]
}
```

Every entry requires all four fields: `name`, `description`, `start_nodes`,
`end_nodes`. **Never include `resolved_nodes`** — node resolution happens at
runtime. `num_subgraphs` must equal `len(subgraphs)`; set it last.

## Analysis Procedure

### Step 1 — Load and inspect the model

```bash
python3 "$SKILL_DIR/inspect_model.py" <MODEL_PATH>
```

For quantized models (detected automatically via Q/DQ op presence), Q/DQ
wrapper nodes are suppressed so structural landmarks remain visible; Q/DQ
counts are reported separately.

**Text `.onnxtxt`** — use `grep` instead:

```bash
grep -n 'op_type:\|  name:\|input:\|output:' <MODEL_PATH> | head -400
```

**Quantized model rules:** use compute nodes (`Conv`, `MatMul`, `Add`, …) as
boundaries — never Q/DQ nodes. BFS from a compute node captures surrounding
Q/DQ wrappers automatically.

### Step 2 — Identify structural landmarks

| Signal | Likely boundary |
|--------|-----------------|
| First `Conv` consuming the graph input | Backbone / model stem |
| Repeated `/model.N/` or `/layer.N/` prefix groups | Stage or layer repetition |
| `MaxPool` or strided `Conv` (stride 2) | Resolution downsampling |
| `Resize` (upsample) + `Concat` on lateral path | FPN / PAN top-down merge |
| `Split` → N parallel `Conv` → `Concat` + 1×1 `Conv` | C2f / CSP bottleneck |
| `GlobalAveragePool` → FC → activation → `Mul` | SE block |
| `MatMul`×3 → `Softmax` → `MatMul` (QKV pattern) | Self-attention block |
| `LayerNormalization` or `InstanceNormalization` | Transformer / diffusion layer |
| `MatMul`/`Gemm` → activation → `MatMul`/`Gemm` (hidden × 4) | FFN / MLP block |
| `Add` immediately after attention + FFN | Residual add (layer end) |
| `GridSample` with sampling offsets | Deformable attention |
| `Gather` on index 0 → `LayerNorm` → `Gemm` | CLS token / pooler / head |

### Step 3 — Assign blocks

| Block type | Description |
|------------|-------------|
| `Stem` | Initial convs before first downsampling |
| `BackboneStage` | Stage at one resolution (N residual / bottleneck blocks) |
| `SEBlock` | Squeeze-and-Excitation (GAP → FC → activation → Mul) |
| `PatchEmbedding` | ViT patch projection (Conv with patch-stride kernel) |
| `SelfAttentionBlock` | Multi-head self-attention (QKV + Softmax + out proj) |
| `FFNBlock` | Feed-forward network (Linear → activation → Linear) |
| `TransformerLayer` | Full encoder/decoder layer (attn + FFN + norms + residuals) |
| `SPPF` | Spatial Pyramid Pooling Fast |
| `FPNNeck` | Feature Pyramid Network (lateral convs + upsample + merge) |
| `PANNeck` | Path Aggregation Network (down-path convs + concat + merge) |
| `DetectionHead` | Conv layers + decode logic for bbox / class output |
| `ClassificationHead` | MLP predicting class logits |

**Granularity rules:**

- No single subgraph > ~25 % of total nodes; split if needed.
- No trivial single-activation subgraphs; minimum unit is one compute op.
- Split every repeated layer individually (12 transformer layers → 12 entries).
- Merge inseparable op chains (Conv + BN + ReLU with no branch points).
- Assign `Concat` / `Add` / `Resize` to the subgraph that *produces* the feature map.

### Step 4 — Choose start and end nodes

**`start_nodes`**: first node(s) receiving data from outside the block. Only
list a node if it is **not already reachable** from another listed start node —
downstream-reachable additions are redundant. When a block has multiple

From amd/Quark, MIT.

More from amd/Quark

Signals

Stars
186
Forks
36
Open issues
3
Last commit (this folder)
Sep 28, 2026 (1 month ago)
Last release
Sep 28, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from amd

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get quark-onnx-subgraph-partitioner running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying quark-onnx-subgraph-partitioner?

CallGet help
Cite this page

quark-onnx-subgraph-partitioner skill. Agent Mart. https://agentmart.dev/skills/amd-quark-onnx-subgraph-partitioner-b59f39 (last updated 2026-10-24)