Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into per-tier-winner
Browse files Browse the repository at this point in the history
  • Loading branch information
MsRandom committed Oct 22, 2024
2 parents 71ec576 + ee09a3f commit ef68d8b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
5 changes: 3 additions & 2 deletions miner/miner/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
make_submission,
random_inputs,
ModelRepositoryInfo,
BaselineBenchmark,
TextToImageRequest,
MetricData,
GenerationOutput,
BENCHMARKS_VERSION,
)

from neuron.submission_tester import (
generate_baseline,
compare_checkpoints,
BaselineBenchmark,
MetricData,
)

VALID_PROVIDER_REGEX = r'^[a-zA-Z0-9-.]+$'
Expand Down
1 change: 0 additions & 1 deletion neuron/neuron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
from .config import *
from .contest import *
from .random_inputs import *
from .submission_tester import *
2 changes: 1 addition & 1 deletion neuron/neuron/submission_tester/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from pydantic import BaseModel

from neuron import GenerationOutput
from pipelines import TextToImageRequest
from .. import GenerationOutput

SIMILARITY_SCORE_THRESHOLD = 0.8

Expand Down
40 changes: 25 additions & 15 deletions neuron/neuron/submission_tester/testing.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import logging
from collections.abc import Iterable
from concurrent.futures import ThreadPoolExecutor, CancelledError
from io import BytesIO
from pathlib import Path
from statistics import mean
from threading import Event
from time import perf_counter

from neuron import (
from pipelines import TextToImageRequest
from . import InvalidSubmissionError
from .inference_sandbox import InferenceSandbox
from .metrics import CheckpointBenchmark, MetricData, BaselineBenchmark
from .vram_monitor import VRamMonitor
from .. import (
GenerationOutput,
ModelRepositoryInfo,
CURRENT_CONTEST,
Key, OutputComparator,
Key,
OutputComparator,
)
from pipelines import TextToImageRequest
from .inference_sandbox import InferenceSandbox
Expand Down Expand Up @@ -107,23 +114,26 @@ def compare_checkpoints(
with InferenceSandbox(submission, False, sandbox_directory, switch_user, cache) as sandbox:
size = sandbox.model_size

f"Take {len(inputs)} samples, keeping track of how fast/accurate generations have been"
for index, request in enumerate(inputs):
logger.info(f"Sample {index + 1}, prompt {request.prompt} and seed {request.seed}")
try:
f"Take {len(inputs)} samples, keeping track of how fast/accurate generations have been"
for index, request in enumerate(inputs):
logger.info(f"Sample {index + 1}, prompt {request.prompt} and seed {request.seed}")

if cancelled_event and cancelled_event.is_set():
raise CancelledError()
if cancelled_event and cancelled_event.is_set():
raise CancelledError()

output = generate(sandbox, request)
output = generate(sandbox, request)

logger.info(
f"Sample {index + 1} Generated\n"
f"Generation Time: {output.generation_time}s\n"
f"VRAM Usage: {output.vram_used}b\n"
f"Power Usage: {output.watts_used}W"
)
logger.info(
f"Sample {index + 1} Generated\n"
f"Generation Time: {output.generation_time}s\n"
f"VRAM Usage: {output.vram_used}b\n"
f"Power Usage: {output.watts_used}W"
)

outputs.append(output)
outputs.append(output)
except Exception as e:
raise InvalidSubmissionError(f"Failed to run inference on {submission}") from e

average_time = sum(output.generation_time for output in outputs) / len(outputs)
vram_used = max(output.vram_used for output in outputs)
Expand Down
2 changes: 1 addition & 1 deletion neuron/neuron/submission_tester/vram_monitor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import threading
import time

from neuron import Contest
from .. import Contest

POLL_RATE_SECONDS = 0.1

Expand Down
2 changes: 1 addition & 1 deletion validator/base_validator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .metrics import *

API_VERSION = "4.2.0"
API_VERSION = "4.2.1"
2 changes: 1 addition & 1 deletion validator/submission_tester/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
MetricData,
compare_checkpoints,
generate_baseline,
InvalidSubmissionError,
)

from neuron import (
Key,
ModelRepositoryInfo,
TIMEZONE,
random_inputs,
InvalidSubmissionError,
)
from pipelines import TextToImageRequest

Expand Down

0 comments on commit ef68d8b

Please sign in to comment.