annotation-studio / flora_speed_entry.py
pepijn223's picture
pepijn223 HF Staff
Enable verified Flora batching: 25 ABC episodes fully exported in 15m24s
4595804 verified
Raw History Blame Contribute Delete
1.33 kB
"""GPU benchmark entry: validate code identity before loading weights or writing data."""
import hashlib
import json
import os
import time
from pathlib import Path
def main():
folder = Path(__file__).parent
for name, expected in json.loads(os.environ["FLORA_EXPECTED_CODE"]).items():
if Path(name).name != name or hashlib.sha256((folder / name).read_bytes()).hexdigest() != expected:
raise RuntimeError("Flora image differs from the approved benchmark code")
if os.environ.get("FLORA_EXECUTION") != "accelerated":
raise RuntimeError("Benchmark must use the explicit accelerated profile")
if os.environ.get("FLORA_VISION_FRAME_BATCHING") == "1":
from flora_vision import verify_cuda_batching
print(
"FLORA_RUNTIME " + json.dumps({"event": "vision_sdpa_cuda_check", **verify_cuda_batching()}),
flush=True,
)
os.environ["ANNOTATION_DEADLINE_EPOCH"] = str(time.time() + int(os.environ["FLORA_RUNTIME_SECONDS"]) - 60)
from worker import run
manifest = json.loads(os.environ["ANNOTATION_MANIFEST"])
if manifest["provider_required"] or manifest["features"] != ["Subtasks"]:
raise RuntimeError("Speed benchmark must be independent native Flora subtasks")
run(manifest)
if __name__ == "__main__":
main()