Factor Studios commited on
Commit
e41bfbc
·
verified ·
1 Parent(s): f5fb3d1

Upload 3 files

Browse files
Files changed (3) hide show
  1. ai_http.py +11 -1
  2. test_ai_integration_http.py +1 -1
  3. virtual_vram.py +12 -2
ai_http.py CHANGED
@@ -55,7 +55,17 @@ class AIAccelerator:
55
  if not self.vram:
56
  return True # No VRAM restrictions
57
 
58
- if self._vram_allocated + size_bytes > self.vram.total_size:
 
 
 
 
 
 
 
 
 
 
59
  return False
60
 
61
  self._vram_allocated += size_bytes
 
55
  if not self.vram:
56
  return True # No VRAM restrictions
57
 
58
+ # Check vram_state for unlimited allocation
59
+ if hasattr(self.vram, 'vram_state') and self.vram.vram_state.get('is_unlimited', False):
60
+ self._vram_allocated += size_bytes
61
+ return True
62
+
63
+ # If there's a specific size limit in vram_state
64
+ total_size = float('inf')
65
+ if hasattr(self.vram, 'vram_state'):
66
+ total_size = self.vram.vram_state.get('total_size', float('inf'))
67
+
68
+ if self._vram_allocated + size_bytes > total_size:
69
  return False
70
 
71
  self._vram_allocated += size_bytes
test_ai_integration_http.py CHANGED
@@ -122,7 +122,7 @@ def test_ai_integration_http():
122
  components['chips'].append(chip_for_loading)
123
 
124
  # Initialize VRAM with local storage (unlimited)
125
- vram = VirtualVRAM(storage=storage)
126
  components['vram'] = vram
127
 
128
  # Set up AI accelerator
 
122
  components['chips'].append(chip_for_loading)
123
 
124
  # Initialize VRAM with local storage (unlimited)
125
+ vram = VirtualVRAM(size_gb=None, storage=storage) # Explicitly set unlimited
126
  components['vram'] = vram
127
 
128
  # Set up AI accelerator
virtual_vram.py CHANGED
@@ -15,14 +15,24 @@ class VirtualVRAM:
15
 
16
  # Initialize VRAM state with unlimited capacity
17
  self.vram_state = {
18
- "total_size": float('inf'), # Unlimited size
19
  "allocated": 0,
20
  "blocks": {},
21
  "memory_map": {},
22
- "is_unlimited": True
23
  }
24
  self.store_vram_state()
25
 
 
 
 
 
 
 
 
 
 
 
26
  def store_vram_state(self, max_retries=3):
27
  """Store VRAM state in WebSocket storage with retry logic"""
28
  for attempt in range(max_retries):
 
15
 
16
  # Initialize VRAM state with unlimited capacity
17
  self.vram_state = {
18
+ "total_size": size_gb * 1024 * 1024 * 1024 if size_gb is not None else float('inf'), # Convert GB to bytes or use unlimited
19
  "allocated": 0,
20
  "blocks": {},
21
  "memory_map": {},
22
+ "is_unlimited": size_gb is None
23
  }
24
  self.store_vram_state()
25
 
26
+ @property
27
+ def total_size(self) -> int:
28
+ """Get total VRAM size in bytes"""
29
+ return self.vram_state["total_size"]
30
+
31
+ @property
32
+ def available_size(self) -> int:
33
+ """Get available VRAM size in bytes"""
34
+ return self.vram_state["total_size"] - self.vram_state["allocated"] if not self.vram_state["is_unlimited"] else float('inf')
35
+
36
  def store_vram_state(self, max_retries=3):
37
  """Store VRAM state in WebSocket storage with retry logic"""
38
  for attempt in range(max_retries):