Skip to content

Release 2.0.0#124

Merged
dylanuys merged 55 commits intomainfrom
testnet
Dec 5, 2024
Merged

Release 2.0.0#124
dylanuys merged 55 commits intomainfrom
testnet

Conversation

@dylanuys
Copy link
Contributor

@dylanuys dylanuys commented Dec 5, 2024

Release 2.0.0 - Video Challenges V1

Validator Update Steps

  • Ensure you are running on a machine that meets the requirements specified in min_compute.yaml
    • Note the 80 GB VRAM GPU and recommended 600 GB storage
  • If on autoupdate, no other action needed
  • If not on autoupdate, run:
git pull
./setup_env.sh

pm2 delete bitmind_validator
pm2 delete run_neuron  # if using our run script

pm2 start run_neuron.py -- --validator

If you wish to turn off autoupdate or self healing restarts, you can instead start your validator with either

pm2 start run_neuron.py -- --validator --no-auto-update --no-self-heal

or

./start_validator.sh

NOTE Our startup script run_neuron.py (which calls start_validator.py, which is responsible for spawning the pm2 processes) now starts the processes shown below.
Do not manually run neruons/validator.py

┌────┬───────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name                      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├────┼───────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 2  │ bitmind_cache_updater     │ default     │ N/A     │ fork    │ 3354129  │ 14s    │ 0    │ online    │ 0%       │ 1.7gb    │ user     │ disabled │
│ 3  │ bitmind_data_generator    │ default     │ N/A     │ fork    │ 3354163  │ 13s    │ 0    │ online    │ 0%       │ 1.8gb    │ user     │ disabled │
│ 1  │ bitmind_validator         │ default     │ N/A     │ fork    │ 3354098  │ 15s    │ 0    │ online    │ 0%       │ 1.8gb    │ user     │ disabled │
│ 0  │ run_neuron                │ default     │ N/A     │ fork    │ 3353994  │ 52s    │ 0    │ online    │ 0%       │ 10.5mb   │ user     │ disabled │
└────┴───────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
  • run_neuron manages self-heal restarts and auto-update
  • bitmind_validator is your validator process
  • bitmind_data_generator is populating ~/.cache/sn34/synthetic with outputs from text-to-video and text-to-image models. This is the only sn34 validator process that uses GPU
  • bitmind_cache_updater manages the cache of real images and videos at ~/.cache/sn34/real

Miner Update Steps

  • For deployed miner instances, no immediate action is required
  • For orientation around video detection model training and deployment, please see the Miner Updates section below
  • Note that reward distribution will initially be split 90% to image challenges, 10% to video challenges to allow miners the opportunity to iterate without being significantly impacted.

Overview

v2.0.0 features our initial version of video challenges with three text-to-video models, and two large real video datasets amounting to nearly 10TB of video data. It also contains significant refactors of core subnet components, with an emphasis on our approach to sampling and generating data for validator challenges. More on this below.

It also includes code to train and deploy a deepfake video detection model called TALL (whitepaper) as a SN34 miner.

Reward distribution will initially be split 90% to image challenges, 10% to video challenges. This is meant to allow miners the freedom to explore and experiment with different video detection models without a significant on incentive distribution, while still allowing high video performance to provide upward mobility.

To test miner generalizability, video challenges include (chronologically ordered) random set of video frames sampled at a variable frame rate. Frames are extracted with a png codec, with randomly applied jpeg compression as part of our pre-existing augmentation pipeline

This release corresponds to our initial version of video challenges. Upcoming future releases will include:

  • Improved output quality from existing text-to-video models
  • Additional SoTA text-to-video models, like open-sora
  • Additional real image dataset sources
  • Improved VideoSynapse efficiency

Models

https://huggingface.co/genmo/mochi-1-preview
https://huggingface.co/THUDM/CogVideoX-5b
https://huggingface.co/ByteDance/AnimateDiff-Lightning

Datasets

Initial selection for providing real videos. More to come, these are subject to change.
https://huggingface.co/datasets/nkp37/OpenVid-1M
https://huggingface.co/datasets/shangxd/imagenet-vidvrd

Replacement of open-image-v7 URL dataset with 256x256 JPEG subset (1.9M images).
https://huggingface.co/datasets/bitmind/open-image-v7-256

Miner Updates

TALLDetector + VideoDataset

Model Training

  • Miners can use base_miner/datasets/create_video_dataset.py (example usage in create_videos_dataset_example.sh) to transform a directory of mp4 files into a train-ready video frames dataset. This involves extracting individual frames from the mp4s and creating a local Huggingface dataset to reference the extracted frames during training.

Miner Deployment

  • miner.env now has separate env vars for configuring both an image detection model and a video detection model.
  • These models reside within the same miner process listening on the single miner axon port, and respectively respond to requests of type ImageSynapse and VideoSynapse.

Validator Optimizations and Refactors

SyntheticDataGenerator

  • Formerly known as SyntheticImageGenerator, this class handles generation of videos in addition to its original functionality of prompt and image generation
  • New functionality to run independently of the validator, continually generating and caching new synthetic video and images in ~/.cache/sn34/synthetic.
    • start_validator.sh now starts an additional pm2 process called bitmind_data_generator
    • This is an improvement over the previous "as-needed" approach to synthetic data generation, providing greater flexibility and higher generation throughput

ImageAnnotationGenerator

  • Simplified, stripped of utility code used internally by the BitMind team for full synthetic dataset generation. The utility code will be updated and moved to our bitmind-utils repository

ImageCache and VideoCache

  • Two new classes are introduced to reduce storage requirements for validators (given that the video files from OpenVid-1m alone takes up several TB)
  • These classes are used to keep a fresh cache of compressed data sources (parquet for images, zips for videos), and a corresponding cache of extracted images and videos.
    • start_validator.sh now starts an additional pm2 process called bitmind_cache_updater that manages a real video cache and a real image cache. Each has its own asynchronous tasks to download new zip/parquet files on a regular interval, and extract random images and videos on a shorter interval.

Validator.forward

  • Challenge generation has been updated according to the asynchronous nature of data sampling/generation described in the previous two sections.
  • Rather than generating synthetic media on an as-needed basis and downloading entire image datasets, the BitMind Validator's forward function now samples random data from a local cache of real and synthetic images and videos. For videos, a random number of frames are sampled from a random mp4 file. This logic is handled by the VideoCache class

Additional Changes

  • bitmind.constants.py had become quite a monolith, with the majority of its contents pertaining to validator operations. These variables have been moved to a more aptly named bitmind/validator/config.py, and model metadata dictionaries have been given a new structure that is more amenable to the nature of how the codebase interacts with them.
  • Upgraded library versions, accommodating changes in behavior of huggingface file downloads.
  • Added functionality to data augmentation pipeline to apply image transforms uniformly across all frames of a video
  • Consolidated requirements.txt and setup_env.sh to avoid out of sync dependency versions
  • For image challenges, we swapped out the open-images-v7 URL dataset for a JPEG subset of open-images-v7 to comply with our new caching system. This will also improve sampling reliability, as fetching URL images sometimes fails.

dylanuys and others added 30 commits November 19, 2024 17:17
* adding rich arg, adding coldkeys and hotokeys

* moving rich to payload from headers

* bump version

---------

Co-authored-by: benliang99 <caliangben@gmail.com>
Adding two finetuned image models to expand validator challenges
Updated transformers version to fix tokenizer initialization error
* Made gpu id specification consistent across synthetic image generation models

* Changed gpu_id to device

* Docstring grammar

* add neuron.device to SyntheticImageGenerator init

* Fixed variable names

* adding device to start_validator.sh

* deprecating old/biased random prompt generation

* properly clear gpu of moderation pipeline

* simplifying usage of self.device

* fixing moderation pipeline device

* explicitly defining model/tokenizer for moderation pipeline to avoid accelerate auto device management

* deprecating random prompt generation

---------

Co-authored-by: benliang99 <caliangben@gmail.com>
bump version
* simple video challenge implementation wip

* dummy multimodal miner

* constants reorg

* updating verify_models script with t2v

* fixing MODEL_PIPELINE init

* cleanup

* __init__.py

* hasattr fix

* num_frames must be divisible by 8

* fixing dict iteration

* dummy response for videos

* fixing small bugs

* fixing video logging and compression

* apply image transforms uniformly to frames of video

* transform list of tensor to pil for synapse prep

* cleaning up vali forward

* miner function signatures to use Synapse base class instead of ImageSynapse

* vali requirements imageio and moviepy

* attaching separate video and image forward functions

* separating blacklist and priority fns for image/video synapses

* pred -> prediction

* initial synth video challenge flow

* initial video cache implementation

* video cache cleanup

* video zip downloads

* wip fairly large refactor of data generation, functionality and form

* generalized hf zip download fn

* had claude improve video_cache formatting

* vali forward cleanup

* cleanup + turning back on randomness for real/fake

* fix relative import

* wip moving video datasets to vali config

* Adding optimization flags to vali config

* check if captioning model already loaded

* async SyntheticDataGenerator wip

* async zip download

* ImageCache wip

* proper gpu clearing for moderation pipeline

* sdg cleanup

* new cache system WIP

* image/video cache updates

* cleaning up unused metadata arg, improving logging

* fixed frame sampling, parquet image extraction, image sampling

* synth data cache wip

* Moving sgd to its own pm2 process

* synthetic data gen memory management update

* mochi-1-preview

* util cleanup, new requirements

* ensure SyntheticDataGenerator process waits for ImageCache to populate

* adding new t2i models from main

* Fixing t2v model output saving

* miner cleanup

* Moving tall model weights to bitmind hf org

* removing test video pkl

* fixing circular import

* updating usage of hf_hub_download according to some breaking huggingface_hub changes

* adding ffmpeg to vali reqs

* adding back in video models in async generation after testing

* renaming UCF directory to DFB, since it now contains TALL

* remaining renames for UCF -> DFB

* pyffmpegg

* video compatible data augmentations

* Default values for level, data_aug_params for failure case

* switching image challenges back on

* using sample variable to store data for all challenge types

* disabling sequential_cpu_offload for CogVideoX5b

* logging metadata fields to w&b

* log challenge metadata

* bump version

* adding context manager for generation w different dtypes

* variable name fix in ComposeWithTransforms

* fixing broken DFB stuff in tall_detector.py

* removing unnecessary logging

* fixing outdated variable names

* cache refactor; moving shared functionality to BaseCache

* finally automating w&b project setting

* improving logs

* improving validator forward structure

* detector ABC cleanup + function headers

* adding try except for miner performance history loading

* fixing import

* cleaning up vali logging

* pep8 formatting video_utils

* cleaning up start_validator.sh, starting validator process before data gen

* shortening vali challenge timer

* moving data generation management to its own script & added w&B logging

* run_data_generator.py

* fixing full_path variable name

* changing w&b name for data generator

* yaml > json gang

* simplifying ImageCache.sample to always return one sample

* adding option to skip a challenge if no data are available in cache

* adding config vars for image/video detector

* cleaning up miner class, moving blacklist/priority to base

* updating call to image_cache.sample()

* fixing mochi gen to 84 frames

* fixing video data padding for miners

* updating setup script to create new .env file

* fixing weight loading after detector refactor

* model/detector separation for TALL & modifying base DFB code to allow device configuration

* standardizing video detector input to a frames tensor

* separation of concerns; moving all video preprocessing to detector class

* pep8 cleanup

* reformatting if statements

* temporarily removing initial dataset class

* standardizing config loading across video and image models

* finished VideoDataloader and supporting components

* moved save config file out of trian script

* backwards compatibility for ucf training

* moving data augmentation from RealFakeDataset to Dataset subclasses for video aug support

* cleaning up data augmentation and target_image_size

* import cleanup

* gitignore update

* fixing typos picked up by flake8

* fixing function name ty flake8

* fixing test fixtures

* disabling pytests for now, some are broken after refactor and its 4am
dylanuys and others added 11 commits December 3, 2024 16:52
* docs updates

* mining docs update
* breaking out cache updates into their own process

* adding retries for loading vali info

* moving device config to data generation process

* typo

* removing old run_updater init arg, fixing dataset indexing

* only download 1 zip to start to provide data for vali on first boot

* cache deletion functionality

* log cache size

* name images with dataset prefix
* moving download_data.py to base_miner/datasets

* removing unused args in download_data

* constants -> config

* docs updates for new paths

* updating outdated fn headers
* Fix registry module imports

* Fixing config loading issues

* fixing frame sampling

* bugfix

* print label on testnet

* reenabling model verification

* update detector class names

* Fixing config_name arg for camo

* fixing detector config in camo

* fixing ref to self.config_name

* udpate default frame rate

* vidoe dataset creation example

* default config for video datasets

* update default num_videosg

---------

Co-authored-by: Andrew <caliangandrew@gmail.com>
dylanuys and others added 14 commits December 4, 2024 16:58
* resetting challenge timer to 60s

* fix logging for miner history loading

* randomize model order, log gen time

* remove frame limit

* separate logging to after data check

* generate with batch=1 first for diverse data availability

* load v1 history path for smooth transition to new incentive

* prune extracted cache

* swapping url open-images for jpg

* removing unused config args

* shortening cache refresh timer

* cache optimizations

* typo

* better variable naming

* default to autocast

* log num files in cache along with GB

* surfacing max size gb variables

* cooked typo

* Fixed wrong validation split key string causing no transform to be applied

* Changed detector arg to be required

* fixing hotkey reset check

* removing logline

* clamp mcc at 0 so video doesn't negatively impact performant image miners

* typo

* improving cache logs

* prune after clear

* only update relevant tracker in reward

* improved logging, turned off cache removal in sample()

---------

Co-authored-by: Andrew <caliangandrew@gmail.com>
Re-added bitmind HF org prefix to dataset path
Copy link
Contributor

@benliang99 benliang99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dylanuys dylanuys merged commit 11dcbb9 into main Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants