Agent skill

Quark Torch Shrink Model

by amd in amd/Quark

Shrink a HuggingFace safetensors model to 1 hidden layer for fast debugging without loading the full model into memory.

MITAuto-check passedAI & LLM Engineering

Install Quark Torch Shrink Model

skills CLI
$ npx skills add amd/Quark --skill quark-torch-shrink-model -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install amd/Quark quark-torch-shrink-model --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/amd/Quark.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model .claude/skills/quark-torch-shrink-model && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
quark-torch-shrink-model
GitHub stars
181
Token cost
~980 tokens
SKILL.md length
292 words
Files
2
Skills in repo
37
Repo updated
First seen
Licence
MIT

At a glance

Shrink a HuggingFace safetensors model to 1 hidden layer for fast debugging without loading the full model into memory.

  • Works in 3 steps: Source path: where is the model?… → Destination path: where to save the… → Test mode?: does the user just want to…
  • Tasks that involve Model hubs and datasets
  • SKILL.md covers Purpose, Inputs, How to invoke and Supported architectures, plus 1 more section
  • Runs Python scripts from its folder; calls python and pip

What it does

Quark Torch Shrink Model is an agent skill from amd/Quark. Shrink a HuggingFace safetensors model to 1 hidden layer for fast debugging without loading the full model into memory.

Its SKILL.md is about 980 tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `shrink_model.py`).

It sits in AI & LLM Engineering, covering Model hubs and datasets. It works with Hugging Face. The licence is MIT.

When your agent uses it

  • Tasks that involve Model hubs and datasets

Example prompts

  • “/quark-torch-shrink-model”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Source path: where is the model? (required)
  2. Destination path: where to save the shrunk model? (required)
  3. Test mode?: does the user just want to validate the structure without writing tensors?

What it can do on your machine

Read from SKILL.md and the folder at commit 313cb0b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python
    • pip

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Quark Torch Shrink Model loads about 980 tokens when it runs. Until then it costs about 36 tokens; SKILL.md has 292 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~36
When it runs · the whole SKILL.md, loaded when a task matches
~980

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from amd/Quark at commit 313cb0b, republished under its MIT licence (© amd). 292 words, ~980 tokens.

Download SKILL.mdSave it as .claude/skills/quark-torch-shrink-model/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
quark-torch-shrink-model
description
Shrink a HuggingFace safetensors model to 1 hidden layer for fast debugging without loading the full model into memory.
layer
l1-atomic
primary_artifact
shrink_result.md
source_knowledge
skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model/shrink_model.py

quark-torch-shrink-model

Purpose

Produce a minimal 1-layer copy of any HuggingFace safetensors model for debugging Quark workflows. The tool reads model.safetensors.index.json to determine layer structure and rewrites only the necessary shards — the full model is never loaded into memory.

Non-layer weights (embeddings, final norm, lm_head) are always preserved so the output is a structurally valid model that can be loaded with transformers.

Inputs

  • source_model_directory — local directory containing safetensors files and config.json
  • destination_model_directory — where to write the shrunk model
  • test_mode (optional) — if the user wants only JSON files without tensor data, for structural validation

How to invoke

Understand the user's intent first

Ask (or infer from context):

  1. Source path: where is the model? (required)
  2. Destination path: where to save the shrunk model? (required)
  3. Test mode?: does the user just want to validate the structure without writing tensors?
    • "quick check", "just test", "no tensors", "only json" → use --test
    • "real model", "load and run", "actual weights" → full mode (no --test)
CLI invocation

The script lives in the skill directory and is invoked directly by path:

bash
SKILL_DIR="skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model"

# Full shrink (writes real safetensors shards)
python "$SKILL_DIR/shrink_model.py" \
    --src /path/to/source/model \
    --dst /path/to/output/tiny_model

# Test mode (JSON only, no safetensors — fast structural validation)
python "$SKILL_DIR/shrink_model.py" \
    --src /path/to/source/model \
    --dst /path/to/output/tiny_model \
    --test
Python API
python
import sys
from pathlib import Path

skill_dir = Path("skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model")
sys.path.insert(0, str(skill_dir))
from shrink_model import shrink_model

shrink_model(
    source_model_directory=Path("/path/to/source/model"),
    destination_model_directory=Path("/path/to/output/tiny_model"),
    test_mode=False,  # set True for JSON-only structural validation
)

Supported architectures

The tool auto-detects the layer naming convention from the weight keys:

PatternArchitectures
model.layers.N.LLaMA, Qwen, Mistral, Gemma, DeepSeek-V3/R1
layers.N. (no prefix)DeepSeek-V4
transformer.h.N.GPT-2, Falcon
model.blocks.N.MPT
model.transformer.layer.N.BERT-style

If the user's model uses a different pattern, add a new entry to _LAYER_INDEX_PATTERNS in skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model/shrink_model.py.

Output: shrink_result.md

After running, produce a brief report:

markdown
## Shrink Result

- **Source**: /path/to/source/model
- **Destination**: /path/to/output/tiny_model
- **Mode**: full / test
- **Layers detected**: 80 (0 ... 79)
- **Layer kept**: 0 → remapped to 0
- **Keys kept**: 12 / 723
- **config.json**: num_hidden_layers 80 → 1
- **Status**: success

If the run fails, include the error and the most likely fix:

ErrorLikely CauseFix
Could not detect any layer indices in weight_mapUnsupported key namingAdd pattern to _LAYER_INDEX_PATTERNS
Neither model.safetensors.index.json nor model.safetensors found inWrong source pathVerify --src points to the model directory
ImportError: safetensors is required: pip install safetensorssafetensors not installedpip install safetensors

© amd, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model of amd/Quark.

  • SKILL.md
  • shrink_model.py

Open the folder on GitHubat commit 313cb0b

Compare with similar skills

Quark Torch Shrink Model next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Quark Torch Shrink Model compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Quark Torch Shrink Model this skillamd/Quark181—~980Automated safety check: PassMIT
Codex Commit AgentJulian-adv/OpenMMO1.8k—~1.3kAutomated safety check: PassCustom licence
Hugging Face API Tool Builderhuggingface/skills11k2 repos~1.5kAutomated safety check: PassApache-2.0
Comfy CLIsundial-org/awesome-openclaw-skills663—~1.5kAutomated safety check: PassNone
SageMaker Serving Image Selectionhuggingface/skills11k1 repos~4.6kAutomated safety check: PassApache-2.0
Hugging Face Local Model Evalshuggingface/skills11k2 repos~1.6kAutomated safety check: PassApache-2.0

Similar skills

  • Codex Commit Agent

    Julian-adv/OpenMMO

    Run the repository commit workflow when the user explicitly asks to commit changes or create a save-point commit.

    1.8k GitHub stars~1.3k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Official

    Builds reusable command line scripts that fetch, enrich or process data from the Hugging Face API, aimed at chained, repeated or automated tasks.

    11k GitHub starsUsed in 2 repos~1.5k tokens
    AI & LLM EngineeringAuto-check passed
  • Comfy CLI

    sundial-org/awesome-openclaw-skills

    Install, manage, and run ComfyUI instances. An agent skill from sundial-org/awesome-openclaw-skills.

    663 GitHub stars~1.5k tokensUpdated 7 mo ago
    AI & LLM EngineeringAuto-check passed
  • Official

    Chooses the right serving container and current image URI for deploying a Hugging Face model to a SageMaker endpoint, preferring Hugging Face images over generic ones.

    11k GitHub starsUsed in 1 repo~4.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Official

    Runs evaluations of Hugging Face Hub models on local hardware with inspect-ai or lighteval, and helps choose between vLLM, Transformers and accelerate backends.

    11k GitHub starsUsed in 2 repos~1.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Esmfold2

    JimLiu/science-skills

    Biohub ESMFold2 / ESMFold2-Fast all-atom co-folding (Candido et al.

    227 GitHub starsUsed in 4 repos~2.5k tokens
    AI & LLM EngineeringAuto-check passed

More from amd/Quark

All 37 skills in this repo
  • Author or restructure a Quark Agent Skill so it conforms to this project's template, contracts, and layer rules.

    181 GitHub stars~3.1k tokensUpdated 11 days ago
    Auto-check passed
  • Run, resume, monitor, diagnose, and report Quark Quant-Perf workflows for PyTorch and HuggingFace transformers models.

    181 GitHub stars~3k tokensUpdated 11 days ago
    Auto-check passed
  • Author a new ShapeShifter graph-transformation pass for AMD Quark (ONNX or PyTorch) so it conforms to the pass framework's conventions and auto-registers.

    181 GitHub stars~2.9k tokensUpdated 11 days ago
    Auto-check passed
  • Collect and normalize environment facts (OS, Python, GPU, CUDA/ROCm, container state) before Quark installation or PTQ planning.

    181 GitHub stars~1.4k tokensUpdated 11 days ago
    Auto-check passed
  • Quark Install

    amd/Quark

    Install or verify the AMD Quark package and its dependencies.

    181 GitHub stars~1.8k tokensUpdated 11 days ago
    Auto-check: notes
  • L3 recipe that runs quark.onnx.AutoSearchPro end-to-end on a user .onnx model: intake → preset selection (or custom search space) → calibration / eval data reader → standalone autosearch script…

    181 GitHub stars~3.4k tokensUpdated 11 days ago
    Auto-check passed

Works with

Questions about Quark Torch Shrink Model

What does Quark Torch Shrink Model do?

Shrink a HuggingFace safetensors model to 1 hidden layer for fast debugging without loading the full model into memory. Quark Torch Shrink Model is an agent skill from amd/Quark. Shrink a HuggingFace safetensors model to 1 hidden layer for fast debugging without loading the full model into memory.

When should I use Quark Torch Shrink Model?

Quark Torch Shrink Model fits situations like: tasks that involve Model hubs and datasets.

How do I install Quark Torch Shrink Model in Claude Code?

Run `npx skills add amd/Quark --skill quark-torch-shrink-model -a claude-code`. Or copy the skill folder (skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model in amd/Quark) into .claude/skills/quark-torch-shrink-model in your project. Claude Code loads it when a task matches its description.

How do I install Quark Torch Shrink Model in Codex?

Run `npx skills add amd/Quark --skill quark-torch-shrink-model -a codex`. Or copy the skill folder (skills/_legacy_impl/l1-atomic/torch/quark-torch-shrink-model in amd/Quark) into .agents/skills/quark-torch-shrink-model in your project. Codex loads it when a task matches its description.

Can I use Quark Torch Shrink Model in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add amd/Quark --skill quark-torch-shrink-model -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/quark-torch-shrink-model, .gemini/skills/quark-torch-shrink-model, .github/skills/quark-torch-shrink-model and .opencode/skills/quark-torch-shrink-model in your project.

What does Quark Torch Shrink Model need to run?

Going by SKILL.md and its folder, Quark Torch Shrink Model needs Python for the scripts in its folder and the command-line tools its instructions call (python and pip). Our summary lists: Python 3.

Does Quark Torch Shrink Model access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Quark Torch Shrink Model safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Quark Torch Shrink Model use?

Quark Torch Shrink Model is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Quark Torch Shrink Model use?

About 980 tokens (SKILL.md is roughly 3.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Quark Torch Shrink Model?

Skills that share tags, products or a category with Quark Torch Shrink Model: Codex Commit Agent (Julian-adv/OpenMMO, 1.8k stars), Hugging Face API Tool Builder (huggingface/skills, 11k stars), Comfy CLI (sundial-org/awesome-openclaw-skills, 663 stars) and SageMaker Serving Image Selection (huggingface/skills, 11k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Quark Torch Shrink Model?

amd (a GitHub organization) maintains it in amd/Quark, which has 181 GitHub stars. The repository holds 37 skills in this directory. The repository was last updated on September 28, 2026.

Source: amd/Quark on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.