edge-llm-add-model
Skill631 starsChanged 3 days agoApache-2.0View on GitHub
Implement TensorRT Edge-LLM support for a new Hugging Face checkpoint or model family. Use for a new `model_type`, architecture, text/vision/audio/action component, checkpoint tensor layout, speculative draft, model-specific custom operation, or runtime artifact. Starts from checkpoint inspection and the provider reference, finds the closest existing family, chooses the smallest supported frontend surface, and requires reference-to-export-to-engine-to-inference evidence. Do not use merely to convert an already supported checkpoint (edge-llm-convert-model), serve it (edge-llm-serve), or develop a standalone plugin/kernel (edge-llm-plugin-extension, edge-llm-cutedsl-kernel).
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- edge-llm-accuracy-debuggingSkill
- edge-llm-benchmark-accuracySkill
- edge-llm-benchmark-performanceSkill
- edge-llm-convert-modelSkill
- edge-llm-cpp-testSkill
- edge-llm-cutedsl-kernelSkill
- edge-llm-documentationSkill
- edge-llm-e2e-testSkill
- edge-llm-feature-combinationsSkill
- edge-llm-few-layer-testSkill
- edge-llm-installSkill
- edge-llm-plugin-extensionSkill
- edge-llm-serveSkill
- edge-llm-version-migrationSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 59
Create the smallest deterministic provider run that exercises the difference: fixed seed, greedy decoding, known inputs, and captured …
- Very specific: line 64
Use edge-llm-few-layer-test.
- Distinctive: line 81
Keep model-specific branches in the family directory.
- Very specific: line 121
Use edge-llm-convert-model for levels 4–6 and edge-llm-e2e-test for level 7.
- Very specific: line 122
Do not add a checkpoint to supported-models.md before inference and its baseline pass on the stated route and platform.
- Very specific: line 128
Before completion: search for every registry or switch use of the added enum or model_type.
- Very specific: line 147
Run scripts with the shell tool, with python3.10 or newer (the default python3 can be older), and keep the JSON output as evidence.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. --><!-- SPDX-License-Identifier: Apache-2.0 -->Add model support
Implement from the exact checkpoint and its reference model. Do not port from a model name, marketing family, or memory of another runtime.
Instructions
Inspect the exact checkpoint and its provider reference, find the closest existing family, classify the smallest supported change, implement one component at a time, and validate each against the reference before the next. Finish with the Review pass and a short report.
Read first
AGENTS.mdandCODING_GUIDELINES.md.- references/reconnaissance.md, including the checkpoint inspector and finding the closest family.
- Branch-local model docs and the selected frontend design:
- ONNX:
checkpoint-export.md,engine-builder.md, customization guide. - checkpoint-direct:
onnxless-builder.md, direct-builder guide, andtensorrt_edgellm/builder/README.md.
- ONNX:
- references/file-map.md after the implementation class is known. Search current code for every symbol it names; paths can move.
Phase 1: classify the change
Edge-LLM has independent model implementations for its supported ONNX frontend and experimental checkpoint-direct frontend. Shared C++ runtimes do not make a Python model family portable between them.
Select only the route the user requested:
| Reconnaissance result | Smallest change |
Existing implementation, new equivalent model_type | Registry alias plus a proof that config and tensor contracts match |
| Standard dense decoder compatible with ONNX default model | No family fork; register the type explicitly (an unregistered ONNX model_type silently uses the default model, while the direct builder raises) and prove all required weights load and outputs match |
| Different block/math/tensor layout | New or extended family in that frontend |
| Missing vision/audio/action/draft component | Component implementation plus builder/runtime wiring |
| Missing operation expressible with existing layers | Add frontend lowering; avoid a plugin |
| Operation needs a custom kernel/layout/state contract | Use edge-llm-plugin-extension; use edge-llm-cutedsl-kernel for its CuTe DSL kernel |
| Model requires a model-local native runtime | Use experimental_models/ only when the design requires it and the user accepted experimental scope |
State a short plan: the closest family, the differences, the route, and the files expected to change. Get user agreement before a model-local native runtime or a broad shared-core change.
Phase 2: establish a reference before implementation
Create the smallest deterministic provider run that exercises the difference: fixed seed, greedy decoding, known inputs, and captured intermediate output for the first changed layer/component. Store model/config revision and input data.
For a new architecture, add a few-layer reference case before full deployment.
Use edge-llm-few-layer-test; this catches weight mapping and math errors faster
than a full generated sentence.
Phase 3: implement vertically
Work one component at a time:
- configuration and registry dispatch;
- weight mapping/loading: every model parameter must map to a checkpoint key, and every checkpoint tensor must be used, transformed, tied, or knowingly ignored (see Weight reconciliation);
- model/component graph;
- operation lowering and plugin only when required;
- runtime artifacts (tokenizer, template, processor, config);
- C++ profile/binding/runtime changes only when the exported contract changes;
- focused unit tests and negative contract tests.
Keep model-specific branches in the family directory. Shared code changes need at least two existing families in tests to prove no regression.
Weight reconciliation
The ONNX loader cannot be trusted to report skipped keys: prefix-filter and
key_remap drops are counted but never logged, "Key not found in model" is logged
only at DEBUG, the export CLI has no verbose flag, and parameters the checkpoint
never fills are not reported at all. So reconcile by name instead of by log:
- Take the checkpoint tensor names from
inspect_checkpoint.py. - Take the model's
state_dict()keys (parameters and buffers) for the family class, and apply the family'skey_remapto the checkpoint names. - Diff both ways. Every checkpoint-only name must be explained (tied, fused, quantization scale, or knowingly ignored), and every model-only name must be a buffer computed at construction or a defect.
The loader's "Loaded N, skipped M" line is only a cross-check. The direct builder
raises KeyError for a missing required tensor but does not report unused
checkpoint tensors, so run the same diff there.
For multimodal work, bring up the text model first, then each encoder/head, then the composed runtime. For speculative decoding, prove base inference before the draft path.
Phase 4: validation ladder
Each level gates the next:
- checkpoint inventory and provider reference;
- config/registry/weight unit tests;
- few-layer or component numeric comparison;
- selected frontend build:
- ONNX export and ONNX validation, or
- checkpoint-direct network build;
- TensorRT engine build on each claimed target;
- deterministic inference versus the provider reference;
- an end-to-end test for the model (see
edge-llm-e2e-test); - documentation and support-table update.
Use edge-llm-convert-model for levels 4–6 and edge-llm-e2e-test for level 7.
Do not add a checkpoint to supported-models.md before inference and its
baseline pass on the stated route and platform; mark rows that work only on the
direct builder (checkpoint-direct only).
Review pass
Before completion: search for every registry or switch use of the added enum or
model_type; make sure no private paths, internal hostnames, checkpoint
locations, or credentials are in the change; run pre-commit and the narrowest
applicable tests; and state which route, precision, platform, and component
remain unverified.
Report
State the checkpoint and revision, the closest family and route, what changed per layer, the validation commands and hardware, the reference comparison, the weight reconciliation result, and the remaining gaps. Export-only, compile-only, collection-only, or "the output looks plausible" is not model-support evidence.
Available scripts
| Script | Purpose | Run |
scripts/inspect_checkpoint.py | Inventory config.json, safetensors headers (top-level shards only), shard completeness, tensors absent from the index, and tensor patterns without importing provider code; exits 2 when there are no shards or the index names missing shards or tensors | python3.10 skills/edge-llm-add-model/scripts/inspect_checkpoint.py <checkpoint-dir> --output <work-dir>/checkpoint-inventory.json |
Run scripts with the shell tool, with python3.10 or newer (the default python3 can be older),
and keep the JSON output as evidence.
Examples
- "Add support for a new Hugging Face model_type": run the checkpoint inspector, find the closest existing family, state the plan, then implement and validate vertically.
- "This checkpoint is a renamed copy of an existing family": register the alias and prove the config and tensor contracts match; add no new family code.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

