Factor Studios commited on
Commit
c10be9a
·
verified ·
1 Parent(s): 897c760

Update test_ai_integration_http.py

Browse files
Files changed (1) hide show
  1. test_ai_integration_http.py +20 -5
test_ai_integration_http.py CHANGED
@@ -12,12 +12,13 @@ from typing import Any, Optional
12
  import torch
13
  from torch import nn
14
  import torch.nn.functional as F
15
- from torch.overrides import TorchFunctionMode
16
  from PIL import Image
17
  from transformers import (
18
  AutoTokenizer,
19
  AutoModelForCausalLM,
20
- AutoProcessor
 
21
  )
22
  from virtual_vram import VirtualVRAM
23
  from http_storage import HTTPGPUStorage
@@ -113,21 +114,35 @@ def test_ai_integration_http():
113
  logger.info(f"Loading {model_name}")
114
 
115
  try:
 
116
  processor = AutoProcessor.from_pretrained(
117
  model_name,
118
- trust_remote_code=True
 
119
  )
 
 
 
 
 
 
 
 
 
 
120
  model = AutoModelForCausalLM.from_pretrained(
121
  model_name,
122
- trust_remote_code=True
 
 
123
  )
124
- status['processor_loaded'] = True
125
  status['model_loaded'] = True
126
 
127
  # Log model architecture
128
  model_size = get_model_size(model)
129
  logger.info(f"Model loaded: {model_size/1e9:.2f} GB in parameters")
130
  logger.info(f"Model architecture: {model.__class__.__name__}")
 
131
  except Exception as e:
132
  logger.error(f"Model loading failed: {str(e)}")
133
  raise
 
12
  import torch
13
  from torch import nn
14
  import torch.nn.functional as F
15
+ from torch.utils._python_dispatch import TorchFunctionMode
16
  from PIL import Image
17
  from transformers import (
18
  AutoTokenizer,
19
  AutoModelForCausalLM,
20
+ AutoProcessor,
21
+ AutoConfig
22
  )
23
  from virtual_vram import VirtualVRAM
24
  from http_storage import HTTPGPUStorage
 
114
  logger.info(f"Loading {model_name}")
115
 
116
  try:
117
+ # Load processor with direct configuration
118
  processor = AutoProcessor.from_pretrained(
119
  model_name,
120
+ trust_remote_code=True,
121
+ return_tensors="pt"
122
  )
123
+ status['processor_loaded'] = True
124
+
125
+ # Load model with vision config
126
+ from transformers import AutoConfig
127
+ config = AutoConfig.from_pretrained(
128
+ model_name,
129
+ trust_remote_code=True,
130
+ torch_dtype=torch.float32 # Use float32 for better compatibility
131
+ )
132
+
133
  model = AutoModelForCausalLM.from_pretrained(
134
  model_name,
135
+ config=config,
136
+ trust_remote_code=True,
137
+ device_map=None # Don't auto-map devices
138
  )
 
139
  status['model_loaded'] = True
140
 
141
  # Log model architecture
142
  model_size = get_model_size(model)
143
  logger.info(f"Model loaded: {model_size/1e9:.2f} GB in parameters")
144
  logger.info(f"Model architecture: {model.__class__.__name__}")
145
+ logger.info(f"Model config type: {type(config).__name__}")
146
  except Exception as e:
147
  logger.error(f"Model loading failed: {str(e)}")
148
  raise