Logo: J6 Ucp Hbm Infer

J6 Ucp Hbm Infer

Organisatioun
HorizonRobotics
j6-ucp-hbm-infer

Generate X86-side Python client code for hbm_infer, the Python SDK that connects to BPU boards via gRPC to deploy and run HBM model inference. Use this skill when the user wants to write Python code using hbm_infer client APIs — including HbmRpcSession (standard/flexible mode), HTensor for transmission optimization, output_config for output filtering, and related utilities like get_input_info, get_output_info, get_profile, compress_option, core_id. Triggers on writing or debugging Python inference scripts, optimizing data transfer between X86 and board, or any question about the hbm_infer Python client API.

Iwwersiicht

EditeurHorizonRobotics
RepositoryOE-Skills
Skill-Nummj6-ucp-hbm-infer
Stären
28
Forks
4
Matgeliwwert Dateien
6
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 6 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    HorizonRobotics huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill J6 Ucp Hbm Infer an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/HorizonRobotics/OE-Skills/tree/main/horizon/skills/ucp/j6-ucp-hbm-infer
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HorizonRobotics/OE-Skills.git /tmp/OE-Skills
mkdir -p .claude/skills
cp -r /tmp/OE-Skills/horizon/skills/ucp/j6-ucp-hbm-infer .claude/skills/j6-ucp-hbm-infer
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert J6 Ucp Hbm Infer an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet J6 Ucp Hbm Infer automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass J6 Ucp Hbm Infer net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

hbm_infer X86 Python Client Code Generation

Generate production-ready X86-side Python client code for hbm_infer — the Python SDK that connects to a BPU board via gRPC, deploys HBM models over SSH, runs inference, and manages board resources.

Quick Decision: Which Mode?

ScenarioModeModule
Single model, single processStandardhbm_infer.hbm_rpc_session
Multi-process inference sharing one serverFlexiblehbm_infer.hbm_rpc_session_flexible
Multi-model pipeline with shared board resourcesFlexiblehbm_infer.hbm_rpc_session_flexible

Standard Mode — Quick Reference

python
from hbm_infer.hbm_rpc_session import HbmRpcSession

session = HbmRpcSession(
    host="<board_ip>",
    local_hbm_path="<hbm_file_path>",
)
# Use session, then always close
session.close_server()

HbmRpcSession.init parameters:

ParameterTypeDefaultDescription
hoststrrequiredBoard IP address
local_hbm_pathUnion[str, List[str]]requiredLocal HBM file path(s)
usernamestr"root"Board SSH username
passwordOptional[str]NoneBoard SSH password
ssh_portint22SSH port
remote_rootstr"/map/hbm_infer/"Board-side temp directory
frame_timeoutint90gRPC per-frame timeout (seconds)
server_timeoutint5Server auto-shutdown timeout (minutes)
with_profileboolFalseEnable per-stage timing stats
debugboolFalseDebug mode with extra logging
compress_optionstr"NONE"gRPC compression: "NONE", "IN", "INOUT"
core_idUnion[int, List[int]]-1BPU core ID(s), -1=CORE_ANY
remote_environmentDict[str, Any]{}Board-side environment variables

Key methods:

  • session(data, output_config=None, model_name=None) — Run inference
  • session.get_model_names() → List[str]
  • session.get_input_info(model_name=None) → Dict[str, Dict]
  • session.get_output_info(model_name=None) → Dict[str, Dict]
  • session.show_input_output_info(model_name=None) — Print model I/O info
  • session.get_profile(model_name=None) → Cumulative timing stats (avg/min/max in ms)
  • session.get_profile_last_frame(model_name=None) → Last-frame timing stats (ms)
  • session.close_server() — Must call explicitly to release board resources

Flexible Mode — Quick Reference

python
from hbm_infer.hbm_rpc_session_flexible import (
    HbmRpcSession, init_server, deinit_server, init_hbm, deinit_hbm
)

server = init_server(host="<board_ip>")
handle = init_hbm(local_hbm_path="<hbm_file_path>", hbm_rpc_server=server)
session = HbmRpcSession(hbm_handle=handle, hbm_rpc_server=server)
# Use session...
session.close_server()
deinit_hbm(handle)
deinit_server(server)

Flexible mode separates lifecycle into three levels:

  1. Server (init_server / deinit_server) — Board connection and file deployment
  2. HBM Handle (init_hbm / deinit_hbm) — Model file on board
  3. Session (HbmRpcSession.__init__ / close_server) — Inference session

init_server parameters: host, username="root", password=None, ssh_port=22, remote_root="/map/hbm_infer/" init_hbm parameters: local_hbm_path, hbm_rpc_server

Flexible mode HbmRpcSession.__init__ takes hbm_handle and hbm_rpc_server instead of host and local_hbm_path. All other parameters (frame_timeout, with_profile, etc.) are identical to standard mode.

Transmission Optimization with HTensor

HTensor reduces data transfer between X86 and board. Three optimization scenarios:

1. Fixed/Periodic Input — Cache on Board

python
from hbm_infer.hbm_rpc_session import HbmRpcSession, HTensor

fixed_input = HTensor(
    data=torch.ones((1, 3, 224, 224), dtype=torch.int8),
    device=["cpu", "bpu"],  # "cpu" = X86, "bpu" = board copy
    key="model.input_0",    # Unique board-side identifier
)
# Update data periodically — only changed frames get transferred
fixed_input.data = torch.ones((1, 3, 224, 224), dtype=torch.int8) * 2

HTensor.init parameters:

ParameterTypeDescription
dataUnion[np.ndarray, torch.Tensor, None]Tensor data
deviceUnion[str, List[str], None]Storage: None, "cpu", "bpu", or ["cpu", "bpu"]
keyOptional[str]Board-side unique key (required when device includes "bpu")

HTensor properties: data (get/set), device (get only), key (get only), shape (get only, auto-maintained)

2. Output Filtering — Skip Unused Outputs

python
output_config = {
    "unused_output": {"device": None}  # Don't transfer back
}
result = session(data=input, output_config=output_config)
# result["unused_output"] is HTensor with data=None, but shape is available

3. Model Chaining — Board-Side Passthrough

python
# Model0 output stays on board
model0_output_config = {
    "output_0": {"device": "bpu", "key": "model0.output_0"}
}
model0_output = session(data=model0_input, output_config=model0_output_config, model_name="model0")

# model0_output["output_0"] is HTensor — use directly as model1 input
model1_input = {"input_0": model0_output["output_0"]}
model1_output = session(data=model1_input, model_name="model1")

output_config Format

Dict[str, Dict[str, Any]] — first-level keys are output names, second-level keys:

KeyValueMeaning
"device"None / "cpu" / "bpu" / ["bpu", "cpu"]Where to store the output
"key"strBoard-side unique key (required when device includes "bpu")

Outputs in output_config return as HTensor; others return as np.ndarray or torch.Tensor.

Inference Input/Output Rules

  • Input data: Dict[str, Union[np.ndarray, torch.Tensor, HTensor]]
  • Output: Same type as input (torch in → torch out, numpy in → numpy out)
  • No mixing torch.Tensor and np.ndarray in the same data dict
  • All torch.Tensor inputs must have the same device
  • Input names, shapes, and element types must match model specs

Model I/O Info Fields

get_input_info() / get_output_info() return Dict[str, Dict] — first-level keys are tensor names, second-level values contain:

FieldAlwaysTypeDescription
valid_shapeYesList[int]Tensor shape. -1 in a dimension indicates a dynamic dimension
tensor_typeYesstrData type enum name (see below)
quanti_typeYesstrQuantization type enum name (see below)
quantizeAxisNointPer-channel quantization axis. Only when quanti_type != QUANTI_TYPE_NONE
scale_dataNoList[float]Quantization scales. Only when quanti_type != QUANTI_TYPE_NONE
zero_point_dataNoList[int]Quantization zero points. Only when quanti_type != QUANTI_TYPE_NONE

tensor_type values: DATA_TYPE_S4, DATA_TYPE_U4, DATA_TYPE_S8, DATA_TYPE_U8, DATA_TYPE_F16, DATA_TYPE_S16, DATA_TYPE_U16, DATA_TYPE_F32, DATA_TYPE_S32, DATA_TYPE_U32, DATA_TYPE_F64, DATA_TYPE_S64, DATA_TYPE_U64, DATA_TYPE_BOOL8

quanti_type values: QUANTI_TYPE_NONE, QUANTI_TYPE_SCALE

Multi-Model Session

When local_hbm_path contains multiple models:

  • Model names ≠ HBM file names — call session.get_model_names() to list them
  • Must specify model_name in get_input_info, get_output_info, __call__, get_profile
  • Model file names and graph names must be unique across the session

Profile Data Structure

When with_profile=True, get_profile() returns cumulative stats (avg/min/max in ms):

KeyMeaning
frame_durationTotal frame latency
sd2rv_durationgRPC send-to-receive latency
commu_durationNetwork communication time
board_durationTotal board-side time
infer_durationPure inference time on board
prepr_durationBoard-side pre-processing time
pospr_durationBoard-side post-processing time

get_profile_last_frame() returns the same keys with single-frame values (ms).

Critical Rules

  1. Always call close_server() — Board processes and storage will leak otherwise. Do NOT rely on __del__.
  2. Always call deinit_hbm() and deinit_server() in flexible mode — same reason.
  3. Use try/finally to guarantee cleanup even on exceptions.
  4. Compression is software-level — Increases latency, only use to reduce network load / increase throughput. Avoid for float I/O; try for image input / segmentation output.
  5. Board-side logs: ${remote_root}/${session_token}/log/s.log for debugging.
  6. Multi-model session: user must guarantee unique names — Model file names and internal graph names must not duplicate across the session; duplicates silently overwrite files on the board.
  7. Model chaining must use the same session — One session maps to one board-side process; board-side data (HTensor with device="bpu") can only be reused within the same process.
  8. L2M model inference requires remote_environment and core_id — Set HB_DNN_USER_DEFINED_L2M_SIZES via remote_environment to allocate L2 memory per BPU core (e.g. {"HB_DNN_USER_DEFINED_L2M_SIZES": "6:6:6:6"} for 4-core, 6MB each). Set core_id to match the cores in the env var. If the user needs L2M inference but hasn't specified this env var, ask for the L2M size requirement.

Code Generation Workflow

When generating hbm_infer code:

  1. Ensure hbm_infer is installed: Check with pip3 list | grep hbm_infer. If not installed, run:
    bash
    pip3 install hbm_infer -i https://pypi.hobot.cc/hobot-local/simple
  2. Determine mode: Ask or infer standard vs. flexible based on use case
  3. Read model info: Generate code that calls show_input_output_info() or get_input_info() / get_output_info() to discover shapes and types
  4. Prepare inputs: Match model input names, shapes, and dtypes exactly
  5. Apply optimizations: Use HTensor for fixed/periodic inputs, output_config for filtering/chaining
  6. Add cleanup: Always wrap in try/finally with close_server() (and deinit_* for flexible mode)
  7. Add profiling if needed: Set with_profile=True and call get_profile() or get_profile_last_frame()
  8. Consult FAQ when in doubt: If uncertain about API usage, error handling, or edge cases, read references/faq.md for troubleshooting guidance

For detailed API signatures, complete examples, and troubleshooting, read the reference files:

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill J6 Ucp Hbm Infer?

Generate X86-side Python client code for hbm_infer, the Python SDK that connects to BPU boards via gRPC to deploy and run HBM model inference. Use this skill when the user wants to write Python code using hbm_infer client APIs — including HbmRpcSession (standard/flexible mode), HTensor for transmission optimization, output_config for output filtering, and related utilities like get_input_info, get_output_info, get_profile, compress_option, core_id. Triggers on writing or debugging Python inference scripts, optimizing data transfer between X86 and board, or any question about the hbm_infer P...

Firwat J6 Ucp Hbm Infer op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. J6 Ucp Hbm Infer besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech J6 Ucp Hbm Infer an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/HorizonRobotics/OE-Skills/tree/main/horizon/skills/ucp/j6-ucp-hbm-infer an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen J6 Ucp Hbm Infer benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat J6 Ucp Hbm Infer benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir J6 Ucp Hbm Infer domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill J6 Ucp Hbm Infer gratis?

Jo. HorizonRobotics huet de Skill ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇