Restore benchmark.json loading in comfyui-json worker
The "Use PyWorker SDK" rewrite (4380d98) replaced the dynamic
ComfyWorkflowData.for_test() benchmark logic with a hardcoded list of 11
SD1.5 Text2Image payloads, dropped misc/benchmark.json.example and
misc/test_prompts.txt, and stopped honouring the BENCHMARK_TEST_*
environment variables. The README's documented behaviour (custom
workflow via benchmark.json, env-var-tuned fallback) had no
implementation behind it.
Restore the original two-tier behaviour against the new SDK by passing
BenchmarkConfig(generator=make_benchmark_payload) instead of a static
dataset, splitting the load logic into a custom-workflow path and a
fallback path, and re-shipping the misc/ assets.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
cartoon character of a person with a hoodie , in style of cytus and deemo, ork, gold chains, realistic anime cat, dripping black goo, lineage revolution style, thug life, cute anthropomorphic bunny, balrog, arknights, aliased, very buff, black and red and yellow paint, painting illustration collage style, character composition in vector with white background
|
||||||
|
stardew valley, fine details
|
||||||
|
2D Vector Illustration of a child with soccer ball Art for Sublimation, Design Art, Chrome Art, Painting and Stunning Artwork, Highly Detailed Digital Painting, Airbrush Art, Highly Detailed Digital Artwork, Dramatic Artwork, stained antique yellow copper paint, digital airbrush art, detailed by Mark Brooks, Chicano airbrush art, Swagger! snake Culture
|
||||||
|
realistic futuristic city-downtown with short buildings, sunset
|
||||||
|
seascape by Ray Collins and artgerm, front view of a perfect wave, sunny background, ultra detailed water
|
||||||
|
inspired by realflow-cinema4d editor features, create image of a transparent luxury cup with ice fruits and mint, connected with white, yellow and pink cream, Slow - High Speed MO Photography, YouTube Video Screenshot, Abstract Clay, Transparent Cup , molecular gastronomy, wheel, 3D fluid,Simulation rendering, still video, 4k polymer clay futras photography, very surreal, Houdini Fluid Simulation, hyperrealistic CGI and FLUIDS & MULTIPHYSICS SIMULATION effect, with Somali Stain Lurex, Metallic Jacquard, Gold Thread, Mulberry Silk, Toub Saree, Warm background, a fantastic image worthy of an award.
|
||||||
|
biker with backpack on his back riding a motorcycle, Style by Ade Santora, Oilpunk, Cover photo, craig mullins style, on the cover of a magazine, Outdoor Magazine, inspired by Alex Petruk APe, image of a male biker, Cover of an award-winning magazine, the man has a backpack, photo for magazine, with a backpack, magazine cover
|
||||||
|
generate a collage-style illustration inspired by the Procreate raster graphic editor, photographic illustration with the theme, 2D vector, art for textile sublimation, containing surrealistic cartoon cat wearing a baseball cap and jeans standing in front of a poster, inspired by Sadao Watanabe, Doraemon, Japanese cartoon style, Eichiro Oda, Iconic high detail character, Director: Nakahara Nantenbō, Kastuhiro Otomo, image detailed, by Miyamoto, Hidetaka Miyazaki, Katsuhiro illustration, 8k, masterpiece, Minimize noise and grain in photo quality without lose quality and increase brightness and lighting,Symmetry and Alignment, Avoid asymmetrical shapes and out-of-focus points. Focus and Sharpness: Make sure the image is focused and sharp and encourages the viewer to see it as a work of art printed on fabric.
|
||||||
|
fantasy medieval village world inside a glass sphere , high detail, fantasy, realistic, light effect, hyper detail, volumetric lighting, cinematic, macro, depth of field, blur, red light and clouds from the back, highly detailed epic cinematic concept art cg render made in maya, blender and photoshop, octane render, excellent composition, dynamic dramatic cinematic lighting, aesthetic, very inspirational, world inside a glass sphere by james gurney by artgerm with james jean, joe fenton and tristan eaton by ross tran, fine details
|
||||||
|
Iron Man, (Arnold Tsang, Toru Nakayama), Masterpiece, Studio Quality, 6k , toa, toaair, 1boy, glowing, axe, mecha, science_fiction, solo, weapon, jungle , green_background, nature, outdoors, solo, tree, weapon, mask, dynamic lighting, detailed shading, digital texture painting
|
||||||
|
(Pope Francis) wearing leather jacket is a DJ in a nightclub, mixing live on stage, giant mixing table, a masterpiece
|
||||||
|
Pope Francis wearing biker (leather jacket), a masterpiece
|
||||||
|
Luke Skywalker ordering a burger and fries from the Death Star canteen.
|
||||||
|
I want to generate a group avatar for a Feishu group chat. The role of this group is daily software technical communication. Now the subject technology stacks that members of this group discuss daily include: algorithms, data structures, optimization, functional programming, and the programming languages often discussed are: TypeScript, Java, python, etc. I hope this avatar has a simple aesthetic, this avatar is a single person avatar
|
||||||
|
portrait Anime black girl cute-fine-face, pretty face, realistic shaded Perfect face, fine details. Anime. realistic shaded lighting by Ilya Kuvshinov Giuseppe Dangelico Pino and Michael Garmash and Rob Rey, IAMAG premiere, WLOP matte print, cute freckles, masterpiece
|
||||||
|
young Disney socialite wearing a beige miniskirt, dark brown turtleneck sweater, small neckless, cute-fine-face, anime. illustration, realistic shaded perfect face, brown hair, grey eyes, fine details, realistic shaded lighting by ilya kuvshinov giuseppe dangelico pino and michael garmash and rob rey, iamag premiere, wlop matte print, a masterpiece
|
||||||
|
Cute small cat sitting in a movie theater eating chicken wiggs watching a movie ,unreal engine, cozy indoor lighting, artstation, detailed, digital painting,cinematic,character design by mark ryden and pixar and hayao miyazaki, unreal 5, daz, hyperrealistic, octane render
|
||||||
|
Cute small dog sitting in a movie theater eating popcorn watching a movie ,unreal engine, cozy indoor lighting, artstation, detailed, digital painting,cinematic,character design by mark ryden and pixar and hayao miyazaki, unreal 5, daz, hyperrealistic, octane render
|
||||||
|
fox bracelet made of buckskin with fox features, rich details, fine carvings, studio lighting
|
||||||
|
crane buckskin bracelet with crane features, rich details, fine carvings, studio lighting
|
||||||
|
london luxurious interior living-room, light walls
|
||||||
|
Parisian luxurious interior penthouse bedroom, dark walls, wooden panels
|
||||||
|
cute girl, crop-top, blond hair, black glasses, stretching, with background by greg rutkowski makoto shinkai kyoto animation key art feminine mid shot
|
||||||
|
houses in front, houses background, straight houses, digital art, smooth, sharp focus, gravity falls style, doraemon style, shinchan style, anime style
|
||||||
|
Simplified technical drawing, Leonardo da Vinci, Mechanical Dinosaur Skeleton, Minimalistic annotations, Hand-drawn illustrations, Basic design and engineering, Wonder and curiosity
|
||||||
|
High quality 8K painting impressionist style of a Japanese modern city street with a girl on the foreground wearing a traditional wedding dress with a fox mask, staring at the sky, daylight
|
||||||
|
a landscape from the Moon with the Earth setting on the horizon, realistic, detailed
|
||||||
|
Isometric Atlantis city,great architecture with columns, great details, ornaments,seaweed, blue ambiance, 3D cartoon style, soft light, 45° view
|
||||||
|
A hyper realistic avatar of a guy riding on a black honda cbr 650r in leather suit,high detail, high quality,8K,photo realism
|
||||||
|
the street of amedieval fantasy town, at dawn, dark, highly detailed
|
||||||
|
overwhelmingly beautiful eagle framed with vector flowers, long shiny wavy flowing hair, polished, ultra detailed vector floral illustration mixed with hyper realism, muted pastel colors, vector floral details in background, muted colors, hyper detailed ultra intricate overwhelming realism in detailed complex scene with magical fantasy atmosphere, no signature, no watermark
|
||||||
|
a highly detailed matte painting of a man on a hill watching a rocket launch in the distance by studio ghibli, makoto shinkai, by artgerm, by wlop, by greg rutkowski, volumetric lighting, octane render, 4 k resolution, trending on artstation, masterpiece | hyperrealism| highly detailed| insanely detailed| intricate| cinematic lighting| depth of field
|
||||||
|
electronik robot and ofice ,unreal engine, cozy indoor lighting, artstation, detailed, digital painting,cinematic,character design by mark ryden and pixar and hayao miyazaki, unreal 5, daz, hyperrealistic, octane render
|
||||||
|
exquisitely intricately detailed illustration, of a small world with a lake and a rainbow, inside a closed glass jar.
|
||||||
@@ -1,15 +1,35 @@
|
|||||||
|
"""ComfyUI worker for the vast.ai PyWorker SDK.
|
||||||
|
|
||||||
|
Each worker runs a benchmark on warm-up. The payload is selected as follows:
|
||||||
|
|
||||||
|
1. If ``misc/benchmark.json`` exists, it is used as a custom ComfyUI
|
||||||
|
workflow (recommended: match the workflow your endpoint will actually
|
||||||
|
serve, so the autoscaler's performance estimate is meaningful).
|
||||||
|
2. Otherwise an SD1.5 Text2Image fallback runs, parameterised by the
|
||||||
|
``BENCHMARK_TEST_{WIDTH,HEIGHT,STEPS}`` env vars and a random prompt
|
||||||
|
from ``misc/test_prompts.txt``.
|
||||||
|
|
||||||
|
``__RANDOM_INT__`` placeholders in custom workflows are substituted
|
||||||
|
server-side by ai-dock/comfyui-api-wrapper, so this worker does not handle
|
||||||
|
them itself.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from vastai import Worker, WorkerConfig, HandlerConfig, LogActionConfig, BenchmarkConfig
|
from vastai import Worker, WorkerConfig, HandlerConfig, LogActionConfig, BenchmarkConfig
|
||||||
|
|
||||||
# ComyUI model configuration
|
# ComfyUI model configuration
|
||||||
MODEL_SERVER_URL = 'http://127.0.0.1'
|
MODEL_SERVER_URL = 'http://127.0.0.1'
|
||||||
MODEL_SERVER_PORT = 18288
|
MODEL_SERVER_PORT = 18288
|
||||||
MODEL_LOG_FILE = '/var/log/portal/comfyui.log'
|
MODEL_LOG_FILE = '/var/log/portal/comfyui.log'
|
||||||
MODEL_HEALTHCHECK_ENDPOINT = "/health"
|
MODEL_HEALTHCHECK_ENDPOINT = "/health"
|
||||||
|
|
||||||
# ComyUI-specific log messages
|
# ComfyUI-specific log messages
|
||||||
MODEL_LOAD_LOG_MSG = [
|
MODEL_LOAD_LOG_MSG = [
|
||||||
"To see the GUI go to: "
|
"To see the GUI go to: "
|
||||||
]
|
]
|
||||||
@@ -24,37 +44,63 @@ MODEL_INFO_LOG_MSGS = [
|
|||||||
'"message":"Downloading'
|
'"message":"Downloading'
|
||||||
]
|
]
|
||||||
|
|
||||||
benchmark_prompts = [
|
# Benchmark assets shipped alongside this worker. Resolved relative to this
|
||||||
"Cartoon hoodie hero; orc, anime cat, bunny; black goo; buff; vector on white.",
|
# file so the worker keeps working regardless of the launch cwd.
|
||||||
"Cozy farming-game scene with fine details.",
|
MISC_DIR = Path(__file__).parent / "misc"
|
||||||
"2D vector child with soccer ball; airbrush chrome; swagger; antique copper.",
|
BENCHMARK_FILE = MISC_DIR / "benchmark.json"
|
||||||
"Realistic futuristic downtown of low buildings at sunset.",
|
TEST_PROMPTS = MISC_DIR / "test_prompts.txt"
|
||||||
"Perfect wave front view; sunny seascape; ultra-detailed water; artful feel.",
|
|
||||||
"Clear cup with ice, fruit, mint; creamy swirls; fluid-sim CGI; warm glow.",
|
log = logging.getLogger(__name__)
|
||||||
"Male biker with backpack on motorcycle; oilpunk; award-worthy magazine cover.",
|
|
||||||
"Collage for textile; surreal cartoon cat in cap/jeans before poster; crisp.",
|
|
||||||
"Medieval village inside glass sphere; volumetric light; macro focus.",
|
|
||||||
"Iron Man with glowing axe; mecha sci-fi; jungle scene; dynamic light.",
|
|
||||||
"Pope Francis DJ in leather jacket, mixing on giant console; dramatic.",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
|
def _custom_workflow_payload() -> dict | None:
|
||||||
|
"""Build a payload from ``misc/benchmark.json``, or None if unavailable."""
|
||||||
|
if not BENCHMARK_FILE.exists():
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
with open(BENCHMARK_FILE) as f:
|
||||||
|
workflow = json.load(f)
|
||||||
|
except (json.JSONDecodeError, OSError) as e:
|
||||||
|
log.error("Failed to load %s: %s; falling back to default benchmark", BENCHMARK_FILE, e)
|
||||||
|
return None
|
||||||
|
log.info("Using custom benchmark workflow from %s", BENCHMARK_FILE)
|
||||||
|
return {
|
||||||
|
"input": {
|
||||||
|
"request_id": f"test-{random.randint(1000, 99999)}",
|
||||||
|
"workflow_json": workflow,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
benchmark_dataset = [
|
|
||||||
{
|
def _default_payload() -> dict:
|
||||||
|
"""Build the SD1.5 Text2Image fallback payload."""
|
||||||
|
with open(TEST_PROMPTS) as f:
|
||||||
|
prompts = [line.strip() for line in f if line.strip()]
|
||||||
|
return {
|
||||||
"input": {
|
"input": {
|
||||||
"request_id": f"test-{random.randint(1000, 99999)}",
|
"request_id": f"test-{random.randint(1000, 99999)}",
|
||||||
"modifier": "Text2Image",
|
"modifier": "Text2Image",
|
||||||
"modifications": {
|
"modifications": {
|
||||||
"prompt": prompt,
|
"prompt": random.choice(prompts),
|
||||||
"width": 512,
|
"width": int(os.getenv("BENCHMARK_TEST_WIDTH", 512)),
|
||||||
"height": 512,
|
"height": int(os.getenv("BENCHMARK_TEST_HEIGHT", 512)),
|
||||||
"steps": 20,
|
"steps": int(os.getenv("BENCHMARK_TEST_STEPS", 20)),
|
||||||
"seed": random.randint(0, sys.maxsize)
|
"seed": random.randint(0, sys.maxsize),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} for prompt in benchmark_prompts
|
}
|
||||||
]
|
|
||||||
|
|
||||||
|
def make_benchmark_payload() -> dict:
|
||||||
|
"""Build one benchmark request payload.
|
||||||
|
|
||||||
|
Called once per benchmark run by the SDK; using a generator (rather
|
||||||
|
than a static ``dataset=``) lets each run re-pick a prompt and re-roll
|
||||||
|
the seed, and avoids holding multiple copies of a large workflow JSON
|
||||||
|
in memory.
|
||||||
|
"""
|
||||||
|
return _custom_workflow_payload() or _default_payload()
|
||||||
|
|
||||||
|
|
||||||
worker_config = WorkerConfig(
|
worker_config = WorkerConfig(
|
||||||
model_server_url=MODEL_SERVER_URL,
|
model_server_url=MODEL_SERVER_URL,
|
||||||
@@ -67,7 +113,7 @@ worker_config = WorkerConfig(
|
|||||||
allow_parallel_requests=False,
|
allow_parallel_requests=False,
|
||||||
max_queue_time=10.0,
|
max_queue_time=10.0,
|
||||||
benchmark_config=BenchmarkConfig(
|
benchmark_config=BenchmarkConfig(
|
||||||
dataset=benchmark_dataset,
|
generator=make_benchmark_payload,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user