Serving integrations and row operators#
These entrypoints are explicit process-local opt-ins. Read the SGLang contract before model construction.
Explicit opt-in decode integration for SGLang 0.5.22.
- install_sglang_backend()[source]#
Opt into LoRAForge decode for csgmv in this process; repeatable per worker.
Refuse to overwrite another plugin. Native SGLang owns fixed-address buffers, routing updates, loader synchronization and graph lifetimes.
Experimental vLLM linear decode#
Read the vLLM contract. Registration is inert unless explicitly enabled, pins vLLM 0.26.0 and retains native fallback execution.
Explicit per-worker vLLM 0.26.0 linear decode integration.
- install_vllm_backend(*, tokens_per_lora: int = 4) None[source]#
Experimental API (alpha)
Added in 0.1.0.dev0. Opt-in vLLM 0.26.0 specialized linear decode; synthetic CUDA validation, no model-quality claim. API compatibility is not guaranteed. Review the documented validation limits.
Install in each worker before model construction; repeatable/conflict-aware.
Only specialized dense-linear decode is replaced. Prefill, unspecialized execution, extra keyword contracts and non-linear methods stay native.
Lazy GEMV for padded vLLM slot layouts, independent of vLLM imports.
Routing values must be -1 or valid slot indices. Callers own device metadata validation, input ordering, and fixed-address lifetimes during graph replay.
- shrink(x, weights, out, routes, *, scale=1.0)[source]#
Experimental API (alpha)
Added in 0.1.0.dev0. Inference-only padded-slot GEMV; vLLM 0.26.0 layouts, FP32 intermediates, CUDA validation only. API compatibility is not guaranteed. Review the documented validation limits.
Write FP32 out[slices, tokens, rank] = scale * A[route] @ x.
A is [slots, rank, width] or [slots, 1, rank, width]. Base routes (-1) produce zero. Split-K uses FP32 atomic accumulation, as in the source.
- expand(v, weights, y, routes, *, offset=0, add=True)[source]#
Experimental API (alpha)
Added in 0.1.0.dev0. Inference-only padded-slot GEMV; tolerance-based native parity, not full-model acceptance. API compatibility is not guaranteed. Review the documented validation limits.
Apply B[route] @ v to output slices in place, with FP32 accumulation.
Unlike native vLLM matrix-dot, the source GEMV retains FP32 intermediates before multiplying by B. Numerical parity is tolerance-based, not bitwise. Base-route rows and columns outside the slices remain unchanged, even for add=False, matching native vLLM’s skipped-token behavior.
Experimental retained-rank BF16 row operators#
Read the metadata, rounding and lifetime contract. These tensor operators do not install a serving backend or adapter manager.
BF16 retained-rank shrink and compact-B RowExpand without framework imports.
Device metadata values are trusted inputs: see docs/row-operators.md. Structural validation does not copy metadata to the CPU or synchronize the current stream.
- row_shrink(x: torch.Tensor, a: torch.Tensor, output: torch.Tensor, slots: torch.Tensor, ranks: torch.Tensor, *, num_slices: int = 1, max_rank: int = 64) None[source]#
Experimental API (alpha)
Added in 0.1.0.dev0. BF16 retained-rank inference operator; L40S CUDA validated, caller-owned device metadata. API compatibility is not guaranteed. Review the documented validation limits.
Write live packed A @ x prefixes in place, rounding FP32 sums to BF16.
x is [tokens, width], A [slots, slices * capacity, width], output [tokens, slices * capacity]. For slot rank r, slice s starts at s*r in both A and output. Slots -1 and rank-zero rows are left unchanged; unused output columns are also unchanged. All live ranks must be <=max_rank. Input width and row stride must be multiples of eight BF16 elements.
- row_expand(z: torch.Tensor, b: torch.Tensor, output: torch.Tensor, *, b_offsets: torch.Tensor, b_strides: torch.Tensor, ranks: torch.Tensor, scales: torch.Tensor, segment_indptr: torch.Tensor, segment_slots: torch.Tensor, token_indices: torch.Tensor, slice_offsets: torch.Tensor, segment_count: torch.Tensor, blocks: int | None = None, threads: int = 256) None[source]#
Experimental API (alpha)
Added in 0.1.0.dev0. Compact-B RowExpand; L40S CUDA validated, fixed-address metadata/lifetime contract. API compatibility is not guaranteed. Review the documented validation limits.
Add compact B @ z to BF16 output, reusing B across <=16 token segments.
z is [tokens, slices * capacity], with each live slice packed at s*r. B is flat; b_offsets are element offsets and b_strides are power-of-two row widths in 1..64, at least the corresponding rank. B padding is zero. Each segment has one slot and at most 16 distinct token indices. Tokens occur at most once across active segments. slice_offsets partition output columns; segment_count is a one-element int32 device vector.
FP32 dot products are scaled, rounded to BF16, added to the BF16 base, and rounded again. Rank-zero and slot -1 segments leave output unchanged. Warm the operator before capturing a graph. Callers own all buffer lifetimes and stream ordering, including writes to metadata before replay.