@@ -13,6 +13,12 @@ import (
1313 "github.com/mudler/xlog"
1414)
1515
16+ var (
17+ totalAvailableVRAM = xsysinfo .TotalAvailableVRAM
18+ getGPUAggregateInfo = xsysinfo .GetGPUAggregateInfo
19+ getSystemRAMInfo = xsysinfo .GetSystemRAMInfo
20+ )
21+
1622// effectiveBasePort returns the port used as base for gRPC backend processes.
1723// Priority: Addr port → ServeAddr port → 50051
1824func (cfg * Config ) effectiveBasePort () int {
@@ -118,7 +124,7 @@ func (cfg *Config) registrationBody() map[string]any {
118124 }
119125
120126 // Detect GPU info for VRAM-aware scheduling
121- totalVRAM , err := xsysinfo . TotalAvailableVRAM ()
127+ totalVRAM , err := totalAvailableVRAM ()
122128 if err != nil {
123129 xlog .Debug ("Failed to detect worker VRAM; registering without GPU capacity" , "error" , err )
124130 }
@@ -179,15 +185,14 @@ func (cfg *Config) registrationBody() map[string]any {
179185 body ["vram_budget" ] = cfg .VRAMBudget
180186 }
181187
182- // If no GPU detected, report system RAM so the scheduler/UI has capacity info
183- if totalVRAM == 0 {
184- ramInfo , err := xsysinfo .GetSystemRAMInfo ()
185- if err != nil {
186- xlog .Debug ("Failed to detect worker RAM for registration" , "error" , err )
187- } else {
188- body ["total_ram" ] = ramInfo .Total
189- body ["available_ram" ] = ramInfo .Available
190- }
188+ // Report system RAM independently from VRAM so both discrete-GPU and
189+ // unified-memory workers expose the capacity visible to the host.
190+ ramInfo , err := getSystemRAMInfo ()
191+ if err != nil {
192+ xlog .Debug ("Failed to detect worker RAM for registration" , "error" , err )
193+ } else {
194+ body ["total_ram" ] = ramInfo .Total
195+ body ["available_ram" ] = ramInfo .Available
191196 }
192197 if cfg .RegistrationToken != "" {
193198 body ["token" ] = cfg .RegistrationToken
@@ -220,20 +225,17 @@ func (cfg *Config) registrationBody() map[string]any {
220225// free capacity.
221226func (cfg * Config ) heartbeatBody () map [string ]any {
222227 body := map [string ]any {}
223- aggregate := xsysinfo . GetGPUAggregateInfo ()
228+ aggregate := getGPUAggregateInfo ()
224229 if aggregate .TotalVRAM > 0 {
225230 body ["available_vram" ] = aggregate .FreeVRAM
226231 }
227232
228- // CPU-only workers (or workers that lost GPU visibility momentarily):
229- // report system RAM so the scheduler still has capacity info.
230- if aggregate .TotalVRAM == 0 {
231- ramInfo , err := xsysinfo .GetSystemRAMInfo ()
232- if err != nil {
233- xlog .Debug ("Failed to detect worker RAM for heartbeat" , "error" , err )
234- } else {
235- body ["available_ram" ] = ramInfo .Available
236- }
233+ // RAM availability changes independently from VRAM on discrete-GPU nodes.
234+ ramInfo , err := getSystemRAMInfo ()
235+ if err != nil {
236+ xlog .Debug ("Failed to detect worker RAM for heartbeat" , "error" , err )
237+ } else {
238+ body ["available_ram" ] = ramInfo .Available
237239 }
238240
239241 // Free disk changes far faster than VRAM under staging traffic (each
0 commit comments