model-management
Manage BentoML model stores, model references, framework save/load helpers, optional dependencies, and model troubleshooting for services and builds.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- model-management
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Manage BentoML model stores, model references, framework save/load helpers, optional dependencies, and model troubleshooting for services and builds.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/frameworks.md6.2 KB
- 参考文档references/model-store.md4.3 KB
- 参考文档references/troubleshooting.md4.9 KB
- 脚本scripts/check_framework_extra.py5.3 KB
- 脚本scripts/inspect_model_store.py4.3 KB
03 SKILL.md 正文
BentoML Model Management
Use this sub-skill when an agent needs to save, inspect, package, load, import/export, or diagnose BentoML models. Keep service endpoint design in ../service-authoring/SKILL.md; keep Bento build/container packaging mechanics in ../packaging-and-containerization/SKILL.md; keep BentoCloud deployment in ../cli-and-cloud/SKILL.md.
First Decision
- Need a model dependency in a Service or Bento build? Declare
BentoModel("name:version"),BentoModel("name:latest"), orHuggingFaceModel("org/model")as a Service class variable so BentoML can include/resolve it during build and deployment. - Need to put files into BentoML's local store? Use
bentoml.models.create(name)as a context manager for arbitrary model directories, or a framework helper such asbentoml.sklearn.save_model()when that framework helper is appropriate and installed. - Need to inspect or move a stored model? Use
bentoml models list/get/export/import/deleteor the Python equivalents underbentoml.models. - Need to load framework-native objects? Prefer the matching helper (
bentoml.sklearn.load_model,bentoml.pytorch.load_model, etc.) only when the stored model'smodulematches that helper and its optional dependencies are present.
Model Store Essentials
- BentoML stores models by tag (
name:version) and supports:latestresolution.bentoml.models.get(tag)returns abentoml.Model;bentoml.models.list(name_or_none)returns stored model objects. bentoml.models.create(name)yields a model reference withpathandpath_of(...); write or copy model files inside that directory, then let the context manager flush and save on successful exit.- Model metadata includes the saved module, labels, options, metadata, context, signatures, BentoML version, Python version, and creation time. Use it to diagnose helper mismatch and serialization/version mismatch.
- Import/export moves BentoML model archives or folders between stores. Use framework save/import APIs for raw framework artifacts;
bentoml.models.import_model()expects an exported BentoML model archive or folder. - Store location is controlled by the installed BentoML configuration and environment. If a model appears missing, inspect the active process environment and
bentoml models list --output jsonbefore assuming the tag is wrong.
Service Loading Pattern
Declare model dependencies at Service class scope, then load the framework object in __init__ or a method:
import bentoml
from bentoml.models import BentoModel
@bentoml.service
class IrisService:
model_ref = BentoModel("iris_sklearn:latest")
def __init__(self):
import joblib
self.model = joblib.load(self.model_ref.path_of("model.pkl"))
Class-scope declaration is important: BentoML records the model dependency for build, push, and deployment. Creating BentoModel(...) only inside __init__ can produce a Bento that starts without the referenced model and later fails with a model not found error.
For Hugging Face Hub models, use HuggingFaceModel("org/model") as a class variable and pass the resolved path to transformers loaders in __init__. Private or gated Hub models require the appropriate token in the runtime/build environment; do not bake secrets into skill content or service source.
Commands And APIs
- List models:
bentoml models listorbentoml.models.list(). - Inspect a model:
bentoml models get MODEL_TAG,bentoml models get MODEL_TAG --output json,bentoml models get MODEL_TAG --output path, orbentoml.models.get("MODEL_TAG"). - Export/import:
bentoml models export MODEL_TAG OUT_PATH,bentoml models import MODEL_PATH,bentoml.models.export_model(tag, path), andbentoml.models.import_model(path). - Delete:
bentoml models delete MODEL_TAG --yesorbentoml.models.delete(tag). Deletion can fail if a local Bento references the model. - Cloud transfer:
bentoml models push MODEL_TAGandbentoml models pull MODEL_TAGrequire BentoCloud auth; keep deployment/cloud workflow in../cli-and-cloud/SKILL.md.
Bundled Helpers
scripts/inspect_model_store.pylists model tags, modules, locations, metadata keys, context, and optional tag details. It is read-only.scripts/check_framework_extra.pychecks whether a framework helper's Python modules are importable and warns about deprecated helper-module usage. It does not install packages or download models.
References
- Model store operations:
references/model-store.md. - Framework helpers and optional dependencies:
references/frameworks.md. - Troubleshooting:
references/troubleshooting.md.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).