Views
No views yet
git clone https://github.com/pytorch-labs/superblock.git
cd superblockconda create -n superblock
conda activate superblock2.3.0.dev20240305+cu121 nightly
pip install --pre torch==2.3.0.dev20240305+cu121 --index-url https://download.pytorch.org/whl/nightly/cu121
pip install --pre torchvision==0.18.0 --no-depspython benchmark.py \
--model vit_b_16 \
--batch-size 256 \
> /dev/null532.1160546875 mspython benchmark.py --model vit_b_16 \
--batch-size 256 \
--sparsity-linear 0.8 \
--sp-linear-tile-size 64 \
--sparsify-weights \
--bsr 64 \
> /dev/null393.864453125 ms--sparsity-linear
--sp-linear-tile-size--sparsity-conv1x1
--sp-conv1x1-tile-size--sparsity-conv
--sp-conv-tile-size--skip-last-layer-sparsity
--skip-first-transformer-sparsityvit_b_16 from scratch using Supermask, you can use the respective torchvision command found in TRAINING.md and append the supermask arguments:torchrun --nproc_per_node=8 train.py\
--model vit_b_16 --epochs 300 --batch-size 512 --opt adamw --lr 0.003 --wd 0.3\
--lr-scheduler cosineannealinglr --lr-warmup-method linear --lr-warmup-epochs 30\
--lr-warmup-decay 0.033 --amp --label-smoothing 0.11 --mixup-alpha 0.2 --auto-augment ra\
--clip-grad-norm 1 --ra-sampler --cutmix-alpha 1.0 --model-ema\
--sparsity-linear 0.9 --sp-linear-tile-size 32vit_b_16 with 90% sparsity to linear layers using 32x32 tiles.python train.py --help for a full list of available arguments.--amp in the example commands below.MODEL_PATH=<put the path of the trained checkpoint here>
IMAGENET_PATH=<put the path of ImageNet dataset here>
NGPUS=1 # put number of available GPUS heretorchrun --nproc_per_node=${NGPUS} evaluate.py --model vit_b_16 --batch-size 256 --sparsity-linear 0.9 --sp-linear-tile-size 32 --weights-path ${MODEL_PATH} --data-path ${IMAGENET_PATH} --sparsify-weights --bsr 32--bsr the same as tile size.torchrun --nproc_per_node=${NGPUS} evaluate.py --model vit_b_16 --batch-size 256 --sparsity-linear 0.9 --sp-linear-tile-size 32 --weights-path ${MODEL_PATH} --data-path ${IMAGENET_PATH}python evaluate.py --help for a full list of available arguments.Test: Total time: 0:02:11
Test: Acc@1 78.392 Acc@5 93.592Test: Total time: 0:01:52
Test: Acc@1 76.092 Acc@5 92.656Test: Total time: 0:01:54
Test: Acc@1 76.092 Acc@5 92.656Test: Total time: 0:01:25
Test: Acc@1 76.092 Acc@5 92.656vit_b_16 trained on privacy mitigated Imagenet-blurred, you can download them here:SPARSITY=0.80 # Checkpoints available for: 0.70, 0.80, 0.82, 0.84, 0.86, 0.88, 0.90
BLOCK_SIZE=32 # Checkpoints available for: 16, 32, 64mkdir checkpoints
# For baseline,
wget https://huggingface.co/facebook/superblock-vit-b-16/resolve/main/checkpoints/baseline.pth -P checkpoints/
# For sparsified checkpoints,
wget https://huggingface.co/facebook/superblock-vit-b-16/resolve/main/checkpoints/sp${SPARSITY}-ts${BLOCK_SIZE}.pth -P checkpoints/python benchmark.py --model vit_b_16 \
--batch-size 256 \
--sparsity-linear ${SPARSITY} \
--sp-linear-tile-size ${BLOCK_SIZE} \
--sparsify-weights \
--bsr ${BLOCK_SIZE} \
--weights-path ./checkpoints/superblock-vit-b-16-sp${SPARSITY}-ts${BLOCK_SIZE}.pth \
> /dev/null530.342578125 mstorchrun --nproc_per_node=8 evaluate.py --model vit_b_16 --batch-size 256 --sparsity-linear ${SPARSITY} --sp-linear-tile-size ${BLOCK_SIZE} --bsr ${BLOCK_SIZE} --sparsify-weights --weights-path checkpoints/superblock-vit-b-16-sp${SPARSITY}-ts${BLOCK_SIZE}.pth --data-path ${IMAGENET_PATH}Test: Total time: 0:01:01
Test: Acc@1 77.644 Acc@5 93.554torchrun --nproc_per_node=1 evaluate.py --model vit_b_16 --batch-size 256 --sparsity-linear ${SPARSITY} --sp-linear-tile-size ${BLOCK_SIZE} --bsr ${BLOCK_SIZE} --sparsify-weights --weights-path checkpoints/superblock-vit-b-16-sp${SPARSITY}-ts${BLOCK_SIZE}.pth --data-path ${IMAGENET_PATH}Test: Total time: 0:01:51
Test: Acc@1 77.644 Acc@5 93.554