TVM 행렬 곱셈 최적화 - Step 7: cuBLAS Comparison
Published:
TVM으로 최적화한 행렬 곱셈 구현을 NVIDIA cuBLAS와 비교합니다. Step 6에서 달성한 1053 GFLOPS는 cuBLAS의 50.7%에 해당하며, 512x512 크기에서는 85.6%의 성능을 달성했습니다.
Published:
TVM으로 최적화한 행렬 곱셈 구현을 NVIDIA cuBLAS와 비교합니다. Step 6에서 달성한 1053 GFLOPS는 cuBLAS의 50.7%에 해당하며, 512x512 크기에서는 85.6%의 성능을 달성했습니다.
Published:
We compare our TVM-optimized matrix multiplication implementation with NVIDIA cuBLAS. The 1053 GFLOPS achieved in Step 6 corresponds to 50.7% of cuBLAS, and we achieved 85.6% performance for 512x512 size.
Published:
Loop Unrolling을 통해 1050 GFLOPS를 달성했습니다. 루프 오버헤드를 제거하고 Instruction-Level Parallelism을 향상시켜 최종 성능을 끌어올렸습니다.
Published:
We achieved 1050 GFLOPS through Loop Unrolling. We improved final performance by removing loop overhead and enhancing Instruction-Level Parallelism.
Published:
Software Pipelining을 통해 1029 GFLOPS를 달성했습니다. 메모리 레이턴시를 연산으로 은폐하여 평균 58% 성능 향상을 달성했습니다. 이 포스트에서는 여러 반복을 겹쳐서 실행하는 Software Pipelining 기법을 다룹니다.
Published:
We achieved 1029 GFLOPS through Software Pipelining. We achieved an average 58% performance improvement by hiding memory latency with computation. This post covers Software Pipelining techniques that execute multiple iterations overlapped.
Published:
Vectorization과 Local Memory(레지스터) 캐싱을 통해 평균 614 GFLOPS를 달성했습니다. 이 포스트에서는 Scalar Replacement 기법을 통한 레지스터 최적화와 벡터화를 통한 메모리 대역폭 활용을 다룹니다.
Published:
We achieved an average of 614 GFLOPS through Vectorization and Local Memory (register) caching. This post covers register optimization through Scalar Replacement techniques and memory bandwidth utilization through vectorization.
Published:
Shared Memory를 활용하여 큰 행렬(2048x2048)에서 101% 성능 향상을 달성했습니다. 이 포스트에서는 GPU 메모리 계층 구조와 Shared Memory를 통한 캐싱 전략, Cooperative Fetching 기법을 다룹니다.
Published:
We achieved 101% performance improvement on large matrices (2048x2048) using Shared Memory. This post covers GPU memory hierarchy and caching strategies through Shared Memory, and Cooperative Fetching techniques.
Published:
Tiling과 Loop Reordering을 통해 481 GFLOPS를 달성했습니다. Step 1 대비 5.1배 향상된 성능을 보여줍니다. 이 포스트에서는 캐시 최적화를 위한 Tiling 기법과 레지스터 재사용을 극대화하는 Loop Reordering을 다룹니다.
Published:
We achieved 481 GFLOPS through Tiling and Loop Reordering. This shows 5.1x performance improvement over Step 1. This post covers Tiling techniques for cache optimization and Loop Reordering to maximize register reuse.
Published:
기본 GPU 구현으로 95 GFLOPS를 달성했습니다. CPU 대비 6.3배 향상된 성능을 보여주지만, A500 Peak (3.072 TFLOPS)의 3.1%에 불과합니다. 이 포스트에서는 Data Parallelism과 2D Thread Mapping을 통한 기본 GPU 구현을 다룹니다.
Published:
We achieved 95 GFLOPS with basic GPU implementation. This shows 6.3x performance improvement over CPU, but it is only 3.1% of A500 Peak (3.072 TFLOPS). This post covers basic GPU implementation through Data Parallelism and 2D Thread Mapping.
Published:
TVM의 FuseReductionEpilogue 프리미티브의 복잡한 AST 변환 과정을 Mermaid 다이어그램으로 시각화합니다. 전체 아키텍처 흐름, 클래스 관계도, AST 변환 과정, 패턴 분석, 버퍼 교체 메커니즘, Python API 연결 구조를 다룹니다.
Published:
We visualize the complex AST transformation process of TVM FuseReductionEpilogue primitive using Mermaid diagrams. We cover overall architecture flow, class relationship diagram, AST transformation process, pattern analysis, buffer replacement mechanism, and Python API connection structure.
Published:
Part 2에서 세운 계획을 바탕으로 TVM 컴파일러가 이해할 수 있는 C++ 코드로 구현합니다. 패턴 분석, AST 변환, 트리 재구성의 세 단계를 통해 Reduction Block과 Epilogue Block을 융합하는 프리미티브를 완성합니다.
Published:
Based on the plan established in Part 2, we implement it in C++ code that the TVM compiler can understand. We complete a primitive that fuses Reduction Block and Epilogue Block through three stages: pattern analysis, AST transformation, and tree reconstruction.
Published:
Part 1에서 확인한 기존 스케줄링 프리미티브의 한계를 넘어, Reduction Block의 초기값을 0이 아닌 Bias로 설정하는 새로운 접근 방식을 제안합니다. 이 포스트에서는 TIR 구조 변환 설계와 구현 요구사항을 다룹니다.
Published:
Beyond the limitations of existing scheduling primitives confirmed in Part 1, we propose a new approach that sets the initial value of Reduction Block to Bias instead of 0. This post covers TIR structure transformation design and implementation requirements.
Published:
Vitis-AI의 Model Zoo는 DPU 제약을 고려해 이미 최적화된 AI 모델을 제공합니다. 본 문서는 TVM의 패턴 변환 패스를 활용해 원본 YOLOv4를 DPU 호환 YOLOv4-Leaky로 자동 변환하여, Model Zoo에서 제공하는 결과와 동등한 구조를 자동화하는 방법을 정리합니다.
Published:
Vitis-AI Model Zoo provides AI models already optimized considering DPU constraints. This document summarizes how to automatically convert original YOLOv4 to DPU-compatible YOLOv4-Leaky using TVM pattern transformation passes, automating the same structure provided by Model Zoo.
Published:
Part 3까지 구현한 FuseReductionEpilogue 프리미티브가 올바르게 동작하는지 검증하기 위한 테스트 전략을 다룹니다. 구조적 동등성 검사, 수치 정확도 검사, 엣지 케이스 테스트, Trace Roundtrip 검사를 통해 프리미티브의 안정성을 확보합니다.
Published:
We cover testing strategies to verify that the FuseReductionEpilogue primitive implemented up to Part 3 works correctly. We ensure the stability of the primitive through structural equality checks, numerical accuracy checks, edge case tests, and Trace Roundtrip checks.
Published:
대부분의 AI 가속기는 Output = Input * Weight + Bias를 한 번의 사이클에 처리하는 MAC(Multiply-Accumulate) 명령어를 지원합니다. 하지만 컴파일러가 생성한 중간 코드(TIR)에서 이 두 연산이 분리되어 있다면, 하드웨어의 성능을 온전히 끌어낼 수 없습니다. 이 포스트에서는 TVM의 MatMul 블록에 Bias Addition을 인라인할 수 없는 문제를 분석하고, 기존 스케줄링 프리미티브의 한계를 살펴봅니다.
Published:
Most AI accelerators support MAC (Multiply-Accumulate) instructions that process Output = Input * Weight + Bias in a single cycle. However, if these two operations are separated in the intermediate code (TIR) generated by the compiler, the hardware performance cannot be fully utilized. This post analyzes the problem of not being able to inline Bias Addition into TVM MatMul blocks and examines the limitations of existing scheduling primitives.
Published:
Conv2d + Bias + ReLU는 딥러닝에서 가장 흔한 패턴입니다. 하지만 PyTorch 모델을 TVM으로 가져올 때 Reshape 노드가 중간에 삽입되어 퓨전이 깨지는 문제가 발생합니다. 이 포스트는 이 문제를 해결하기 위한 패턴 매칭 기반 퓨전 패스 구현 과정을 다룹니다.
Published:
Conv2d + Bias + ReLU is the most common pattern in deep learning. However, when importing PyTorch models into TVM, Reshape nodes are inserted in the middle, breaking fusion. This post covers the implementation process of a pattern matching-based fusion pass to solve this problem.