Coder Social home page Coder Social logo

transformer_neural_network_hls's Introduction

Reconfigurable Acceleration of Transformer Neural Networks with Meta-Programming Strategies for Particle Physics Experiments

Available programs

Explore a Pytorch architecture

python3 pytorch/train_evaluate.py <options>

  • --particles <int>: use dataset specific jet dataset (1, 30, 50, 100, 150)

  • --train: train before evaluating

  • --debug: train/evaluate debug (prints each layer output) model

  • --timing: perform timing evaluation

  • --rng_seed: randomize all seeds

  • --use_cpu: force CPU usage, even if GPU available

  • --only_predictions: only print predictions

  • --fetch: refetch a dataset

  • --tiny_size <int>: number of particles to use for debug (to select fewer particles than the dataset offers, e.g. 10 out of 30)

  • --epochs <int>: epoch number to use for training and/or timing evaluation

  • --cuda <int>: CUDA device ID (for machines with more than 1 GPU)

  • --generate_hls_tb <int>: place specific number of input samples and PyTorch results as TB input and output for HLS

  • --flops: perform FLOPS measurement

  • --norm_info <str>: [deprecated] write summary of network's normalization layers


Extract weights and biases from a trained model

python3 scripts/extract_weights_biases.py <options>

  • --debug: use debug version of the Pytorch model

Run Vivado HLS

python3 scripts/compare_hls_pytorch.py <options>

  • --csim: run C Simulation

  • --synth: run C/RTL Synthesis

  • --cosim: run RTL Cosimulation

  • --reset: reset design

  • --pytorch: run Pytorch model

  • --load <str>: load pickled data and analyse it

  • --quiet: supress outputs


Perform a post-training quantization

python3 scripts/quantization_search.py <options>

  • --quiet: supress outputs

Generate precomputed log table for HLS

python3 scripts/generate_log_table.py <options>

  • --table_size <int>: Number of elements (must be a power of 2)

  • --max_value <int>: Biggest value used

  • --path <str>: path of the resulting table

  • --var_name <str>: name of the table variable

  • --var_type <str>: HLS type of the table variable

  • --quiet: supress outputs


Repo structure

├─ hls/
│   ├─ firmware/
│   │   ├─ nnet_utils/
│   │   │   ├─ nnet_activation.h               # log_softmax_latency, softmax_latency
│   │   │   ├─ nnet_self_attention.h           # self_attention
│   │   │   └─ nnet_transformer.h              # transformer
│   │   │
│   │   ├─ weights/                            # Weights and biases used in HLS
│   │   ├─ defines.h                           # typedef's, #define's
│   │   ├─ myproject.cpp                       # Implementation of ConstituentNetBase
│   │   ├─ myproject.h                         # Prototype of top-level function
│   │   └─ parameters.h                        # #include's, nnet struct redefinitions
│   │
│   ├─ tb_data/
│   │   ├─ csim_layer.log                      # C Simulation layer-by-layer output data
│   │   ├─ csim_result.log                     # C Simulation final output data (calculated)
│   │   ├─ tb_input_features.dat               # Input data
│   │   └─ tb_output_predictions.dat           # Output data (provided)
│   │
│   ├─ build_prj.tcl                           # Script for running C Simulation/Synthesis
│   └─ myproject_test.cpp                      # TB program for C Simulation
│
├─ pytorch/
│   ├─ data/                                   # Particles data
│   ├─ model/                                  # Modified ConstituentNet model files
│   └─ train_evaluate.py                       # Used to train and/or evaluate Pytorch model
│
├─ scripts/
│   ├─ compare_hls_pytorch.py                  # Runs and compares HLS vs Pytorch implementation
│   ├─ extract_weights_biases.py               # Extracts weights and biases from a Pytorch model
│   ├─ quantization_search.py                  # Perform post-training quantization search
│   ├─ generate_log_table.py                   # Generate precomputed log table for HLS
│   └─ playground.py                           # Used for testing and debugging Pytorch implementation
│
├─ logs/                                       # All sorts of logs and images
│   └─ synthesis_reports/                      # Synthesis reports captured at different design stages
│
├─ thesis/                                     # Directory used for generating the LaTeX thesis
│
├─ .gitignore                                  # gitignore
├─ environment.yaml                            # Packages for Conda environment
├─ requirements.txt                            # Packages for pip
└─ README.md                                   # This file

Helpful links

https://fastmachinelearning.org/hls4ml/

transformer_neural_network_hls's People

Contributors

fiwo735 avatar mam2118 avatar

Stargazers

Noah avatar Zhao Tong avatar  avatar  avatar Zhiqiang Walkie Que avatar Binglei Lou avatar Morgan Mitchell avatar

Watchers

Zhiqiang Walkie Que avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.