writing-skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
sdkUse MMDeploy SDK model directories, runtime FFIs, profiler output, and packaged SDK distributions for inference.
Independent GitHub snapshot · Automated classification · Original documentation governs
Use this sub-skill when the user already has, or needs to consume, an MMDeploy
SDK model directory produced with --dump-info; when they ask how to run
mmdeploy_runtime from Python; when they need C, C++, Java, or C# SDK inference
patterns; when they have SDK profiler output; or when they need safe guidance on
precompiled SDK/runtime packages.
Do not use this sub-skill for conversion internals, deployment config authoring, backend toolkit installation, custom-op builds, regression automation, or metric benchmarking. Route those tasks to the owning conversion, backend, extensibility, or validation guidance, and return here only for the SDK model directory/runtime handoff.
--dump-info handoff, Python
and C/C++ API patterns, language demo coverage, and FFI task mapping.Clarify the artifact. SDK runtime APIs consume a model directory or a
zip model built for SDK loading. A raw backend file such as end2end.engine,
end2end.onnx, end2end.xml, or end2end.param is not enough for
mmdeploy_runtime task classes because preprocessing and postprocessing live
in the SDK metadata JSON files.
Check the model package before writing runtime code. At minimum, the
directory should contain deploy.json, pipeline.json, detail.json, and
every backend file named by deploy.json. Use
Model directory for a deterministic checklist.
Pick the runtime FFI from the user environment.
mmdeploy_runtime and create the appropriate task class,
usually Detector, Classifier, Segmentor, Restorer,
TextDetector, TextRecognizer, PoseDetector, RotatedDetector, or
VideoRecognizer.mmdeploy_mat_t,
call *_apply, release results, and destroy handles.mmdeploy::Model, mmdeploy::Device or mmdeploy::Context, then
construct mmdeploy::<Task> and call Apply.(modelPath, deviceName, deviceId) and keep required native libraries discoverable.Interpret device arguments literally. Python runtime constructors take a
device_name such as "cpu" or "cuda" plus a numeric device_id. Do not
pass a converter-style backend_files list to SDK task classes, and do not
pass only an engine file as model_path.
For profiler questions, route directly to the analyzer. If the file is a
text SDK profile with a graph section, a ---- separator, and event lines,
run:
python scripts/sdk_analyze.py profiler_data.txt
Then use Profiler and packaging to
interpret occupy, usage, n_call, t_mean, t_50%, and t_90%.
For precompiled package questions, distinguish usage from release builds. Installing an existing runtime wheel/package is a user workflow. Building release packages is a maintainer workflow that depends on Python ABI, platform, device, backend libraries, CMake flags, and licensing constraints.
Use these only as read-only probes; they do not prove a backend engine is valid:
python - <<'PY'
import importlib.util
print('mmdeploy_runtime:', importlib.util.find_spec('mmdeploy_runtime') is not None)
PY
from mmdeploy.backend.sdk import is_available
print(is_available()) # True only when the Python SDK runtime module is visible
If either check is false, do not continue with SDK inference code until the runtime package or built SDK Python API is available.
--dump-info was omitted or the SDK JSON files are missing, hand the user
back to conversion guidance to regenerate the model directory with SDK info.mmdeploy_runtime imports but backend shared libraries or device runtimes
are missing, use backend guidance for the target backend/device before trying
another API layer.