packaging-and-containerization
Build BentoML Services into Bentos, author bentofile.yaml or equivalent build options, configure runtime images/dependencies, manage local Bento stores, and containerize safely.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- packaging-and-containerization
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Build BentoML Services into Bentos, author bentofile.yaml or equivalent build options, configure runtime images/dependencies, manage local Bento stores, and containerize safely.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/bentofile-reference.md4.8 KB
- 参考文档references/troubleshooting.md4.1 KB
- 参考文档references/workflows.md3.3 KB
- 脚本scripts/create_minimal_bentofile.py6.5 KB
- 脚本scripts/validate_bentofile.py16.0 KB
03 SKILL.md 正文
Packaging and Containerization
Use this sub-skill when the task is about turning a BentoML Service into a Bento artifact or OCI image: bentoml build, bentoml.build(...), bentofile.yaml, pyproject.toml [tool.bentoml.build], dependency/runtime image settings, file inclusion, local Bento store operations, or bentoml containerize.
Do not use this sub-skill for writing the Service/API itself, running clients or servers, BentoCloud deployment, or framework-specific model import/export details. Route those to service-authoring, serving-and-clients, cli-and-cloud, or model-management.
Fast Path
- Identify the entry Service import path, usually
service:ClassNamefor a class decorated with@bentoml.serviceormodule:svcfor an exported service object. - Prefer runtime image configuration in Python with
bentoml.images.Image(...)attached to@bentoml.service(image=...)for new SDK Services. - Use
bentofile.yamlor[tool.bentoml.build]when the project needs declarative build metadata, file patterns, models, or compatibility with existing workflows. - Run safe local validation before building: parse the YAML, check required files, inspect include/exclude patterns, and confirm dependency files exist.
- Build with
bentoml build,bentoml build -f path/to/bentofile.yaml BUILD_CTX, orbentoml.build(...). - Containerize only when Docker or another OCI backend is available:
bentoml containerize BENTO_TAGorbentoml build --containerize.
Safe Local Checks
python scripts/validate_bentofile.py bentofile.yaml --project-dir .validates field shapes, required paths, and common packaging mistakes without running BentoML, Docker, network access, or dependency resolution.python scripts/create_minimal_bentofile.py --service service:MyService --package numpy --include service.pyprints a starterbentofile.yamlto stdout or writes it with--output bentofile.yaml.bentoml build --bentofile bentofile.yaml --name NAME --version VERSION .creates a Bento in the local Bento store and may resolve dependencies; treat it as more expensive than static validation.bentoml containerize BENTO_TAG --platform linux/amd64requires a container backend and may pull base images or run Docker/BuildKit.
Core Workflows
- Authoring field-level build files: see
references/bentofile-reference.md. - Choosing CLI/API/container commands and build contexts: see
references/workflows.md. - Diagnosing build and image failures: see
references/troubleshooting.md.
Minimal Examples
A minimal bentofile.yaml:
service: "service:MyService"
include:
- "service.py"
python:
packages:
- "numpy"
docker:
python_version: "3.11"
Equivalent direct build API shape:
import bentoml
bento = bentoml.build(
service="service:MyService",
include=["service.py"],
python={"packages": ["numpy"]},
docker={"python_version": "3.11"},
)
A modern runtime image in service.py:
import bentoml
image = bentoml.images.Image(python_version="3.11").python_packages("numpy")
@bentoml.service(image=image)
class MyService:
pass
Build Context Rules
- Relative paths in
include,exclude,requirements_txt,environment_yml,setup_script,dockerfile_template, wheels, and descriptions usingfile:are resolved relative to the build context. - If
includeis absent, BentoML includes all files under the build context, then appliesexclude,.bentoignore, and built-in ignores such as.git/, virtualenvs,__pycache__/, and.DS_Store. excludealways applies afterinclude; use it to remove secrets, tests, training data, notebooks, and large artifacts.- For
src/layout projects,pyproject.tomlauto-detection can markpython.is_src_layout, and explicitpython: {is_src_layout: true}strips the leadingsrc/when packaging code.
Side-Effect Boundaries
- Static YAML checks and file existence checks are safe.
bentoml buildwrites to the local Bento store and can run package locking; it may access package indexes or local model stores.bentoml build --containerize,bentoml containerize, andbentoml.container.buildrequire an OCI builder and may pull or build images.bentoml push,bentoml pull, andbentoml deployare cloud/network operations and belong in cloud/deployment workflows.
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).