New
Apps 6,355Makers 6,334This week 13
Promote your app−30%
neurarch-mcp screenshot 1 1 / 6
2views in
the last 30 days

neurarch-mcp

MCP server exposing a Neurarch model graph to Claude Code, Cursor, Windsurf

Built with Claude/Claude Code/ llama.cpp

by neurarch-ai · Unclaimed · added Nov 2, 2026
no ratings0 comments

Know what a GPU job needs before it takes a reservation, from inside your agent. An MCP server for Claude Code, Cursor, Claude Desktop, VS Code, Windsurf and Codex.

  • Small jobs: pack them or move them to a smaller card.
  • Large jobs: the right card count and sharding the first time.
  • Agent-launched jobs: a gate before the GPU, because an agent cannot size its own job.

GitHub stars

Call size_training_job before a job launches and the agent learns, for the model, batch and card in front of it: the peak memory (weights and optimizer state, activations, stored attention scores, each shown), the smallest card that holds it, the largest batch each card holds, a two-card split when one card does not, what one run costs, and a one-line verdict such as will not fit a T4: needs ~30 GB with headroom (peak 26 GB) at batch 32, seq 2048, use L40S or batch <= 12. history adds what that structure measured the last time it ran in your organisation. After a CUDA out-of-memory error, diagnose_oom reads the message against the same estimate and names the cause (too big for the card, fragmentation, another process, logits over a large vocabulary, growth during the run) with the least invasive fix first. Then whether it forward-passes: the structural checks the CI bot runs (lint_model, check_design), offline too. It answers the same whether a person or an agent wrote the job, which is the question the person who owns the GPU bill is asking.

See it

Before launch. The job does not fit the card it was about to take, so the agent sizes it again at the batch the tool named:

size_training_job refusing batch 32 on a T4, then confirming batch 12 fits

A model straight from Hugging Face. Qwen3-8B fits no single card at batch 8, and on eight A100-40s only sharded:

size_training_job on hf:Qwen/Qwen3-8B: no single card holds it, 8xA100-40 fits only under FSDP / ZeRO-3

After a CUDA out-of-memory error. The message is read against the same estimate, and the cause comes back with the fix that leaves training unchanged listed first:

diagnose_oom naming too-big-for-card and batch 8 with 4 accumulation steps

Not every OOM means a smaller batch. When the job fits and the allocator does not, the fix leaves training as it is:

diagnose_oom naming fragmentation and expandable_segments, with batch 8 unchanged

Whether it forward-passes. The shipped examples/tiny-vit.py builds an attention layer its head count does not divide:

lint_model blocking embed dim 258 with 8 heads in examples/tiny-vit.py

Without the agent asking. neurarch-mcp hook sizes a python train.py launch before the Bash call runs and blocks the one that will not fit:

the PreToolUse hook blocking batch 32 on a T4 and letting batch 12 through

Every number in these recordings is copied from the tools' real output (0.17.1 and 0.17.2) on phi3-mini, tiny-vit.py and hf:Qwen/Qwen3-8B; the error texts are examples and the model's closing sentences are scripted. scripts/demo-anim/ has the calls.

The memory number is a calibrated estimate of the training peak under AdamW with bf16 autocast, not a measurement: 1.2 x 16 bytes per parameter, plus, per sample in bf16, 0.88 x every layer output, 3.64 x stored attention scores (eager attention only; SDPA and flash keep none), 1.34 x each layer's weight-matrix intermediates, 5.2 x recurrent gate states and 2.02 x the largest single tensor. Fitted on 178 measured runs across 41 architectures, out-of-memory runs included. Held out one architecture at a time, the median error is 7% above 1 GB and it flagged 113 of the 131 times a run did not fit a 16, 24, 40 or 80 GB card, where accelerate estimate-memory flagged at most 8. On 25 runs measured after the fit, at the edge of a 24 GB card, the median miss is 14%, so read it as a fit check before a precise number. Every run is public: neurarch.com/memory-calibration.

Get the graph by tracing the model for real shapes, or point the server at a saved graph, a PyTorch .py, or a Hugging Face repo. Every tool but three runs on your machine, offline, with no API key and no account. Two of the three, plan and history, read what a frontier model structurally cannot know: what happened the last time this exact structure trained here. That is not in the weights and not in the repository. The third, model_changes, reads the public record of what changed in a Hugging Face model between revisions. They are the only tools in this package that open a socket.

Install

claude mcp add neurarch -- npx -y neurarch-mcp /abs/path/to/model.py        # Claude Code

Or, in Claude Code, the server, the launch hook and the skill in one plugin: /plugin marketplace add neurarch-ai/neurarch-mcp, then /plugin install neurarch@neurarch-ai.

Add to Cursor Install in VS Code Claude Desktop bundle

Per-client config for Claude Desktop, Cursor, VS Code, Windsurf and Codex is below. Node 20+ is the only requirement; there is no install step beyond npx.

What it looks like

An agent about to launch a fine-tune on a T4, against src/test/templates/phi3-mini.neurarch.json (a 310M-parameter Phi-3 block, one of the Neurarch app's templates). The output is the tool's, trimmed:

Agent ▸ (calls size_training_job { batch_size: 32, gpu: "T4" })
  verdict        will not fit a T4: needs ~30 GB with headroom (peak 26 GB) at batch 32,
                 seq 2048, use L40S or batch <= 12
  memory         peak 26.38 GB = 5.96 weights + optimizer state, 20.42 activations
                 (SDPA: the 40.13 GB of attention scores eager would keep are not counted)
  maxBatch       T4 12, L4 23, A10G 23, A100-40 45, L40S 56, A100-80 99, H100-80 99
  cost           $9.68 on a T4, 10 epochs over 50,000 samples (assumed; pass samples)
  forwardPasses  legal, no blockers
  lastRun        fingerprint 4e0b97b4: call history for what it measured last time

  (same job, attention: "eager", gpu: "A100-40")
  verdict        will not fit an A100-40: needs ~76 GB with headroom (peak 67 GB) at batch 32,
                 seq 2048, use A100-80 or batch <= 15
  memory         peak 66.51 GB = 5.96 weights + optimizer state, 60.55 activations
                 (40.13 GB of them the attention scores eager keeps)

A real exchange against examples/tiny-gpt.neurarch.json, about where the budget lives:

You ▸ Where does the parameter budget live, and is it safe to drop block_1?

Claude ▸ (calls describe_architecture)
  tiny-gpt: 8 layers, depth 7, 57.8M params, 8.27 GMACs.
  Heaviest by params: token_embedding (25.7M, 44%), lm_head (25.7M), block_0/1 (3.1M each).
  Heaviest by compute: lm_head, then the two decoder blocks. Validation: clean.

  (calls layer_impact { names: ["block_1"] })
  Downstream of block_1: final_norm and lm_head (shape-sensitive, weight-carrying), then output.

  The budget is dominated by the embedding + LM head (~89%), not the decoder blocks,
  so dropping block_1 frees only ~3.1M params (~5%) while removing one of just two
  decoder layers. It is structurally safe (final_norm just re-reads block_0's output),
  but it is the wrong lever if your goal is shrinking the model. Quantizing the
  embedding/head would do far more.

And whether it forward-passes, shown on examples/tiny-vit.py in the recording above. That is a runtime crash sitting in source that reads fine, found offline in milliseconds, with no key and no account. The same rule set the Neurarch CI action reports, so a clean result here is a clean CI run. The rules are measured (the crash rules: 96 of 96 blocked graphs crashed PyTorch forward, 80 of 80 passes ran); the static parser in front of them is the weaker half, and we measured that too.

Three ways in, in order of how well they work

Input What the agent gets How
A traced graph (neurarch-trace). Start here. Everything, with real shapes, because they are read at runtime rather than inferred from text. Handles what static parsing cannot: from_pretrained, timm, models spread across files, anything built dynamically. The trace_model tool runs this for the agent. pip install neurarch-trace
NEURARCH_TRACE=1 python train.py (no target, no shapes, no edit: it records the first forward pass the script runs)
or neurarch-trace my_pkg.model:build --input 1,3,224,224
A Hugging Face repo The architecture from config.json, with the published parameter count next to the graph's so you can see how close it is (Qwen2.5-0.5B: 494.00M against 494,032,768). npx -y neurarch-mcp hf:Qwen/Qwen2.5-0.5B --hf
A self-contained PyTorch .py file. The fallback. Layers, types, hyperparameters and wiring, when the file builds its own layers with literal sizes. Shapes and FLOPs are unknown, because the source never says what goes in, and are reported as unknown rather than as zero. On real repositories this is the weak path, and we measured how weak: a graph a person would recognise for 41% of 116 real model files, and of the block and warn findings raised on them, zero were real defects when hand-judged. Good enough to orient with, not to act on. The study. npx -y neurarch-mcp model.py

A .neurarch.json saved from the Neurarch app (File → Save) is the fourth, and carries shapes, groups and design notes. Add --watch so the agent sees app-side saves without a restart.

The flow this server is built around, in one line each: size_training_job before any job launches, history for what that structure measured last time, trace_model for a graph with real shapes, plan for the card the CI bot posts, lint_model / check_design for whether it forward-passes, suggest_fix for the edit. Everything else answers a question one of those raised.

What the static parser can read

We measured it rather than describe it: docs/REAL_REPOS_STUDY.md runs the parser and linter over 116 model files from 59 popular repositories (nanoGPT, HF modeling_*.py, timm, torchvision, DiT, MAE, CLIP, Mamba, SAM, diffusers and more). The parser returns a graph for 86% of files and a graph a person would recognise as the model for 41% (Llama, Qwen2, Mistral and Gemma come back as 58-node graphs; nanoGPT as 72), up from 63% and 8% in August. Re-measured 2026-09-09 with per-edge provenance: every edge the importer chained from statement order rather than read out of forward() is marked, the rules that are about adjacency hold back on those, and block+warn findings fell from 92 to 37 with two thirds of the parser artefacts gone. Real defects found on either engine: still zero. The graph is good enough to orient with and not yet good enough to lint from; run trace_model before acting on a finding from a .py.

Three consequences are in this release. A graph from source carries a parseQuality grade (full, partial, thin) on describe_architecture and lint_model, with the fix named. Dimension rules are held back on layers whose dimension is still source text, and the count is reported as suppressed rather than dropped. And find_models marks thin parses partial so an agent does not build a plan on two layers. For real repositories, use neurarch-trace: it reads the numbers at runtime, which is the only place they exist.

Every read tool also takes an optional model_path, so one server covers a whole repository: ask about baseline.py, then variant_b.neurarch.json, then zoo:llama-3-8b, without restarting anything. find_models tells the agent what is there.

Tools

Start here: size the job before it launches

Tool Answers
size_training_job What a training job needs before it takes a GPU reservation. Inputs: the model (the server's, model_path to a .py, a traced .neurarch.json, zoo:<id> or hf:<org/name>, or hf_id), batch_size, and optionally gpu ("A100-40", "H100", "8xH100"), seq_len, attention (sdpa default, flash, eager), epochs and samples for the price, and data (seq_len, tokenizer_size, num_classes, image_size, channels). Returns the training peak at that batch with its weights-and-optimizer, activation and attention-score parts; the smallest card that holds it with 1.15x headroom; per card a gpuVerdict of fits, borderline or does_not_fit against an upperBound (the estimate x 1.43, at or above the measured peak on 95% of 91 held-out runs), with smallestSafeGpu (the cheapest card that holds the upper bound) and maxBatchSafe, and a borderline verdict says to measure one step before reserving; with data or seq_len, a dataFit report on whether the data fits what the model accepts (a sequence past a learned position table, a tokenizer larger than the embedding, labels past the classifier head, an image size or channel count the first layer was not built for, each a first-batch crash), the label count read from an hf: model's own config.json; the largest batch on each of T4, L4, A10G, L40S, A100-40, A100-80 and H100-80; a two-card split when one card does not hold it; one run's cost on the requested card or the cheapest that fits; a verdict line; whether the graph forward-passes; the structural fingerprint for history; and the held-out accuracy sentence. An N-card request is read both as plain DDP (a full copy per card at the per-device batch) and as sharded FSDP / ZeRO-3. Computed by the same buildPlan the Neurarch app, the CI bot and POST /api/v1/plan run, vendored, offline. A graph that feeds a hidden-state or image tensor into a token embedding is refused rather than sized, because the number would be wrong by the hidden width.
diagnose_oom Why a job ran out of GPU memory, and the smallest change that fixes it. Call it after a CUDA out-of-memory error, before changing batch size. Inputs: error (the text as printed, either PyTorch wording), and optionally the model (as above, or hf_id, read from the local config cache with no network when it is there), batch, seq_len, step, attention, and inference: true with gen_tokens for a generation job. It reads the allocated, reserved-but-empty, other-process and failing-request numbers out of the message, compares them with the same predicted peak size_training_job uses, and returns one cause (too-big-for-card, fragmentation, other-process, large-logits, undeclared-memory, grows-during-run, unknown), a summary, the evidence lines it was read from, fixes ordered least invasive first with a changesTraining flag on each, and the job facts used. A smaller batch is offered only when the job is too big for the card, and then with the gradient accumulation that keeps the effective batch. The diagnosis is the app's own (npx neurarch oom), vendored in the plan bundle.
check_edit Whether an edit to a model's config or architecture is one that runs and is wrong, and what it did to memory. Call it after editing and before training. Inputs: the base (base_model_path: a .py, a .neurarch.json, zoo:<id> or hf:<org/name>; or base_config) and the changed model (the server's, model_path, model_source, or config); base_config and config take a Hugging Face config.json as an object, JSON text or a path. Optionally lora_target_modules, batch (default 32), seq_len, gpu, attention. Returns findings, each with a stable rule, a severity, the tensors or keys it is about, and seenIn (the public upstream reports of that failure): vocab-resize-incomplete (a resize that left a token-indexed tensor at the old vocabulary), weight-tying-lost, attention-config-drift (heads, head_dim, hidden_size and kv heads that have to move together), rope-context-drift (a longer context with no RoPE scaling), and, against lora_target_modules matched the way PEFT matches it, lora-target-no-match, lora-target-partial and lora-target-wrapper; config divisibility comes back under the lint ids head-dim-divisibility and gqa-head-divisibility. Then memory: the training peak before and after at that batch and sequence length, the delta, and whether the job still fits gpu (or the smallest card that holds it, before and after), from the same estimate size_training_job uses. The checks are the app's own (src/utils/editChecks.ts), vendored in the plan bundle.

Before a multi-GPU or serving launch

check_parallel_layout says whether a TP / PP / DP / CP / EP split is legal, which pipeline stage is the straggler, the predicted step slowdown against a balanced split and the split that removes it, every time labelled predicted (per-card matmul efficiency fitted on public GEMM measurements, the 1F1B schedule simulated op by op, never timed):

check_parallel_layout { model_path: "hf:Qwen/Qwen3-8B", tp: 4, pp: 4, micro_batch: 1, global_batch: 32, seq_len: 4096, gpu: "h100" }
-> legal on 16 x h100-sxm; predicted 15.5% slower per step than a balanced split (slowest stage 3);
   split 10,10,9,7 is predicted 11.4% faster; bubble 8.6%; 1 warning

check_serving_config reads a vLLM, SGLang or llama.cpp launch line against the model's config.json, tokenizer_config.json, chat_template.jinja and generation_config.json and the card, and returns findings on TP against the heads, served length against the context, KV memory and concurrency, quantization against the card, and the chat template and sampler defaults (with against, what

Description taken from the repository README.

Ratings

–
0 ratings
5 0
4 0
3 0
2 0
1 0

Rate this app

Sign in to rate

Comments 0

Sign in to comment

No comments yet.

Related apps

#machine-learning · #model-graph · #mcp