English 中文说明

PHYSICAL ATLAS

Winyunq Industrial Core / API Layer Documentation

Concept 01 / ABI Firewall

Physical Isolation: ABI Firewall

Unreal Engine 5 (User Space) UObject, Blueprints, Game Thread LITERT_LM_WRAPPER.DLL Google SDK (Engine Core) Abseil, Protobuf, Minja, WebGPU void* handle
Physical Contract: The Unreal side only holds void* handles. The lifetime, symbols, and memory layout of all underlying C++ objects are completely hidden by the DLL.
Engineering Advantage: Unreal projects do not need recompilation even if the Google SDK is updated. This solves the "symbol collision" nightmare in large projects.
Concept 02 / KV Cache persistence

Persistence: Multi-Session KV Cache Mapping

GPU VRAM ADDRESS SPACE Model Weights (Frozen) Conv_A (NPC 1) KV Cache Slot 0 Conv_B (NPC 2) Conv_C (NPC 3)
Physical Mapping: Each Conversation handle owns a dedicated physical slice in VRAM of max_num_tokens size.
Instant Response: Switching NPCs only requires passing a different handle to SendChatRequest. TTFT < 100ms.
Concept 03 / Functional API Reference

Functional API Reference (LiteRtLmUnrealApi)

LoadModel(const FLiteRtLmConfig& Config) STATIC

Loads the .tflite model from the specified path and initializes the underlying runtime. Pre-requisite for all inference ops.

Side Effect: GPU VRAM Allocation Return: bool
SendChatRequest(void* SessionKey, const TArray<...>& Messages, ...) STATIC

Sends a chat request. The system compares the history for the SessionKey and only syncs new message chunks (Incremental Sync), significantly boosting speed.

  • Supports automatic Tool Call injection and parsing.
  • Callback OnChunk triggers on Game Thread for UI safety.
ReleaseSession(void* SessionKey) STATIC

Manually releases the KV Cache slot for a specific session. Call when an NPC is destroyed.

GetAutoConfig() STATIC

Probes VRAM via DXGI and generates optimal thread count and KV slot configurations.

Concept 04 / Hardware Mapping

Physical Mapping & Side Effects

Physical Mapping

Weights -> Memory

Model weights are mounted via mmap, avoiding redundant memory copies during cold starts.

Handle -> VRAM

Each void* SessionKey maps to a LlamaIndex, corresponding to a fixed stride offset in VRAM.

System Side Effects

Thread Blocking

The underlying WaitUntilDone is blocking. It is isolated via Unreal's AsyncTask to prevent main thread stalls.

VRAM Pressure

Once loaded, the model occupies several GBs of VRAM. UnloadModel must be called during level transitions.