Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e756f61b9a | |||
| 8cb98c84f9 | |||
| e251afda2b | |||
| 74bd932327 |
+16
-25
@@ -26,8 +26,7 @@ from lib.data_types import (
|
|||||||
LogAction,
|
LogAction,
|
||||||
ApiPayload_T,
|
ApiPayload_T,
|
||||||
JsonDataException,
|
JsonDataException,
|
||||||
RequestMetrics,
|
RequestMetrics
|
||||||
BenchmarkResult
|
|
||||||
)
|
)
|
||||||
|
|
||||||
VERSION = "0.1.0"
|
VERSION = "0.1.0"
|
||||||
@@ -286,7 +285,7 @@ class Backend:
|
|||||||
message = {
|
message = {
|
||||||
key: value
|
key: value
|
||||||
for (key, value) in (dataclasses.asdict(auth_data).items())
|
for (key, value) in (dataclasses.asdict(auth_data).items())
|
||||||
if key != "signature" and key != "__request_id"
|
if key != "signature"
|
||||||
}
|
}
|
||||||
if auth_data.reqnum < (self.reqnum - MSG_HISTORY_LEN):
|
if auth_data.reqnum < (self.reqnum - MSG_HISTORY_LEN):
|
||||||
log.debug(
|
log.debug(
|
||||||
@@ -296,7 +295,7 @@ class Backend:
|
|||||||
elif message in self.msg_history:
|
elif message in self.msg_history:
|
||||||
log.debug(f"message: {message} already in message history")
|
log.debug(f"message: {message} already in message history")
|
||||||
return False
|
return False
|
||||||
elif verify_signature(json.dumps(message, indent=4, sort_keys=True), auth_data.signature):
|
elif verify_signature(json.dumps(message, indent=4), auth_data.signature):
|
||||||
self.reqnum = max(auth_data.reqnum, self.reqnum)
|
self.reqnum = max(auth_data.reqnum, self.reqnum)
|
||||||
self.msg_history.append(message)
|
self.msg_history.append(message)
|
||||||
self.msg_history = self.msg_history[-MSG_HISTORY_LEN:]
|
self.msg_history = self.msg_history[-MSG_HISTORY_LEN:]
|
||||||
@@ -315,10 +314,10 @@ class Backend:
|
|||||||
with open(BENCHMARK_INDICATOR_FILE, "r") as f:
|
with open(BENCHMARK_INDICATOR_FILE, "r") as f:
|
||||||
log.debug("already ran benchmark")
|
log.debug("already ran benchmark")
|
||||||
# trigger model load
|
# trigger model load
|
||||||
# payload = self.benchmark_handler.make_benchmark_payload()
|
payload = self.benchmark_handler.make_benchmark_payload()
|
||||||
# _ = await self.__call_api(
|
_ = await self.__call_api(
|
||||||
# handler=self.benchmark_handler, payload=payload
|
handler=self.benchmark_handler, payload=payload
|
||||||
# )
|
)
|
||||||
return float(f.readline())
|
return float(f.readline())
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
@@ -333,26 +332,18 @@ class Backend:
|
|||||||
|
|
||||||
for run in range(1, self.benchmark_handler.benchmark_runs + 1):
|
for run in range(1, self.benchmark_handler.benchmark_runs + 1):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
benchmark_requests = []
|
tasks = []
|
||||||
|
total_workload = 0
|
||||||
|
|
||||||
for i in range(concurrent_requests):
|
for _ in range(concurrent_requests):
|
||||||
payload = self.benchmark_handler.make_benchmark_payload()
|
payload = self.benchmark_handler.make_benchmark_payload()
|
||||||
workload = payload.count_workload()
|
total_workload += payload.count_workload()
|
||||||
task = self.__call_api(handler=self.benchmark_handler, payload=payload)
|
tasks.append(
|
||||||
benchmark_requests.append(
|
self.__call_api(handler=self.benchmark_handler, payload=payload)
|
||||||
BenchmarkResult(request_idx=i, workload=workload, task=task)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
responses = await gather(*[br.task for br in benchmark_requests])
|
responses = await gather(*tasks)
|
||||||
for br, response in zip(benchmark_requests, responses):
|
|
||||||
br.response = response
|
|
||||||
|
|
||||||
total_workload = sum(br.workload for br in benchmark_requests if br.is_successful)
|
|
||||||
time_elapsed = time.time() - start
|
time_elapsed = time.time() - start
|
||||||
successful_responses = sum([1 for br in benchmark_requests if br.is_successful])
|
|
||||||
if successful_responses == 0:
|
|
||||||
self.backend_errored("No successful responses from benchmark")
|
|
||||||
log.debug(f"benchmark failed: {successful_responses}/{concurrent_requests} successful responses")
|
|
||||||
|
|
||||||
throughput = total_workload / time_elapsed
|
throughput = total_workload / time_elapsed
|
||||||
sum_throughput += throughput
|
sum_throughput += throughput
|
||||||
@@ -366,7 +357,7 @@ class Backend:
|
|||||||
f"Run: {run}, concurrent_requests: {concurrent_requests}",
|
f"Run: {run}, concurrent_requests: {concurrent_requests}",
|
||||||
f"Total workload: {total_workload}, time_elapsed: {time_elapsed}s",
|
f"Total workload: {total_workload}, time_elapsed: {time_elapsed}s",
|
||||||
f"Throughput: {throughput} workload/s",
|
f"Throughput: {throughput} workload/s",
|
||||||
f"Successful responses: {successful_responses}/{concurrent_requests}",
|
f"Successful responses: {len([r for r in responses if r.status == 200])}",
|
||||||
"#" * 60,
|
"#" * 60,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -393,7 +384,7 @@ class Backend:
|
|||||||
)
|
)
|
||||||
# some backends need a few seconds after logging successful startup before
|
# some backends need a few seconds after logging successful startup before
|
||||||
# they can begin accepting requests
|
# they can begin accepting requests
|
||||||
# await sleep(5)
|
await sleep(5)
|
||||||
try:
|
try:
|
||||||
max_throughput = await run_benchmark()
|
max_throughput = await run_benchmark()
|
||||||
self.__start_healthcheck = True
|
self.__start_healthcheck = True
|
||||||
|
|||||||
+6
-18
@@ -3,7 +3,7 @@ import logging
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Dict, Any, Union, Tuple, Optional, Set, TypeVar, Generic, Type, Awaitable
|
from typing import Dict, Any, Union, Tuple, Optional, Set, TypeVar, Generic, Type
|
||||||
from aiohttp import web, ClientResponse
|
from aiohttp import web, ClientResponse
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ class ApiPayload(ABC):
|
|||||||
class AuthData:
|
class AuthData:
|
||||||
"""data used to authenticate requester"""
|
"""data used to authenticate requester"""
|
||||||
|
|
||||||
|
signature: str
|
||||||
cost: str
|
cost: str
|
||||||
endpoint: str
|
endpoint: str
|
||||||
reqnum: int
|
reqnum: int
|
||||||
request_idx: int
|
|
||||||
signature: str
|
|
||||||
url: str
|
url: str
|
||||||
|
request_idx: int
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json_msg(cls, json_msg: Dict[str, Any]):
|
def from_json_msg(cls, json_msg: Dict[str, Any]):
|
||||||
@@ -190,12 +190,11 @@ class SystemMetrics:
|
|||||||
self.additional_disk_usage = disk_usage - self.last_disk_usage
|
self.additional_disk_usage = disk_usage - self.last_disk_usage
|
||||||
self.last_disk_usage = disk_usage
|
self.last_disk_usage = disk_usage
|
||||||
|
|
||||||
def reset(self, expected: float | None) -> None:
|
def reset(self):
|
||||||
# autoscaler excepts model_loading_time to be populated only once, when the instance has
|
# autoscaler excepts model_loading_time to be populated only once, when the instance has
|
||||||
# finished benchmarking and is ready to receive requests. This applies to restarted instances
|
# finished benchmarking and is ready to receive requests. This applies to restarted instances
|
||||||
# as well: they should send model_loading_time once when they are done loading
|
# as well: they should send model_loading_time once when they are done loading
|
||||||
if self.model_loading_time == expected:
|
self.model_loading_time = None
|
||||||
self.model_loading_time = None
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -207,17 +206,6 @@ class RequestMetrics:
|
|||||||
status: str
|
status: str
|
||||||
success: bool = False
|
success: bool = False
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class BenchmarkResult:
|
|
||||||
request_idx: int
|
|
||||||
workload: float
|
|
||||||
task: Awaitable[ClientResponse]
|
|
||||||
response: Optional[ClientResponse] = None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_successful(self) -> bool:
|
|
||||||
return self.response is not None and self.response.status == 200
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ModelMetrics:
|
class ModelMetrics:
|
||||||
"""Model specific metrics"""
|
"""Model specific metrics"""
|
||||||
@@ -258,7 +246,7 @@ class ModelMetrics:
|
|||||||
def wait_time(self) -> float:
|
def wait_time(self) -> float:
|
||||||
if (len(self.requests_working) == 0):
|
if (len(self.requests_working) == 0):
|
||||||
return 0.0
|
return 0.0
|
||||||
return sum([request.workload for request in self.requests_working.values()]) / max(self.max_throughput, 0.00001)
|
return sum([request.workload for request in self.requests_working.values()]) / self.max_throughput
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cur_load(self) -> float:
|
def cur_load(self) -> float:
|
||||||
|
|||||||
+15
-50
@@ -145,72 +145,41 @@ class Metrics:
|
|||||||
#######################################Private#######################################
|
#######################################Private#######################################
|
||||||
|
|
||||||
async def __send_delete_requests_and_reset(self):
|
async def __send_delete_requests_and_reset(self):
|
||||||
async def post(report_addr: str, idxs: list[int], success_flag: bool) -> bool:
|
|
||||||
|
async def send_data(report_addr: str, success: bool) -> bool:
|
||||||
data = {
|
data = {
|
||||||
"worker_id": self.id,
|
"worker_id": self.id,
|
||||||
"request_idxs": idxs,
|
"request_idxs": [r.request_idx for r in self.model_metrics.requests_deleting if r.success == success],
|
||||||
"success": success_flag,
|
"success": success
|
||||||
}
|
}
|
||||||
log.debug(
|
|
||||||
f"Deleting requests that {'succeeded' if success_flag else 'failed'}: {data['request_idxs']}"
|
|
||||||
)
|
|
||||||
full_path = report_addr.rstrip("/") + "/delete_requests/"
|
full_path = report_addr.rstrip("/") + "/delete_requests/"
|
||||||
for attempt in range(1, 4):
|
for attempt in range(1, 4):
|
||||||
try:
|
try:
|
||||||
session = await self.http()
|
session = await self.http()
|
||||||
async with session.post(full_path, json=data) as res:
|
async with session.post(full_path, json=data) as res:
|
||||||
log.debug(f"delete_requests response: {res.status}")
|
|
||||||
res.raise_for_status()
|
res.raise_for_status()
|
||||||
return True
|
return True
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
log.debug("delete_requests timed out")
|
log.debug(f"delete_requests timed out")
|
||||||
except (ClientResponseError, Exception) as e:
|
except (ClientResponseError, Exception) as e:
|
||||||
log.debug(f"delete_requests failed with error: {e}")
|
log.debug(f"delete_requests failed with error: {e}")
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
log.debug(f"retrying delete_request, attempt: {attempt}")
|
log.debug(f"retrying delete_request, attempt: {attempt}")
|
||||||
return False
|
|
||||||
|
|
||||||
# Take a snapshot of what we plan to send this tick.
|
|
||||||
# New arrivals after this snapshot will remain in the queue for the next tick.
|
|
||||||
snapshot = list(self.model_metrics.requests_deleting)
|
|
||||||
success_idxs = [r.request_idx for r in snapshot if r.success is True]
|
|
||||||
failed_idxs = [r.request_idx for r in snapshot if r.success is False]
|
|
||||||
|
|
||||||
if not success_idxs and not failed_idxs:
|
|
||||||
return # nothing to do
|
|
||||||
|
|
||||||
for report_addr in self.report_addr:
|
for report_addr in self.report_addr:
|
||||||
# TODO: Add a Redis subscriber queue for delete_requests
|
success = await send_data(report_addr, success=True) and await send_data(report_addr, success=False)
|
||||||
if report_addr == "https://cloud.vast.ai/api/v0":
|
if success is True:
|
||||||
# Patch: ignore the Redis API report_addr
|
self.model_metrics.requests_deleting.clear()
|
||||||
continue
|
|
||||||
sent_success = True
|
|
||||||
sent_failed = True
|
|
||||||
|
|
||||||
if success_idxs:
|
|
||||||
sent_success = await post(report_addr, success_idxs, True)
|
|
||||||
if failed_idxs:
|
|
||||||
sent_failed = await post(report_addr, failed_idxs, False)
|
|
||||||
|
|
||||||
if sent_success and sent_failed:
|
|
||||||
# Remove only the items we actually sent from the live queue.
|
|
||||||
sent_set = set(success_idxs) | set(failed_idxs)
|
|
||||||
self.model_metrics.requests_deleting[:] = [
|
|
||||||
r for r in self.model_metrics.requests_deleting
|
|
||||||
if r.request_idx not in sent_set
|
|
||||||
]
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
async def __send_metrics_and_reset(self):
|
async def __send_metrics_and_reset(self):
|
||||||
|
|
||||||
loadtime_snapshot = self.system_metrics.model_loading_time
|
|
||||||
|
|
||||||
def compute_autoscaler_data() -> AutoScalerData:
|
def compute_autoscaler_data() -> AutoScalerData:
|
||||||
return AutoScalerData(
|
return AutoScalerData(
|
||||||
id=self.id,
|
id=self.id,
|
||||||
version=self.version,
|
version=self.version,
|
||||||
loadtime=(loadtime_snapshot or 0.0),
|
loadtime=(self.system_metrics.model_loading_time or 0.0),
|
||||||
new_load=self.model_metrics.workload_processing,
|
new_load=self.model_metrics.workload_processing,
|
||||||
cur_load=self.model_metrics.cur_load,
|
cur_load=self.model_metrics.cur_load,
|
||||||
rej_load=self.model_metrics.workload_rejected,
|
rej_load=self.model_metrics.workload_rejected,
|
||||||
@@ -258,15 +227,11 @@ class Metrics:
|
|||||||
|
|
||||||
self.system_metrics.update_disk_usage()
|
self.system_metrics.update_disk_usage()
|
||||||
|
|
||||||
sent = False
|
|
||||||
for report_addr in self.report_addr:
|
for report_addr in self.report_addr:
|
||||||
if await send_data(report_addr):
|
success = await send_data(report_addr)
|
||||||
sent = True
|
if success is True:
|
||||||
break
|
break
|
||||||
|
self.update_pending = False
|
||||||
if sent:
|
self.model_metrics.reset()
|
||||||
# clear the one-shot loadtime only if we actually sent *this* value
|
self.system_metrics.reset()
|
||||||
self.system_metrics.reset(expected=loadtime_snapshot)
|
self.last_metric_update = time.time()
|
||||||
self.update_pending = False
|
|
||||||
self.model_metrics.reset()
|
|
||||||
self.last_metric_update = time.time()
|
|
||||||
|
|||||||
@@ -12,21 +12,9 @@ A docker image is provided but you may use any if the above requirements are met
|
|||||||
|
|
||||||
## Benchmarking
|
## Benchmarking
|
||||||
|
|
||||||
### Custom Benchmark Workflows
|
A simple image generation benchmark runs when each worker initializes to validate GPU performance and identify underperforming machines.
|
||||||
|
|
||||||
You can provide a custom ComfyUI workflow for benchmarking by creating `workers/comfyui-json/misc/benchmark.json`. This allows you to test performance using your preferred models and workflow complexity.
|
The benchmark uses Stable Diffusion v1.5 with ComfyUI's default text-to-image workflow. Configure the benchmark complexity and duration using these variables:
|
||||||
|
|
||||||
**Ways to provide the benchmark file:**
|
|
||||||
- Fork this repository and add your `benchmark.json` file
|
|
||||||
- Write the file during worker provisioning (onstart script or setup phase)
|
|
||||||
|
|
||||||
An example file is provided in the repository. To ensure varied generations, use the placeholder `__RANDOM_INT__` in place of static seed values - it will be replaced with a random integer for each benchmark run.
|
|
||||||
|
|
||||||
### Default Benchmark (Fallback)
|
|
||||||
|
|
||||||
If `benchmark.json` is not available, a simple image generation benchmark runs when each worker initializes. This validates GPU performance and helps identify underperforming machines.
|
|
||||||
|
|
||||||
The default benchmark uses Stable Diffusion v1.5 with ComfyUI's standard text-to-image workflow. Configure it using these environment variables:
|
|
||||||
|
|
||||||
| Environment Variable | Default Value | Description |
|
| Environment Variable | Default Value | Description |
|
||||||
| -------------------- | ------------- | ----------- |
|
| -------------------- | ------------- | ----------- |
|
||||||
@@ -36,7 +24,7 @@ The default benchmark uses Stable Diffusion v1.5 with ComfyUI's standard text-to
|
|||||||
|
|
||||||
Each benchmark run uses a random prompt from `misc/test_prompts.txt` and a random seed to ensure consistent GPU load patterns.
|
Each benchmark run uses a random prompt from `misc/test_prompts.txt` and a random seed to ensure consistent GPU load patterns.
|
||||||
|
|
||||||
#### Calibrating Fallback Benchmark Duration
|
### Calibrating Benchmark Duration
|
||||||
|
|
||||||
To screen for underperforming hardware, set `BENCHMARK_TEST_STEPS` to match your expected production workflow duration. This allows you to identify machines that won't meet performance requirements.
|
To screen for underperforming hardware, set `BENCHMARK_TEST_STEPS` to match your expected production workflow duration. This allows you to identify machines that won't meet performance requirements.
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,12 @@ import dataclasses
|
|||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
from functools import cache
|
from functools import cache
|
||||||
from math import ceil
|
from math import ceil
|
||||||
from pathlib import Path
|
|
||||||
import json
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from lib.data_types import ApiPayload, JsonDataException
|
from lib.data_types import ApiPayload, JsonDataException
|
||||||
|
|
||||||
log = logging.getLogger(__file__)
|
|
||||||
|
with open("workers/comfyui/misc/test_prompts.txt", "r") as f:
|
||||||
|
test_prompts = f.readlines()
|
||||||
|
|
||||||
def count_workload() -> float:
|
def count_workload() -> float:
|
||||||
# Always 100.0 where there is a single instance of ComfyUI handling requests
|
# Always 100.0 where there is a single instance of ComfyUI handling requests
|
||||||
@@ -25,32 +24,9 @@ class ComfyWorkflowData(ApiPayload):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def for_test(cls):
|
def for_test(cls):
|
||||||
"""
|
"""
|
||||||
If the user has provided a benchmark workflow we can use it here to properly gauge performance.
|
Use the variables available to simulate workflows of the required running time
|
||||||
Otherwise, use the variables available to simulate workflows of the required running time
|
|
||||||
Example: SD1.5, simple image gen 10000 steps, 512px x 512px will run for approximately 9 minutes @ ~18 it/s (RTX 4090)
|
Example: SD1.5, simple image gen 10000 steps, 512px x 512px will run for approximately 9 minutes @ ~18 it/s (RTX 4090)
|
||||||
"""
|
"""
|
||||||
# Try to load benchmark.json
|
|
||||||
benchmark_file = Path("workers/comfyui-json/misc/benchmark.json")
|
|
||||||
|
|
||||||
if benchmark_file.exists():
|
|
||||||
try:
|
|
||||||
with open(benchmark_file, "r") as f:
|
|
||||||
benchmark_workflow = json.load(f)
|
|
||||||
return cls(
|
|
||||||
input={
|
|
||||||
"request_id": f"test-{random.randint(1000, 99999)}",
|
|
||||||
"workflow_json": benchmark_workflow
|
|
||||||
}
|
|
||||||
)
|
|
||||||
except (json.JSONDecodeError, IOError):
|
|
||||||
# JSON is malformed or file can't be read, fall through to default
|
|
||||||
log.error(f"Failed to benchmark using {benchmark_file}")
|
|
||||||
|
|
||||||
# Fallback: read prompts and construct payload
|
|
||||||
log.info("Using fallback method for benchmarking")
|
|
||||||
with open("workers/comfyui-json/misc/test_prompts.txt", "r") as f:
|
|
||||||
test_prompts = f.readlines()
|
|
||||||
|
|
||||||
test_prompt = random.choice(test_prompts).rstrip()
|
test_prompt = random.choice(test_prompts).rstrip()
|
||||||
return cls(
|
return cls(
|
||||||
input={
|
input={
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
{
|
|
||||||
"3": {
|
|
||||||
"inputs": {
|
|
||||||
"seed": "__RANDOM_INT__",
|
|
||||||
"steps": 20,
|
|
||||||
"cfg": 8,
|
|
||||||
"sampler_name": "euler",
|
|
||||||
"scheduler": "normal",
|
|
||||||
"denoise": 1,
|
|
||||||
"model": [
|
|
||||||
"4",
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"positive": [
|
|
||||||
"6",
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"negative": [
|
|
||||||
"7",
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"latent_image": [
|
|
||||||
"5",
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"class_type": "KSampler",
|
|
||||||
"_meta": {
|
|
||||||
"title": "KSampler"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"4": {
|
|
||||||
"inputs": {
|
|
||||||
"ckpt_name": "v1-5-pruned-emaonly-fp16.safetensors"
|
|
||||||
},
|
|
||||||
"class_type": "CheckpointLoaderSimple",
|
|
||||||
"_meta": {
|
|
||||||
"title": "Load Checkpoint"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"5": {
|
|
||||||
"inputs": {
|
|
||||||
"width": 512,
|
|
||||||
"height": 512,
|
|
||||||
"batch_size": 1
|
|
||||||
},
|
|
||||||
"class_type": "EmptyLatentImage",
|
|
||||||
"_meta": {
|
|
||||||
"title": "Empty Latent Image"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"6": {
|
|
||||||
"inputs": {
|
|
||||||
"text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,",
|
|
||||||
"clip": [
|
|
||||||
"4",
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"class_type": "CLIPTextEncode",
|
|
||||||
"_meta": {
|
|
||||||
"title": "CLIP Text Encode (Prompt)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"7": {
|
|
||||||
"inputs": {
|
|
||||||
"text": "text, watermark",
|
|
||||||
"clip": [
|
|
||||||
"4",
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"class_type": "CLIPTextEncode",
|
|
||||||
"_meta": {
|
|
||||||
"title": "CLIP Text Encode (Prompt)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"8": {
|
|
||||||
"inputs": {
|
|
||||||
"samples": [
|
|
||||||
"3",
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"vae": [
|
|
||||||
"4",
|
|
||||||
2
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"class_type": "VAEDecode",
|
|
||||||
"_meta": {
|
|
||||||
"title": "VAE Decode"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"9": {
|
|
||||||
"inputs": {
|
|
||||||
"filename_prefix": "ComfyUI",
|
|
||||||
"images": [
|
|
||||||
"8",
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"class_type": "SaveImage",
|
|
||||||
"_meta": {
|
|
||||||
"title": "Save Image"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,6 @@ MODEL_SERVER_START_LOG_MSG = "To see the GUI go to: "
|
|||||||
MODEL_SERVER_ERROR_LOG_MSGS = [
|
MODEL_SERVER_ERROR_LOG_MSGS = [
|
||||||
"MetadataIncompleteBuffer", # This error is emitted when the downloaded model is corrupted
|
"MetadataIncompleteBuffer", # This error is emitted when the downloaded model is corrupted
|
||||||
"Value not in list: ", # This error is emitted when the model file is not there at all
|
"Value not in list: ", # This error is emitted when the model file is not there at all
|
||||||
"[ERROR] Provisioning Script failed", # Error inserted by provisioning script if models/nodes fail to download
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -119,25 +119,14 @@ class GenericHandler(EndpointHandler[GenericData], ABC):
|
|||||||
class CompletionsData(GenericData):
|
class CompletionsData(GenericData):
|
||||||
@classmethod
|
@classmethod
|
||||||
def for_test(cls) -> "CompletionsData":
|
def for_test(cls) -> "CompletionsData":
|
||||||
system_prompt = """You are a helpful AI assistant. You have access to the following knowledge base:
|
prompt = " ".join(random.choices(WORD_LIST, k=int(250)))
|
||||||
|
|
||||||
Zebras (US: /ˈziːbrəz/, UK: /ˈzɛbrəz, ˈziː-/)[2] (subgenus Hippotigris) are African equines
|
|
||||||
with distinctive black-and-white striped coats. There are three living species: Grévy's zebra
|
|
||||||
(Equus grevyi), the plains zebra (E. quagga), and the mountain zebra (E. zebra). Zebras share the
|
|
||||||
genus Equus with horses and asses, the three groups being the only living members of the family
|
|
||||||
Equidae. Zebra stripes come in different patterns, unique to each individual. Zebras inhabit eastern
|
|
||||||
and southern Africa and can be found in a variety of habitats such as savannahs, grasslands,
|
|
||||||
woodlands, shrublands, and mountainous areas.
|
|
||||||
|
|
||||||
Please answer the following question based on the above context."""
|
|
||||||
unique_question = " ".join(random.choices(WORD_LIST, k=int(100)))
|
|
||||||
model = os.environ.get("MODEL_NAME")
|
model = os.environ.get("MODEL_NAME")
|
||||||
if not model:
|
if not model:
|
||||||
raise ValueError("MODEL_NAME environment variable not set")
|
raise ValueError("MODEL_NAME environment variable not set")
|
||||||
|
|
||||||
test_input = {
|
test_input = {
|
||||||
"model": model,
|
"model": model,
|
||||||
"prompt": f"{system_prompt}\n\n{unique_question}",
|
"prompt": prompt,
|
||||||
"temperature": 0.7,
|
"temperature": 0.7,
|
||||||
"max_tokens": 500,
|
"max_tokens": 500,
|
||||||
}
|
}
|
||||||
@@ -164,18 +153,7 @@ class ChatCompletionsData(GenericData):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def for_test(cls) -> "ChatCompletionsData":
|
def for_test(cls) -> "ChatCompletionsData":
|
||||||
system_prompt = """You are a helpful AI assistant. You have access to the following knowledge base:
|
prompt = " ".join(random.choices(WORD_LIST, k=int(250)))
|
||||||
|
|
||||||
Zebras (US: /ˈziːbrəz/, UK: /ˈzɛbrəz, ˈziː-/)[2] (subgenus Hippotigris) are African equines
|
|
||||||
with distinctive black-and-white striped coats. There are three living species: Grévy's zebra
|
|
||||||
(Equus grevyi), the plains zebra (E. quagga), and the mountain zebra (E. zebra). Zebras share the
|
|
||||||
genus Equus with horses and asses, the three groups being the only living members of the family
|
|
||||||
Equidae. Zebra stripes come in different patterns, unique to each individual. Zebras inhabit eastern
|
|
||||||
and southern Africa and can be found in a variety of habitats such as savannahs, grasslands,
|
|
||||||
woodlands, shrublands, and mountainous areas.
|
|
||||||
|
|
||||||
Please answer the following question based on the above context."""
|
|
||||||
unique_question = " ".join(random.choices(WORD_LIST, k=int(100)))
|
|
||||||
model = os.environ.get("MODEL_NAME")
|
model = os.environ.get("MODEL_NAME")
|
||||||
if not model:
|
if not model:
|
||||||
raise ValueError("MODEL_NAME environment variable not set")
|
raise ValueError("MODEL_NAME environment variable not set")
|
||||||
@@ -183,10 +161,7 @@ class ChatCompletionsData(GenericData):
|
|||||||
# Chat completions use messages format instead of prompt
|
# Chat completions use messages format instead of prompt
|
||||||
test_input = {
|
test_input = {
|
||||||
"model": model,
|
"model": model,
|
||||||
"messages": [
|
"messages": [{"role": "user", "content": prompt}],
|
||||||
{"role": "system", "content": system_prompt}, # Shared prefix
|
|
||||||
{"role": "user", "content": unique_question} # Unique per request
|
|
||||||
],
|
|
||||||
"temperature": 0.7,
|
"temperature": 0.7,
|
||||||
"max_tokens": 500,
|
"max_tokens": 500,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ def do_one(endpoint_name: str,
|
|||||||
# 1) Check if we got a worker back from route
|
# 1) Check if we got a worker back from route
|
||||||
worker_url = msg.get("url", "")
|
worker_url = msg.get("url", "")
|
||||||
if not worker_url:
|
if not worker_url:
|
||||||
status = msg.get("status", "")
|
|
||||||
m = re.search(r"total workers:\s*(\d+).*loading workers:\s*(\d+).*standby workers:\s*(\d+).*error workers:\s*(\d+)", status, re.I | re.S)
|
m = re.search(r"total workers:\s*(\d+).*loading workers:\s*(\d+).*standby workers:\s*(\d+).*error workers:\s*(\d+)", status, re.I | re.S)
|
||||||
if m:
|
if m:
|
||||||
tot, loading, standby, err = map(int, m.groups())
|
tot, loading, standby, err = map(int, m.groups())
|
||||||
|
|||||||
Reference in New Issue
Block a user