Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Tensorflow Serving servable id h

From Leeroopedia
Knowledge Sources
Domains Model Serving, Core Framework
Last Updated 2026-02-13 00:00 GMT

Overview

ServableId is a lightweight struct that uniquely identifies a servable by its stream name and version number.

Description

The ServableId struct is the fundamental identifier used throughout TensorFlow Serving to reference a specific servable. It consists of two fields: a name string identifying the servable stream (e.g., a model name), and a non-negative version number (of type int64_t) that distinguishes different versions within that stream.

Two servable objects with the same ServableId are considered semantically equivalent regardless of their loaded state. The version number serves a dual purpose: it uniquely identifies a servable object within its stream, and it supports routing requests that specify only a stream name to the version with the highest number.

The header provides comparison operators (==, !=, <), a stream insertion operator for logging, a DebugString() method, and a HashServableId functor that uses Fibonacci hashing (from Knuth's Art of Computer Programming) for high-quality hash distribution suitable for use in unordered containers.

Usage

Use ServableId whenever you need to refer to a specific version of a servable. It is used as a key in maps, as a parameter in Manager and Loader interfaces, and as part of ServableData, ServableState, and ServableHandle types.

Code Reference

Source Location

Signature

struct ServableId {
  string name;
  int64_t version;
  string DebugString() const;
};

struct HashServableId {
  uint64_t operator()(const ServableId& id) const;
};

bool operator==(const ServableId& a, const ServableId& b);
bool operator!=(const ServableId& a, const ServableId& b);
bool operator<(const ServableId& a, const ServableId& b);
std::ostream& operator<<(std::ostream& out, const ServableId& id);

Import

#include "tensorflow_serving/core/servable_id.h"

I/O Contract

Inputs

Name Type Required Description
name string Yes The name of the servable stream (e.g., model name)
version int64_t Yes The version number within the stream; must be non-negative

Outputs

Name Type Description
DebugString() string A human-readable representation such as "{name: my_model version: 3}"
HashServableId uint64_t A high-quality hash value using Fibonacci hashing for use in unordered containers

Usage Examples

Creating and Comparing ServableIds

#include "tensorflow_serving/core/servable_id.h"

using namespace tensorflow::serving;

ServableId id1 = {"my_model", 1};
ServableId id2 = {"my_model", 2};
ServableId id3 = {"my_model", 1};

// Equality comparison
bool same = (id1 == id3);   // true
bool diff = (id1 != id2);   // true

// Ordering (name first, then version)
bool less = (id1 < id2);    // true

// Logging
LOG(INFO) << "Servable: " << id1;  // Outputs: {name: my_model version: 1}

Using ServableId in Unordered Containers

#include "tensorflow_serving/core/servable_id.h"
#include <unordered_map>

using namespace tensorflow::serving;

std::unordered_map<ServableId, int, HashServableId> servable_map;
servable_map[{"model_a", 1}] = 42;

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment