Last updated: 2026-07-19
Inference Runtime
Batching
Tenant-aware batch planning for ZINC_RT.
This module owns admission, quotas, and prefill/decode batch selection. It is intentionally independent of the current host-assisted `forward_zinc_rt` execution path so it can be validated before the M3 continuous-batching executor consumes it.
9 exports shown
constant
TenantId
pub const TenantId = u32 Stable tenant identifier supplied by the API/server layer.
constant
RequestId
pub const RequestId = u64 Monotonic request identifier assigned at admission.
struct
TenantLimits
pub const TenantLimits = struct Per-tenant admission and scheduling limits.
struct
RequestConfig
pub const RequestConfig = struct Request metadata needed by the ZINC_RT batch planner.
enum
RequestState
pub const RequestState = enum Lifecycle tracked by the ZINC_RT batch planner.
struct
Slot
pub const Slot = struct One request slot in the multitenant planner.
enum
BatchKind
pub const BatchKind = enum Type of work represented by a batch entry.
struct
BatchEntry
pub const BatchEntry = struct One request inside a selected prefill or decode batch.
struct
BatchScheduler
pub const BatchScheduler = struct Fixed-capacity multitenant scheduler for ZINC_RT prefill/decode batches.
Methods
12method
BatchScheduler.init
pub fn init(allocator: std.mem.Allocator, max_slots: u32, max_tenants: u32) !BatchScheduler Initialize a fixed-capacity scheduler.
method
BatchScheduler.registerTenant
pub fn registerTenant(self: *BatchScheduler, tenant_id: TenantId, limits: TenantLimits) !void Register or update limits for a tenant.
method
BatchScheduler.submit
pub fn submit(self: *BatchScheduler, config: RequestConfig) !u32 Submit a request into the first free slot.
method
BatchScheduler.selectPrefillBatch
pub fn selectPrefillBatch(self: *BatchScheduler, out: []BatchEntry, max_prompt_tokens: u32) []BatchEntry Select queued/prefilling requests for prompt prefill.
method
BatchScheduler.advancePrefill
pub fn advancePrefill(self: *BatchScheduler, slot_id: u32, tokens: u32) !void Account for completed prompt work.
method
BatchScheduler.selectDecodeBatch
pub fn selectDecodeBatch(self: *BatchScheduler, out: []BatchEntry, max_slots: u32) []BatchEntry Select active decode requests fairly across slots and tenant limits.
method
BatchScheduler.recordDecodeToken
pub fn recordDecodeToken(self: *BatchScheduler, slot_id: u32) !void Account for one generated decode token.
method
BatchScheduler.cancel
pub fn cancel(self: *BatchScheduler, slot_id: u32) !void Mark a request as cancelled.
method
BatchScheduler.release
pub fn release(self: *BatchScheduler, slot_id: u32) void Release a completed or cancelled slot.
method
BatchScheduler.activeCount
pub fn activeCount(self: *const BatchScheduler) u32 Number of occupied request slots.
method
BatchScheduler.tenantActiveCount
pub fn tenantActiveCount(self: *const BatchScheduler, tenant_id: TenantId) u32 Number of live requests owned by `tenant_id`.
method
BatchScheduler.deinit
pub fn deinit(self: *BatchScheduler) void Free all planner storage.