Pipestream AI / TurboEmbed

C API · gRPC · KServe v2 · bundles

A C API in process, and one port over gRPC.

A program can link libturbo and call its C API directly, or talk to turbo-kserve, which loads bundles and serves them over the KServe v2 Open Inference Protocol. The same server hosts the analysis, search, catalog, training, vocabulary and health services on its one port.

Hand-written C header Seven gRPC services on one port TLS, mutual TLS and bearer tokens Prometheus metrics

Two ways in, one library underneath.

Every answer the server gives comes from a turbo_* call in the C header. The server is a projection of the library and adds nothing the header does not have.

Callers, one server port, the libturbo C ABI and the devices gRPC clients, Connect clients through the workbench, and C or C++ programs reach libturbo. gRPC and Connect traffic goes to turbo-kserve on one port, which serves the KServe v2 inference service, analysis, search, catalog, training, vocabulary and health. turbo-kserve and direct C callers both call the libturbo C API, which dispatches to the CPU, CUDA, Level Zero, NPU, Metal and Hailo backends. Callers gRPC clientsRust, Java, Python, any language WorkbenchConnect over HTTP, binary protobuf C and C++ programsinclude/turbo/turbo.h One port turbo-kserve--listen 0.0.0.0:8081 inference.GRPCInferenceService AnalysisService TurboSearchService TurboCatalogService TurboTrainingService TurboVocabularyService grpc.health.v1.Health C ABI libturboruntime, bundles, sessions, tokenizers,embed, rerank and extractive QA Devices CPU CUDA Level Zero GPU Intel NPU Metal Hailo Token buffers pinned memory: CPU, CUDA, Level Zero, Metal host memory: Intel NPU, Hailo
Callers reach libturbo directly or through the server, and libturbo runs the work on the device a model was loaded on.

The libturbo C API.

include/turbo/turbo.h is a hand-written C11 and C++17 header. A caller creates a runtime, loads a bundle, opens a session, writes inputs, runs, and reads the result.

  1. turbo_runtime_createLists the devices the library finds, accelerators first, then the CPU.
  2. turbo_model_loadLoads a bundle: manifest, hashes, weights, tokenizer and settings.
  3. turbo_session_createOpens a session with pooling, normalization, truncation, prompt, precision tier and autotune options.
  4. turbo_embed_write_textWrites text, or token ids with turbo_embed_write_tokens.
  5. turbo_session_runRuns the task on the device.
  6. turbo_result_readReads the vectors, with a report of where each stage ran and the bytes that crossed to the device.

Three tasks

  • TURBO_TASK_EMBED: text or token ids in, one pooled vector per row or per token range out.
  • TURBO_TASK_RERANK: query and passage pairs in, one relevance logit per pair out.
  • TURBO_TASK_EXTRACTIVE_QA: a question and context windows in, start and end logits out, with abstention.

Tokenizer API

The tokenizer is exposed through the same header: encode, encode_pair, encode_spans, decode and count. WordPiece, Unigram, byte-level BPE and SentencePiece .model files are implemented in the library.

turbo_embed_write_ranges pools one vector per token range from a single encoder pass, which gives per-sentence and per-chunk vectors from one run over a document.

# Build the library and run the C example on the CPU
cargo build --release -p turbo
cc -std=c11 -I include docs/setup/embed.c -L target/release -lturbo \
    -Wl,-rpath,$PWD/target/release -o embed
./embed testdata/tiny-bert-bundle 0 model

turbo-kserve: seven services on one port.

The server loads bundles from --model flags and serves these services on the address given to --listen.

ServiceWhat it does
inference.GRPCInferenceServiceKServe v2 Open Inference Protocol: embed, rerank and extractive QA through ModelInfer
turbo.result.v1.AnalysisServiceCapabilities, bundle load and unload, AnalyzeStream, AnalyzeDocumentProgressive, graph and window inspection, chunk projection, and output formats
turbo.search.v1.TurboSearchServiceIn-memory indexes, hybrid search with fusion and reranking, persist and seal, aliases and collections
turbo.training.v1.TurboCatalogServiceThe model zoo catalog, installed models, licence acceptance and streamed installs
turbo.training.v1.TurboTrainingServiceStatic models distilled from a served encoder, and classical components trained from streamed samples
turbo.vocabulary.v1.TurboVocabularyServiceDictionary import, corpus vocabulary learning and download
grpc.health.v1.HealthStandard gRPC health checks

KServe v2 calls

ServerLive, ServerReady, ModelReady, ServerMetadata, ModelMetadata and ModelInfer. A ModelInfer request carries texts as BYTES, or ids, mask and optional types as INT32 tensors, and the reply is a vectors tensor of FP32 with the run’s summary as response parameters.

Serving a model

Each --model is comma-separated key=value settings: bundle, device (cpu, cuda:0, levelzero:0, metal:0, hailo:0, npu:0, or select), sessions, name, precision, max_batch and max_seq. One bundle can be served under two names at two precision tiers.

Security and metrics

The server speaks plaintext gRPC unless given --tls-cert and --tls-key; --tls-client-ca adds mutual TLS. --bearer-token and --admin-bearer-token authorize read and admin calls, and health checks stay open for probes. Calls that change server state need --admin. --metrics-listen serves Prometheus metrics on a separate listener.

# Build a bundle and serve it
cargo run --release -p turbo-bundle -- make \
    minishlab/potion-base-8M \
    upstream/potion-base-8M bundles/potion-base-8M
cargo build --release -p turbo-kserve
target/release/turbo-kserve --listen 127.0.0.1:8081 \
    --model bundle=bundles/potion-base-8M,device=cpu,sessions=2
Server tab of the TurboEmbed workbench listing two served bundles and the analysis profiles default-v1, retrieval-v1, minimal-v1 and annotate-v1 with their steps and layers
Server: the bundles served and the analysis profiles, with the steps and layers of each.

Token input buffers follow the device.

When a request carries token ids, the server copies them into buffers that the session holds. The placement of those buffers depends on the backend.

BackendToken input buffer placement
CPU, CUDA, Level Zero GPU, MetalPinned, page-locked host memory the device can read, TURBO_PLACE_PINNED
Intel NPU, HailoHost memory, TURBO_PLACE_HOST, the placement these backends allocate

Model bundles and the zoo.

A bundle is a directory with a manifest and hashes, the weights, the tokenizer, the model’s settings and reference vectors. The tools around it build, verify and catalog them.

turbo-bundle

Builds a bundle from a recipe: fetches the pinned upstream files, runs the conversion and reference pipeline in pinned containers with no network, writes the manifest, and verifies the result with the library’s own loader. Commands include make, fetch, reference, seal, verify, distill and catalogue.

turbo-zoo

An index of models, heads, lexicons, centroid sets and datasets, each with its licence, attribution and training data. The fetcher refuses an artifact whose licence class has not been accepted.

Catalog service

TurboCatalogService lists the catalog, records licence acceptances and streams installs. A file is handed to a client only when its size and SHA-256 match the catalog.

Models tab of the TurboEmbed workbench listing the built-in model catalog as cards with licences, sizes and install controls
Models: the built-in catalog as cards, with licences, sizes and the terms still to accept.
Embed tab of the TurboEmbed workbench comparing potion-base-8M and potion-base-32M on five texts, with a side-by-side table and a cosine similarity matrix per model
Embed: two static models compared on the same five texts, side by side and each with its own similarity table.

Client libraries and release archives.

Clients in other languages are generated from the protos in server/proto.

PathWhat it is
clients/rustRust client that combines in-process analysis, local libturbo sessions and pooled server calls
clients/pythonGenerated Python gRPC stubs, turboembed-proto
clients/javaGenerated Java gRPC stubs, ai.pipestream:turboembed-grpc
clients/java-apiThe in-process Java API, Java 21 and later
clients/java-panamalibturbo through the Foreign Function and Memory API, Java 25 and later
clients/java-jnilibturbo through JNI, Java 21 and later and Android
Release archiveBackends
linux-x86_64.tar.gzCPU, CUDA and NPU
macos-arm64.tar.gzMetal and CPU
linux-aarch64.tar.gzCPU
windows-x86_64.zipCPU and NPU
android.tar.gzCPU, for the JNI binding
turboembed-proto tar.gzThe .proto files

A v<version> tag builds the archives with SHA-256 sums and also pushes two server images to GHCR: ghcr.io/ai-pipestream/turbo-kserve:<version> (CPU, amd64 and arm64) and :<version>-cuda (CPU and CUDA, amd64).