Git Product home page Git Product logo

transformertests's Introduction

TransformerTests

用于 Transformer 基本组网结构矩阵乘性能测试。

使用方法

python performance.py

参数配置如下:

  • --hidden-size:模型隐层大小。默认为 1024。
  • --ffn-inter-size:FFN 中间隐层大小。默认为 None,表示使用 hidden_size * 4 作为其值。
  • --hidden-act:FFN 中间激活函数类型也包括 FFN 组网类型。可设置为 relugelusilugated-relugated-gelugated-silu。默认为 relu
  • --head-num:多头注意力机制中头的数目。默认为 16。
  • --input-dtype:输入的数据类型。目前支持 bfloat16float16float32float64。不支持 int8。默认为 float32
  • --max-sequence-length:生成使用的最长输出长度。默认为 128。
  • --input-sequence-length:模拟的输入的长度。默认为 128。
  • --fused-qkv:是否将 qkv 的矩阵乘融合。
  • --tensor-parallel-size:tensor 并行的大小。不会跑多卡,会将设定的模型超参 size 进行切分后,在单卡上进行测试。默认为 1。
  • --inference-model-dir:输出 inference 模型的位置,一般可以不用设置。
  • --device:执行性能测试用的设备,即 inference config 所指定的设备。默认为 GPU。
  • --use-mkl:Inference 是否开启 MKL。
  • --threads:Inference 设置线程数。默认为 1。
  • --batch-size:性能测试使用的 batch size 大小。默认为 1。

性能数据输出结果为:

Performance:
Batch size: 1, input_sequence_length: 128, max_sequence_length: 128.
--------------------
The time of QKV with fused_qkv False is: 	0.13480520186324915.
The time of q*k (without softmax) is: 		0.023315586149692535.
The time of qk_weight * v is: 			0.023320985751019582.
The time of ffn with hidden_act relu is: 	0.20547565590176317.
The time of q*cached_k(sequence_length from 0 to 128) (without softmax) in decoding is: 11.440430050715804.
The time of qk_weight*cached_v(sequence_length from 0 to 128) in decoding is: 		11.993675859024126.

transformertests's People

Contributors

frostml avatar

Watchers

 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.