sglang: Skill for Claude Code

.claude/skills/compute-mamba-ratio/SKILL.md

compute-mamba-ratio is a skill for Claude Code from sgl-project/sglang. It costs 88 tokens per session (3,560 once invoked), scanned A, original, Apache-2.0.

A method for choosing the memory split between recurrent state and attention cache when serving a hybrid model. Hybrid models combine ordinary attention layers with linear-attention layers such as Mamba, GDN, or KDA.

In plain words
What is it for?
Calculating the SGLang mamba memory ratio or a fixed Mamba cache size from context length, concurrency, speculative decoding, and serving settings.
Why use it?
An unsuitable split can limit request concurrency or context length even when total GPU memory remains. The method matches the two memory pools to the workload so neither becomes the first bottleneck.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is sgl-project/sglang's own configuration. It tells Claude Code how to work on sglang itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything sglang configures →

About the project

SGLang is a framework for running inference for large language models and multimodal models, meaning it processes inputs to produce model outputs such as text or other media. It is used to serve and accelerate open AI models and related workloads.

sgl-project/sglang · 35,682 stars · on GitHub · sglang.io

Reuse

Borrowing it

Nothing to install: this file belongs to sgl-project/sglang. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/sgl-project/sglang/main/.claude/skills/compute-mamba-ratio/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/sgl-project/sglang

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for compute-mamba-ratio

README.md
[![agentmods](https://agentmods.dev/badge/skills/sgl-project/sglang/compute-mamba-ratio/github.svg)](https://agentmods.dev/skills/sgl-project/sglang/compute-mamba-ratio)
Your own site
<a href="https://agentmods.dev/skills/sgl-project/sglang/compute-mamba-ratio"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/compute-mamba-ratio/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for compute-mamba-ratio

Your own site · 80×15
<a href="https://agentmods.dev/skills/sgl-project/sglang/compute-mamba-ratio"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/compute-mamba-ratio.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 88 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,560 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Snyk pass 7 Sept 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00088 $0.03560
Opus 5 $0.00044 $0.01780
Sonnet 5 $0.00018 $0.00712
Haiku 4.5 $0.00009 $0.00356

Measured 10d ago against content hash 55827de7e89d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

compute-mamba-ratio scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/compute-mamba-ratio/SKILL.md · 138 lines

How it starts

The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Optimal hybrid dual-pool ratio (--mamba-full-memory-ratio)

A hybrid model (attention layers + linear-attention layers — the recurrent-state family: Mamba/SSM, GDN, KDA, etc.) splits serving memory into two independently-budgeted pools, fixed once at startup:

  • state pool (the linear-attention recurrent state) → caps concurrency (hard: whole slots, worst-case reserved, fail-loud)
  • full-KV pool (attention KV) → caps context × concurrency (soft: paged, over-committable via retraction)

--mamba-full-memory-ratio r splits the post-weight budget: mamba_budget = rest · r/(1+r), i.e. mamba_budget : kv_budget = r. This skill picks the r (or the pin---max-mamba-cache-size alternative) at which neither pool bottlenecks first for the user's workload.

The formula

r*  =  (S + D) · token_equiv · dcp_size / L
token_equiv  =  state_bytes_per_slot / kv_bytes_per_token
  • L = average context length per request (input + output tokens)
  • token_equiv = full-KV token-equivalent of one state slot
  • S = state slots per running request (cache-strategy dependent, table below)
  • D = --speculative-num-draft-tokens (0 if NOSPEC); each running req carries D extra intermediate states
  • dcp_size = --dcp-size (1 without DCP). DCP shards the per-rank KV by dcp_size, so KV gets ~dcp_size× cheaper per request → the balance shifts that much toward the state pool.

r is dimensionless (just the split). To also predict the actual concurrency you need rest (below).

Inputs to collect from the user

  1. L — average context (input + output) in tokens.
  2. The two per-GPU byte constants — one of:
    • (a) measured (preferred, exact) — from one boot log at any ratio:
      • Mamba Cache is allocated. ... ssm_state size X GB with max_mamba_cache_size: Nstate_bytes_per_slot = X / N
      • KV Cache is allocated. #tokens: M, KV size: Y GBkv_bytes_per_token = Y / M
    • (b) derived — model arch (linear-layer count + state dims d_state/d_conv/heads/head_dim; attention type + KV dims: MLA latent dim, or GQA kv_heads·head_dim·layers) × the dtypes below.
  3. S — from --mamba-radix-cache-strategy, the overlap scheduler, and SGLANG_OPT_MAMBA_SKIP_DECODE_LOCK (table below).
  4. D--speculative-num-draft-tokens (0 if NOSPEC; also 0 when ReplaySSM spec-verify is enabled — see caveats).
  5. dcp_size--dcp-size (1 if no DCP). If DCP and spec with a replicated draft KV, apply the draft caveat (below).
  6. KV dtype (bf16 / fp8) and ssm dtype (fp32 / bf16) — they set the two byte constants (see the token_equiv 2×2).
  7. (only to also predict the clamp, not just r) rest = per-GPU memory − weights at the chosen --mem-fraction-static. Read avail mem after Load weight end, or Memory pool end. avail mem + pool sizes, from the boot log.

Read the full file on GitHub · 138 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 138 lines · 88 tokens per session scan A 55827de7e89d

Subscribe to this mod's changes

compute-mamba-ratio is a skill published in the GitHub repository sgl-project/sglang (35,682 stars, last pushed today), licensed Apache-2.0. It adds 88 tokens to every session and 3,560 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

llama-factory

Expert guidance for fine-tuning LLMs with LLaMA-Factory - WebUI no-code, 100+ models, 2/3/4/5/6/8-bit QLoRA, multimodal support.

davila7/claude-code-templates · 51 tokens

groq-inference

Ultra-fast LLM inference on custom LPU hardware. OpenAI-compatible API at api.groq.com. Lowest latency in the industry (500-1000+ tok/s). Supports chat completions, vision, audio (Whisper STT + TTS), tool calling, JSON mode, and streaming. Free tier available. Inference only — no training.

synthetic-sciences/openscience · 77 tokens

fireworks-ai-inference

Fast inference and fine-tuning platform with serverless and on-demand GPU deployments. OpenAI-compatible API for chat completions, embeddings, function calling, vision, and structured output. Supports SFT, DPO, and RL fine-tuning. SOC2 + HIPAA compliant.

synthetic-sciences/openscience · 62 tokens

ort

ONNX Runtime in Rust via the ort crate (2.x): loading sessions, configuring CPU/CoreML/CUDA execution providers, tensor I/O with ndarray, async-safe spawnblocking wrapping, global thread-pool init, and debugging provider/opset issues.

bobmatnyc/claude-mpm-skills · 54 tokens

minimind-learning

A Chinese-language learning assistant for MiniMind, a small language-model project, that records study notes and recognizes common machine-learning terms.

joyehuang/minimind-notes · 76 tokens

llama-factory

Expert guidance for fine-tuning LLMs with LLaMA-Factory - WebUI no-code, 100+ models, 2/3/4/5/6/8-bit QLoRA, multimodal support.

OpenLAIR/dr-claw · 51 tokens