Back to Portal
Phase 01 / Startup & Loading

Startup: Environment

Full Implementation Paths, Physics, and Procedures

01 / Async Sequence Map
            sequenceDiagram
                participant GT as Game Thread
                participant PL as Plugin Layer
                participant K as Kernel (DLL)
                
                GT->>PL: Trigger LoadModel (Multiple Paths)
                Note right of PL: Entering Background AsyncTask
                PL->>K: Physical mmap mapping
                K->>K: Execute GPU VRAM Pre-allocation
                K-->>PL: Return Engine Handle
                PL-->>GT: Broadcast OnModelLoaded Signal
            
02 / Three Implementation Paths

Path A: Raw Static API (Most Flexible)

For performance purists, manual thread and lifecycle management.

// Manual Async Setup
AsyncTask(ENamedThreads::AnyBackgroundThreadNormalTask, [Config]() {
    FLiteRtLmUnrealApi::LoadModel(Config);
});

Path B: Subsystem Driven (Recommended)

Leveraging ULiteRtLmSubsystem for global lifecycle management.

// Load via global singleton, maintains model state automatically
ULiteRtLmSubsystem* Subsystem = GEngine->GetEngineSubsystem<ULiteRtLmSubsystem>();
Subsystem->LoadModel(MyConfig);

Path C: Component Auto-Init (BP Friendly)

Attach ULiteRtLmComponent and check bAutoInit.

// Internal: Component asks Subsystem during BeginPlay: "Is model loaded?" and triggers if needed.
03 / Related Concepts
PHYSICSmmap Zero-Copy

Why is loading a 2GB model instant? We just tell the OS "the file is here," and physical transfer only happens when computation touches the weights.

VRAMVRAM Budget Locking

Once started, the plugin physically reserves MaxNumTokens * stride in VRAM, ensuring stability during long dialogues.