All Images AI-generated by the author for free with NightCafe Studio - لنک کے لئے فٹبال دیکھیں.
All Images AI-generated by the author for free with NightCafe Studio - لنک کے لئے فٹبال دیکھیں.
All Images AI-generated by the author for free with NightCafe Studio - لنک کے لئے فٹبال دیکھیں.اعلی کارکردگی کی کمپیوٹرنگ کی عمر کو ایک ہی نام سے بیان کیا گیا ہے:حیرت ہے
حیرت ہےNVIDIA کی پلیٹ فارم GPUs کی طاقت کو بند کر دیا، de facto معیار بن گیا.
ایک دہائی سے زیادہ، ایک GPU کو پروگرامنگ کرنے کے لئے CUDA میں پروگرامنگ کرنے کا مطلب تھا.
تاہم، اس حکمرانی نے ایک کمرے پیدا کی ہے، ایک ہی فروخت کرنے والے میں ترقی کو بند کر دیا ہے.
تاہم، اس حکمرانی نے ایک کمرے پیدا کی ہے، ایک ہی فروخت کرنے والے میں ترقی کو بند کر دیا ہے.
تاہم، اس حکمرانی نے ایک کمرے پیدا کی ہے، ایک ہی فروخت کرنے والے میں ترقی کو بند کر دیا ہے.لیکن آج، 2025 کے وسط میں - چیزیں تبدیل کر رہے ہیں.
لیکن آج، 2025 کے وسط میں - چیزیں تبدیل کر رہے ہیں.
The computing world is now undergoing a radical transformation towards heterogeneity.
ہم ماہر ہارڈ ویئر کی فراہمی کو دیکھتے ہیں:
-
Intel Gaudi Series:
Intel's Gaudi processors are designed specifically for deep learning training and inference, offering a competitive alternative to Nvidia's GPUs.
-
AMD Instinct MI Series:
AMD's MI series of GPUs is designed for high-performance computing and AI workloads, providing an alternative to Nvidia's data center GPUs.
-
Groq Tensor Streaming Processor (TSP):
Groq's TSP architecture is designed for low-latency inference and high throughput, particularly for large language models.
-
Google TPUs (Tensor Processing Units):
Google's TPUs are custom-designed chips optimized for machine learning workloads, particularly in Google's cloud infrastructure.
-
AWS Trainium:
AWS Trainium is a chip designed for machine learning training, offering high performance and cost-effectiveness.
اور ہر روز زیادہ سے زیادہ اسٹارٹپ جو اپنی مرضی کے مطابق سلیکون چپس بناتے ہیں.
اور ہر روز زیادہ سے زیادہ اسٹارٹپ جو اپنی مرضی کے مطابق سلیکون چپس بناتے ہیں.یہ نئی، مختلف منظر ایک نئی پروگرامنگ فلسفی کی ضرورت ہے.
Multi-Level Intermediate Representation (MLIR) اور Mojo پروگرامنگ زبان
This is not just another competitor; they represent a fundamental paradigm shift.
یہ کس طرح ہم کسی بھی ہارڈ ویئر کے لئے سافٹ ویئر کو ڈیزائن، بہتر بنانے اور تنصیب کرنے میں ایک انقلاب ہے.
This is a revolution in how we design, optimize, and deploy software for any hardware.
This article will deeply explore the architectural chasm between CUDA and MLIR.
- ہم ایک خاص، عملی موازنہ فراہم کرنے کے لئے مکمل، کام کوڈ مثالوں کا استعمال کریں گے.
- ہم سمجھیں گے کہ کیوں MLIR اس کے عزت مند سابق، LLVM کے مقابلے میں ایک پھیلاؤ ہے.
- ہم اس بات کا اظہار کریں گے کہ Mojo اعلی درجے کی طویل مدتی حل ہے.
- ہم یہ تجزیہ کریں گے کہ کیوں یہ نیا سٹاک قیمت اور رفتار کے لئے ایک کھیل تبدیل کرنے والا ہے.
یہ اثر اہم ترقی یافتہ شعبوں کو بھی بڑھاتا ہے جیسےGenerative AI, Quantum Computingاور یہاں تک کہBlockchain.
ہم بھی مستقبل کی طرف دیکھیں گے، پوشیدہmining ASICs،Neuromorphic Computingاورspecialized hardwareتھوڑا سا ڈیٹا اسٹریٹ کے لئے جو GPUs خراب کام کرتا ہے.
یہ ایک عمر کے اختتام اور ایک نئی عمر کی صبح کی کہانی ہے.
یہ ایک عمر کے اختتام اور ایک نئی عمر کی صبح کی کہانی ہے.
اس تبدیلی کی شدت کو سمجھنے کے لئے، ہم سب سے پہلےunderstand the four key players.
1. CUDA: The Powerful, Proprietary Incumbent
1۔ قوی، مالدار موجودہCUDA stands for Compute Unified Device Architecture.
یہ NVIDIA کی متضاد کمپیوٹرنگ پلیٹ فارم اور پروگرامنگ ماڈل ہے.
یہ ڈویلپرز کو C++ کی طرح کوڈ لکھنے کی اجازت دیتا ہے، جو kernels کہا جاتا ہے، جو NVIDIA GPUs پر چلتا ہے.
CUDA's Strengths:
کوڈ کی طاقت:Its ecosystem of libraries is mature and unmatched:
- Mathematical Libraries:
- cuBLAS: For basic linear algebra subprograms (BLAS).
- cuRAND: For random number generation.
- cuFFT: For Fast Fourier Transforms.
- cuSPARSE: For sparse matrix operations.
- cuTENSOR: For tensor operations.
- cuSOLVER: For dense and sparse direct solvers.
- Parallel Algorithm Libraries:
- nvGRAPH: For graph algorithms.
- Thrust: For parallel algorithms and data structures.
- Communication Libraries:
- NVSHMEM: For partitioned global address space (PGAS) programming.
- NCCL: For multi-GPU and multi-node collective communication.
- Deep Learning Libraries:
- cuDNN: For deep neural network computations.
- TensorRT: For optimized deep learning inference.
- Riva: For conversational AI.
- DALI: For data loading and augmentation for deep learning.
یہ ہارڈ ویئر پر براہ راست، کم سطح کنٹرول فراہم کرتا ہے، ماہرین کے لئے سب سے زیادہ کارکردگی کی اجازت دیتا ہے.
اس کی طویل تاریخ نے وسیع دستاویزات اور حمایت کے ساتھ ایک بڑے پیمانے پر کمیونٹی کی تعمیر کی ہے.
Its long history has built a massive community with vast documentation and support.
CUDA's Fatal Flaw: The Cage
Vendor Lock-In: CUDA code runs only on NVIDIA GPUs.
صرفیہ ڈویلپرز اور پورے صنعتوں کو ایک ہی، مہنگی ہارڈ ویئر سپلائر میں شامل کرتا ہے.
یہ مقابلہ کو روکتا ہے اور اس کام کے لئے بہترین ہارڈ ویئر کا انتخاب کرنے کی آزادی کو محدود کرتا ہے.
The Two-Language Problem: A Major Bottleneck in AI and Scientific Computing۔
محققین اس کی سادہگی اور تکرار کی رفتار کے لئے Python کی طرح ایک اعلی درجے کی زبان میں نمونے.
لیکن پیداوار کے لئے، کارکردگی اہم کوڈ کو کم سطح C++ / CUDA میں مکمل طور پر دوبارہ لکھا جانا چاہئے.
But for production, performance-critical code must be completely rewritten in low-level C++/CUDA.
یہ ایک دردناک اور مہنگا اختلاط پیدا کرتا ہے، تحقیق سے ڈپازٹنگ کے راستے کو کم کر دیتا ہے.
پروگرام کی پیچیدگی:
CUDA طاقتور ہے لیکن مشہور طور پر پیچیدہ اور بات چیت.
ڈویلپر کو مجبور کیا گیا ہے
ایک دستی میموری مینجمنٹ، CPU (آسمان) اور GPU (آلہ) کے درمیان ڈیٹا منتقل کرتا ہے.
ڈویلپر بھی ہارڈ ویئر کی منصوبہ بندی کرنے والا ہونا چاہئے، thread blocks، grids، اور synchronization کا انتظام.
یہ پیچیدگی ایک پائیدار سیکھنے کی کوریج ہے اور تھوڑا سا بیگ کا ایک عام ذریعہ ہے.
2. LLVM: The Foundation and Its "Semantic Gap”
LLVM: فاؤنڈیشن اور اس کے "سیمنیٹک گڑیا"LLVM پروجیکٹ ماڈیولر اور دوبارہ استعمال کرنے والی کمپیوٹر ٹیکنالوجیوں کا ایک مجموعہ ہے.
اس کی بنیادی بنیاد LLVM Intermediate Representation (IR) ہے، ایک کم سطح، جمع کی طرح کی زبان.
LLVM جدید کمپیوٹر بیک انڈز کے لئے معیاری بن گیا، خاص طور پر CPUs کے لئے.
ایک کمپیوٹر frontend (جیسے C++ کے لئے Clang) LLVM IR میں ذریعہ کوڈ کا ترجمہ کرتا ہے.
LLVM بیکنڈ اس IR کو بہتر بناتا ہے اور اسے ایک مخصوص CPU کے لئے مشین کوڈ میں تبدیل کرتا ہے.
یہ ماڈلوریشن اس وقت کے لئے انقلابی تھا.
تاہم، LLVM ایک CPU مرکزی دنیا کے لئے ڈیزائن کیا گیا تھا.
اس کے IR جدید دنیا کے لئے بہت کم سطح ہے heterogeneous ہارڈ ویئر.
یہ منبع کوڈ سے اہم اعلی درجے کی معلومات کھو جاتا ہے، ایک مسئلہ جو "سیمنیٹک غائب" کہا جاتا ہے.
مثال کے طور پر، ایک TensorFlow ماڈل کو جمع کرتے وقت، علم کہ ایک عمل ایک Convolution ہے کھو جاتا ہے.
LLVM IR صرف لنک اور اعداد و شمار کے احکامات کا ایک عام مجموعہ دیکھتا ہے.
یہ کمپیوٹر کو طاقتور، ڈومین کی مخصوص تعینات کرنے سے روکتا ہے.
یہ اب پروگرام کے اعلی درجے کے ارادے کو نہیں سمجھتا.
یہ "سیمنٹک فرق" کا مسئلہ ہے.
اور یہ مسئلہ یہ ہے کہ MLIR نے حل کیا ہے.
It loses crucial high-level information from the source code, a problem known as the "semantic gap."
For example, when compiling a TensorFlow model, the knowledge that an operation is a Convolution is lost.
LLVM IR only sees a generic collection of loops and arithmetic instructions.
This prevents the compiler from performing powerful, domain-specific optimizations.
It no longer understands the programmer's high-level intent.
This is the essence of the “semantic gap problem.”
And this problem is what MLIR has Solved.
3. MLIR: The Universal Translator for Hardware
MLIR: ہارڈ ویئر کے لئے عالمی ترجمہMLIR گوگل میں CPUs، GPUs، اور ان کے TPUs کے لئے TensorFlow کو جمع کرنے کی ضرورت سے پیدا ہوا.
انہوں نے سمجھا کہ LLVM کا واحد، کم سطح IR کافی نہیں تھا.
MLIR کا پھیلاؤ کئی IRs کی وضاحت اور تشکیل کے لئے ایک مشترکہ انٹرفیس ہے.
یہ composable IRs dialects کہا جاتا ہے.
dialect کےMLIR ایک عام مترجم کی طرح ہے، اعلی درجے کے خیالات سے کم درجے کی مشین کی تفصیلات تک ہر چیز میں چیلنج ہے.
ایک اعلی درجے کی dialect Domain-specific concepts کو براہ راست نمائندگی کر سکتا ہے.
For example, a "TensorFlow dialect" has an operation for tf.conv2d.
A "Linear Algebra dialect" has an operation for linalg.matmul.
یہ اہم سمینٹک معلومات کو برقرار رکھتا ہے جو LLVM ہٹا دیتا ہے.
یہ ایک طاقتور کمپیوٹر حکمت عملی کہا جاتا ہے کی اجازت دیتا ہےبڑھتی ہوئی کمائی*۔*
بڑھتی ہوئی کمائی
- کمپیوٹر ایک اعلی درجے کی زبان کی نمائندگی کے ساتھ شروع ہوتا ہے.
- یہ اس dialect پر اعلی درجے، ڈومین کی مخصوص آپریٹنگ کرتا ہے.
- اس کے بعد، یہ آہستہ آہستہ ایک سلسلہ وسطی زبانوں کے ذریعے کوڈ کو "اچھی" کرتا ہے.
- ہر intermediate dialect اپنے اپنے مخصوص آپریٹنگ کو انجام دیتا ہے.
- آخر میں، یہ آخری مشین کوڈ کی پیداوار کے لئے ایک کم سطح dialect تک پہنچتا ہے، جیسے LLVM IR dialect.
This process preserves high-level context for as long as possible.
This enables vastly superior optimizations for any hardware target.
MLIR is the missing link between high-level languages and diverse silicon.
MLIR is the missing link between high-level languages and diverse silicon.
MLIR is the missing link between high-level languages and diverse silicon.4. Mojo: The User-Friendly Face of MLIR's Power
4. Mojo: The User-Friendly Face of MLIR's PowerIf MLIR is the powerful, complex engine, Mojo is the sleek, intuitive user interface.
Mojo was created by Chris Lattner, the original architect of LLVM and the Swift language.
Mojo was created by Chris Lattner, the original architect of LLVM and the Swift language.
یہ ابتدائی اصولوں سے ڈیزائن کیا گیا ہے کہ MLIR عمر کے لئے کامل زبان بن جائے.
اس سلسلے میں، یہ آج سب سے زیادہ تکنیکی طور پر اعلی درجے کی زبان ہے.
Even Rust is based on LLVM and has all of LLVM’s shortcomings.
Even Rust is based on LLVM and has all of LLVM’s shortcomings.
Mojo is the only major programming language today based on MLIR.
Mojo is the only major programming language today based on MLIR.
Mojo's Key Features:
Python کے مترادفات
- Mojo aims for full compatibility with the existing Python ecosystem.
- This is a killer feature!
- It allows developers to import and use any Python library like NumPy, Pandas, or Matplotlib.
- یہ مکمل طور پر "چلنے شروع" مسئلہ کو دور کرتا ہے کہ نئے زبانوں کو پائٹون کی وسیع بحالی کا استعمال کرتے ہوئے سامنا کرنا پڑتا ہے.
True Systems پروگرامنگ کی خصوصیات:
- Unlike Python, Mojo is a compiled language with strong static typing.
- This eliminates entire classes of runtime errors and enables C++-level performance optimizations.
- It introduces modern memory management concepts like ownership and borrowing (from Rust) for memory safety without the overhead of a garbage collector.
First-Class MLIR Integration:
- Mojo exposes the full power of MLIR directly to the developer.
- پروگرامر اپنے زیادہ تر ایپلی کیشنز کے لئے اعلی سطح، پیٹونک کوڈ لکھ سکتے ہیں.
- When maximum performance is needed, they can drop down to use specific MLIR dialects and write low-level kernels.
- Crucially, this can all be done within the same file, in the same language.
Mojo elegantly solves the "two-language problem."
Mojo elegantly solves the "two-language problem."
Full Code Examples and Analysis
مکمل کوڈ مثالیں اور تجزیہTheory is one thing; practice is another.
The following full, working code examples -
Will demonstrate the profound differences between the two paradigms.
Example 1: Matrix Multiplication
مثال 1: متحرک متحرکThis is the "Hello, World!" of high-performance computing, and it clearly reveals the core philosophy of each platform.
The Full CUDA Implementation
This is a complete, compilable CUDA program for matrix multiplication.
(جیسا کہ C++)
// Filename: matmul.cu
// To compile: nvcc matmul.cu -o matmul_cuda
#include <iostream>
#include <vector>
#include <cuda_runtime.h>
// Helper to check for CUDA errors
#define CUDA_CHECK(err) { \
cudaError_t err_code = err; \
if (err_code != cudaSuccess) { \
std::cerr << "CUDA Error: " << cudaGetErrorString(err_code) << " at line " << __LINE__ << std::endl; \
exit(EXIT_FAILURE); \
} \
}
// CUDA Kernel for Matrix Multiplication (Device Code)
__global__ void matrixMulKernel(float* C, const float* A, const float* B, int N) {
// Calculate the global row and column index of the element
int row = blockIdx.y * blockDim.y + threadIdx.y;
int col = blockIdx.x * blockDim.x + threadIdx.x;
// Boundary check to avoid accessing out-of-bounds memory
if (row < N && col < N) {
float p_value = 0.0f;
// Each thread computes one element of the result matrix C
for (int k = 0; k < N; ++k) {
p_value += A[row * N + k] * B[k * N + col];
}
C[row * N + col] = p_value;
}
}
// Main function (Host Code)
int main() {
const int N = 256;
const int size = N * N * sizeof(float);
// Step 1. Allocate host memory
std::vector<float> h_A(N * N);
std::vector<float> h_B(N * N);
std::vector<float> h_C(N * N);
// Initialize host matrices
for (int i = 0; i < N * N; ++i) {
h_A[i] = static_cast<float>(rand()) / RAND_MAX;
h_B[i] = static_cast<float>(rand()) / RAND_MAX;
}
// Step 2. Allocate device memory
float *d_A, *d_B, *d_C;
CUDA_CHECK(cudaMalloc((void**)&d_A, size));
CUDA_CHECK(cudaMalloc((void**)&d_B, size));
CUDA_CHECK(cudaMalloc((void**)&d_C, size));
// Step 3. Copy matrices from host to device
std::cout << "Copying data from host to device..." << std::endl;
CUDA_CHECK(cudaMemcpy(d_A, h_A.data(), size, cudaMemcpyHostToDevice));
CUDA_CHECK(cudaMemcpy(d_B, h_B.data(), size, cudaMemcpyHostToDevice));
// Step 4. Define kernel launch configuration
// Use 16x16 threads per block, a common choice
dim3 threadsPerBlock(16, 16);
// Calculate the number of blocks needed in each dimension
dim3 numBlocks((N + threadsPerBlock.x - 1) / threadsPerBlock.x, (N + threadsPerBlock.y - 1) / threadsPerBlock.y);
// Step 5. Launch the kernel on the device
std::cout << "Launching kernel..." << std::endl;
matrixMulKernel<<<numBlocks, threadsPerBlock>>>(d_C, d_A, d_B, N);
CUDA_CHECK(cudaGetLastError());
CUDA_CHECK(cudaDeviceSynchronize()); // Wait for the kernel to finish
// Step 6. Copy the result matrix back from device to host
std::cout << "Copying result from device to host..." << std::endl;
CUDA_CHECK(cudaMemcpy(h_C.data(), d_C, size, cudaMemcpyDeviceToHost));
// Step 7. Free device memory
CUDA_CHECK(cudaFree(d_A));
CUDA_CHECK(cudaFree(d_B));
CUDA_CHECK(cudaFree(d_C));
std::cout << "CUDA Matrix Multiplication finished successfully." << std::endl;
// (Optional: Add verification step here)
return 0;
}
Analysis of the CUDA Code:
Analysis of the CUDA Code:The code is dominated by boilerplate and low-level management.
Steps 1, 2, 3, 6, and 7 are purely for managing memory across the CPU/GPU boundary.
This is tedious, error-prone, and obscures the core algorithm.
The
This code is fundamentally and permanently tied to NVIDIA's hardware architecture.
The actual algorithm—three nested loops—is a tiny fraction of the total code.
پروگرامن کے ذہنی اوپر کا انتظام ہارڈ ویئر کے انتظام پر خرچ کیا جاتا ہے، نہ ہی خود مسئلہ پر.
The programmer's mental overhead is spent on hardware management, not on the problem itself.
The Full Mojo Implementation
Mojo کی مکمل کارکردگییہ Mojo ورژن حیرت انگیز سادہ اور طاقت کے ساتھ اسی نتیجہ کو حاصل کرتا ہے.
(Mojo)
# Filename: matmul.mojo
# To run: mojo matmul.mojo
from memory import DType, Tensor
from random import rand
from time import now
fn matmul_naive(C: Tensor[DType.float32], A: Tensor[DType.float32], B: Tensor[DType.float32]):
"""A naive, high-level implementation of matrix multiplication."""
let N = A.dim(0)
let M = A.dim(1)
let P = B.dim(1)
for i in range(N):
for j in range(P):
var sum: Float32 = 0.0
for k in range(M):
sum += A.load(i, k) * B.load(k, j)
C.store(i, j, sum)
fn main():
let N = 256
# 1. Allocate and initialize tensors.
# Mojo's Tensor handles memory allocation automatically.
# The compiler will place it in the most appropriate memory space.
var A = Tensor[DType.float32](N, N)
var B = Tensor[DType.float32](N, N)
var C = Tensor[DType.float32](N, N)
for i in range(N):
for j in range(N):
A.store(i, j, rand[DType.float32]())
B.store(i, j, rand[DType.float32]())
print("Starting Mojo Matrix Multiplication...")
let start_time = now()
# 2. Call the function.
# The MLIR-based compiler optimizes this high-level code.
# It can automatically tile, vectorize, and parallelize this code
# for the target hardware (CPU, GPU, etc.).
matmul_naive(C, A, B)
let end_time = now()
let duration_ms = (end_time - start_time) / 1_000_000.0
print("Mojo Matrix Multiplication finished successfully.")
print("Execution time:", duration_ms, "ms")
# (Optional: Print a corner of the result matrix to verify)
print("Result C[0,0]:", C.load(0,0))
}
اور یہ سب ہے!
The Mojo Approach is Far Superior
The Mojo Approach is Far SuperiorProgrammability and Focus:
- The Mojo code is clean and expresses the algorithm directly.
- پروگرامر کیا پر توجہ مرکوز کرتا ہے (معلومات)، نہیں کس طرح (معلومات منتقل).
- There is no manual cudaMalloc, cudaMemcpy, or cudaFree.
- یہ تمام غلطیوں کی کلاس ختم ہو گئی ہے.
Abstraction with Performance:
- The simple nested loops are not what gets executed.
- The MLIR-based compiler performs sophisticated transformations.
- That turns this simple code into a highly-optimized kernel.
- It can apply tiling, vectorization, and parallelization automatically.
- پروگرامر ہدایات (مثلا @vectorize یا @parallelize) کو کمپیوٹر کی رہنمائی کرنے کے لئے شامل کر سکتا ہے، پیچیدگی کے بغیر کنٹرول حاصل کرنے کے لئے.
Portability (The Ultimate Advantage):
- This is the crucial point.
- اسی matmul.mojo فائل کو ایک NVIDIA GPU، ایک AMD GPU، AVX512 کے ساتھ ایک انٹیل CPU، یا ایک گوگل TPU پر چلانے کے لئے دوبارہ کمپیل کیا جا سکتا ہے.
- The logic remains the same; the compiler backend changes.
- CUDA کوڈ کو ہر نئے ہارڈ ویئر ہدف کے لئے ایک مکمل، مہنگی دوبارہ لکھنے کی ضرورت ہوگی.
- Mojo "توازن پورٹیبلشن" پیش کرتا ہے، فروخت کرنے والے کو بند کرنے اور کوڈ کو مستقبل کی ضمانت دیتا ہے.
MLIR پر مبنی Mojo بلاشبہ LLVM پر مبنی CUDA کو تبدیل کرنے کے لئے مقرر کیا گیا ہے، اور ڈویلپرز تبدیلی سے لطف اندوز ہوں گے!
MLIR-based Mojo is undeniably set to replace LLVM-based CUDA, and developers will enjoy the change!
For more on Mojo, refer to the article below:
Example 2: Gen AI and the Transformer Attention Mechanism
مثال 2: Gen AI اور ٹرانسفرورٹر توجہ کے میکانیزم"توجہ" میکانیزم GPT-4 جیسے ماڈلوں کا دل ہے اور ایک اہم کمپیوٹرک بوتل ہے.
Optimizing it is critical.
Optimizing it is critical.
The CUDA Implementation (Conceptual FlashAttention)
FlashAttention is a landmark algorithm that manually and expertly orchestrates data movement between the GPU's slow main memory (HBM) and its fast on-chip memory (SRAM) to reduce bottlenecks.
The real code is thousands of lines long and incredibly complex.
The real code is thousands of lines long and incredibly complex.
The links to the components of the full algorithm implementation are given below:
https://github.com/Dao-AILab/flash-attention/blob/main/csrc/flash_attn/src/flash_fwd_kernel.h
https://github.com/Dao-AILab/flash-attention/blob/main/csrc/flash_attn/flash_api.cpp
Together, they are almost 3000 lines long.
The repository contains thousands of files.
The learning curve and the onboarding curve are both steep.
A simplified version (AI-generated) is given below:
(CUDA C++)
// This is a simplified conceptual view of a FlashAttention-style CUDA kernel.
// The actual implementation is far more complex.
template<typename Kernel_traits>
__global__ void flash_attention_fwd_kernel(Flash_fwd_params params) {
// 1. Incredibly complex setup code
// Calculates dozens of pointers and indices for HBM and shared memory (SRAM)
const int block_row_idx = blockIdx.x;
const int head_idx = blockIdx.y;
// ... many more calculations ...
// 2. Explicitly allocate shared memory tiles for Q, K, V
// The developer must manage this limited resource manually.
extern __shared__ char smem[];
float* sQ = (float*)smem;
float* sK = sQ + kTileM * kTileK;
float* sV = sK + kTileN * kTileK;
// 3. Main loop over the sequence, manually loading blocks
for (int k_block_idx = 0; k_block_idx < params.k_num_blocks; ++k_block_idx) {
// Manually orchestrate asynchronous loads from HBM into SRAM
// to hide memory latency. This is extremely difficult to get right.
load_qkv_block_from_hbm(params, ...);
__syncthreads(); // Hard synchronization barrier
// Manually perform matrix multiplication in fast SRAM
compute_sram_matmul(sQ, sK, ...);
// Recompute softmax "online" to avoid writing the huge intermediate
// attention score matrix back to slow HBM. This is the core trick.
compute_online_softmax(...);
__syncthrows();
// Update the output block
update_output_block(sV, ...);
}
// 4. Manually write the final output block back to HBM
store_output_to_hbm(params, ...);
}
Analysis of the CUDA/FlashAttention Approach:
CUDA / FlashAttention نقطہ نظر کا تجزیہ:- It is a masterpiece of manual, hardware-specific engineering.
- It achieves incredible performance by treating the GPU like a manually programmed machine.
- This makes the code virtually unreadable, unmaintainable, and unportable.
- Only a handful of world-class experts can write or modify such code.
- It represents the peak of performance within a closed ecosystem, but also the peak of complexity and rigidity.
The Conceptual Mojo Implementation
Mojo کے مترادفاتMojo ورژن ایک ہی بیان کرتا ہےalgorithmic خیالات (tiling, online softmax) at a high level, delegating the hardware orchestration to the MLIR compiler.
(مجھے لگتا ہے)
from memory import DType, Tensor
from algorithm import parallelize
struct AttentionParams:
var is_causal: Bool
# ... other model parameters
# This function is a high-level, portable description of the FlashAttention algorithm.
fn flash_attention[T: DType](Q: Tensor[T], K: Tensor[T], V: Tensor[T], params: AttentionParams) -> Tensor[T]:
# Define problem dimensions from input tensors
let num_batches = Q.dim(0)
let num_heads = Q.dim(2)
let seqlen_q = Q.dim(1)
let seqlen_k = K.dim(1)
# Define tunable tiling parameters. The compiler can use these as hints.
alias BLOCK_M: Int = 128
alias BLOCK_N: Int = 64
# The output tensor
var O = Tensor[T](Q.dims)
# The @parallelize decorator tells the compiler to map this function
# over the available hardware parallelism (e.g., CUDA thread blocks or CPU cores).
@parallelize(num_batches * num_heads)
fn compute_head(batch_idx: Int, head_idx: Int):
# Define per-worker accumulators. The compiler will map these
# to the fastest available memory (e.g., registers or SRAM).
var o_i = Tensor[T](seqlen_q, V.dim(3))
var l_i = Tensor[T](seqlen_q) # Stores the denominator of the softmax
var m_i = Tensor[T](seqlen_q) # Stores the max of each row for stable softmax
o_i.zero()
l_i.fill(0.0)
m_i.fill(-50000.0) # Negative infinity
# Loop over blocks of the Key/Value sequence
for j in range(0, seqlen_k, BLOCK_N):
# 1. Load tiles of K and V.
# The compiler is responsible for generating the optimal code
# to move this data from main memory to fast memory.
let k_j = K.load_tile[BLOCK_N](batch_idx, j, head_idx)
let v_j = V.load_tile[BLOCK_N](batch_idx, j, head_idx)
# Loop over blocks of the Query sequence
for i in range(0, seqlen_q, BLOCK_M):
# 2. Load tile of Q.
let q_i = Q.load_tile[BLOCK_M](batch_idx, i, head_idx)
# 3. Compute attention scores for the tile. This is a simple matmul.
let s_ij = q_i @ k_j.transpose()
# Causal masking for decoder models like GPT
if params.is_causal:
# Algorithmic logic, no hardware specifics
apply_causal_mask(s_ij, i, j)
# 4. Perform the "online softmax" update.
# This is pure mathematical logic, not memory management.
let m_ij = row_max(s_ij)
let p_ij = exp(s_ij - m_ij)
let l_ij = row_sum(p_ij)
let m_new = max(m_i, m_ij)
let l_new = exp(m_i - m_new) * l_i + exp(m_ij - m_new) * l_ij
# Update output tile
o_i = (l_i / l_new * exp(m_i - m_new)) * o_i + (exp(m_ij - m_new) / l_new) * (p_ij @ v_j)
# Update softmax stats
l_i = l_new
m_i = m_new
# 5. Store the final output. The compiler manages the write-back.
O.store_tile(batch_idx, head_idx, o_i)
compute_head()
return O
ایک فائل
Less than 100 LOC.
کوئی دماغی انفیکشن نہیں
Of course, this is just the algorithm, but in the repository, the same algorithm took nearly 3000 LOC with CUDA!
Of course, this is just the algorithm, but in the repository, the same algorithm took nearly 3000 LOC with CUDA!
So now you understand the difference:
So now you understand the difference:
Mojo is Game-Changing for AI:
Mojo AI کے لئے کھیل تبدیل کرتا ہے:Separation of Concerns:
- Mojo کوڈ الگورتھم کی وضاحت کرتا ہے.
- CUDA کوڈ ایک دستی ہارڈ ویئر انضمام کی وضاحت کرتا ہے.
- یہ ایک بڑا فرق ہے.
- Mojo پروگرامر الگورتھم کو بہتر بنانے پر توجہ مرکوز کرسکتے ہیں:
- جبکہ MLIR کمپیوٹر اس کو سلیکون میں نقشہ کرنے پر توجہ مرکوز کرتا ہے.
Research Velocity and Maintainability:
- An AI researcher can easily understand and modify this Mojo code to test a new idea.
- Modifying the CUDA code would be a massive, time-consuming engineering project requiring a rare skillset.
- یہ تحقیق اور ترقی کے سائیکل کو سنجیدگی سے تیز کرتا ہے.
Hardware Freedom: (The Most Important)
- یہ Mojo کوڈ NVIDIA سے منسلک نہیں ہے.
- It can be compiled to run on:
- AMD GPUs
- Google TPUs
- Intel Gaudi
- Custom AI chips.
- Any architecture there is!
- MLIR کے زبانوں کو کسی بھی نئے ہارڈ ویئر کی حمایت کے لئے توسیع کیا جا سکتا ہے:
- Mojo کوڈ کو واقعی مستقبل کی تصدیق کرتا ہے.
This breaks the NVIDIA monopoly on high-performance AI and will drive down costs.
This breaks the NVIDIA monopoly on high-performance AI and will drive down costs.
Specialized Hardware and Future Domains
خصوصی ہارڈ ویئر اور مستقبل کے ڈومینزThe limitations of the CUDA model become even more apparent when we look beyond traditional dense workloads to the future of computing.
The limitations of the CUDA model become even more apparent when we look beyond traditional dense workloads to the future of computing.
MLIR/Mojo is designed for this future.
MLIR/Mojo is designed for this future.
Blockchain, Mining, and ASICs
Blockchain، مینجمنٹ اور ASICsکام کے ثبوت کے طور پر Blockchains جیسے Bitcoin کی ضرورت ہے بڑی ہچنگ طاقت.
مقصد یہ ہے کہ ایک "نونس" تلاش کریں جو، دوسرے اعداد و شمار کے ساتھ hashed جب، ایک مخصوص مقصد کے نیچے ایک نتیجہ پیدا کرتا ہے.
This is a brute-force search, perfect for parallel hardware.
Initially, miners used CPUs, then GPUs for their superior parallelism.
ایک SHA-256 مینیئر کے لئے CUDA کوڈ کم سطح پر ہے، بٹویس اور کل تعداد کے عمل پر توجہ مرکوز کرتا ہے.
تاہم، SHA-256 کی طرح ایک مستحکم، غیر متغیر الگورتھم کے لئے، آخری ہارڈ ویئر ایک ASIC ہے.
However, for a stable, unchanging algorithm like SHA-256, the ultimate hardware is an ASIC.
ایک ASIC (Application-Specific Integrated Circuit) ایک چپس ہے جو ایک ہی مقصد کے لئے ڈیزائن کیا گیا ہے - ہارڈ ویئر میں ایک الگورتھم کو لاگو کرنے کے لئے.
ایک ASIC (Application-Specific Integrated Circuit) ایک چپس ہے جو ایک ہی مقصد کے لئے ڈیزائن کیا گیا ہے - ہارڈ ویئر میں ایک الگورتھم کو لاگو کرنے کے لئے.
An SHA-256 ASIC has the hashing logic literally baked into the silicon.
یہ ایک ہی کام کے لئے ایک GPU کے مقابلے میں ہزاروں گنا زیادہ توانائی کی کارکردگی ہے.
یہاں CUDA کی کہانی ختم ہوتی ہے، لیکن MLIR / Mojo کی کہانی مزید دلچسپ ہو جاتی ہے.
یہاں CUDA کی کہانی ختم ہوتی ہے، لیکن MLIR / Mojo کی کہانی مزید دلچسپ ہو جاتی ہے.ایک چپس کو ڈیزائن کرنے کا عمل ہائی سطح مرکب (HLS) کہا جاتا ہے.
HLS ٹولز ایک الگورتھم کی اعلی درجے کی وضاحت کو ایک کم درجے کے ہارڈ ویئر کی وضاحت کی زبان (مثلا Verilog یا VHDL) میں تبدیل کرتے ہیں جو چپس کی تخلیق کرنے کے لئے استعمال کیا جاتا ہے.
MLIR، CIRCT (Circuit IR for Compilers and Tools) جیسے منصوبوں کے ذریعہ، اگلے نسل HLS کی بنیاد بننے کے لئے ڈیزائن کیا گیا ہے.
MLIR, through projects like CIRCT (Circuit IR for Compilers and Tools), is designed to be the backbone of next-generation HLS.
- ایک ڈویلپر Mojo میں ایک hashing algorithm لکھ سکتا ہے.
- GPU مینجمنٹ کے لئے، وہ اسے GPU بیکنڈ کا استعمال کرتے ہوئے جمع کریں گے.
- ایک ASIC بنانے کے لئے، وہ ایک HLS بیکنڈ کا استعمال کرتے ہوئے بالکل اسی Mojo کوڈ کو جمع کرسکتے ہیں.
- MLIR انشورنس اعلی درجے کی Mojo منطق کو Verilog میں کم کرے گا.
یہ اعلی درجے کے سافٹ ویئر سے اپنی مرضی کے مطابق سلیکون ڈیزائن تک پورے سٹاک کو متحد کرتا ہے.
یہ ممکنہ طور پر سب سے زیادہ مؤثر ہارڈ ویئر پر نئے الگورتھم کی تیزی سے پروٹوٹائپنگ اور تنصیب کی اجازت دیتا ہے، چاہے یہ ایک GPU یا ایک نئے ASIC ہے.
Cuda اس کا جواب نہیں ہے.
Cuda اس کا جواب نہیں ہے.
It is a software-only solution for a single vendor's programmable hardware.
Neuromorphic Computing and Sparse Data
Neuromorphic Computing اور Sparse ڈیٹاNVIDIA GPUs SIMT: Single Instruction، Multiple Thread کے ماسٹر ہیں.
NVIDIA GPUs are masters of SIMT: Single Instruction, Multiple Thread.
اس کا مطلب یہ ہے کہ وہ بہت مؤثر ہیں جب ہزاروں تاروں کو مختلف اعداد و شمار (مثال کے طور پر، ایک میٹرکس متغیر) پر ایک ہی حکم کو چلایا جاتا ہے.
تاہم، وہ بھاری فریمنگ یا غیر معمولی ڈیٹا تک رسائی کے ساتھ کام کے لوڈ پر بہت غیر مؤثر ہیں.
اس کا مطلب یہ ہے کہ "تقریبا فرق" ہے.
اگر ایک گروپ میں تاروں (ایک "warp") ایک if/else بیان کے مختلف تاروں کو لیتے ہیں تو، ہارڈ ویئر کو دونوں راستوں کو سیریز میں چلانا ہوگا، غیر فعال راستے میں تاروں کو صرف بند کر دیا گیا ہے.
If threads in a group (a "warp") take different branches of an if/else statement, the hardware must execute both paths serially, with threads in the inactive path simply turned off.
دونوںیہ بہت سے اہم مسائل کے لئے کارکردگی کو قتل کرتا ہے.
Neuromorphic Computing:
یہ ایک دماغ پر مبنی کمپیوٹر پیراگراف ہے.
Neuromorphic چپس، انٹیل کے Loihi کی طرح، گھڑیوں اور گہری میٹرکس ریاضی پر مبنی نہیں ہیں.
یہ واقعات کی وجہ سے ہیں.
They are event-driven.
"نورون" صرف جب ان کے ان پٹیل کی صلاحیت ایک حد سے زائد ہے تو ایک "پائیک" کو گولی مارتا ہے.
یہ سپیکس دیگر "سینیپسز" میں سفر کرتے ہیں، جو اس کے بعد دیگر نیورونز کو آگ لگانے کی وجہ سے ہوسکتا ہے.
یہ ایک انتہائی کمزور، زراعت سنگین، اور غیر معمولی عمل ہے.
ایک GPU پر یہ نمونہ کرنے کی کوشش کرنا مسلسل ٹریڈ ڈویژن کی وجہ سے خوفناک طور پر غیر مؤثر ہے.
Trying to simulate this on a GPU is horrifically inefficient due to constant thread divergence.
MLIR اس کے لئے کامل حل ہے.
MLIR اس کے لئے کامل حل ہے.
MLIR اس کے لئے کامل حل ہے.
- MLIR کے اندر ایک "neuromorphic dialect" پیدا کیا جا سکتا ہے.
- اس زبان میں Spike، Synapse، NeuronUpdate کے لئے پہلی کلاس کے عمل ہوتے ہیں.
- ایک ڈویلپر ان اعلی درجے کے خیالات کا استعمال کرتے ہوئے Mojo میں ایک neuromorphic الگورتھم لکھ سکتا ہے.
- MLIR کمپیوٹر، Loihi کی طرح ایک مخصوص neuromorphic چپس کے لئے ایک بیک اینڈ کے ساتھ، چپس کی اصل، واقعات کی طرف سے ڈرائیونگ ہدایات میں ان مفهوموں کو ترجمہ کرے گا.
یہ ایک پورٹیبل، اعلی درجے کے پروگرامنگ ماڈل کے لئے ایک مکمل طور پر غیر روایتی شکل کمپیوٹرنگ کی اجازت دیتا ہے.
CUDA ماڈل اس علاقے میں اہم نہیں ہے.
The CUDA model is not relevant in this domain.
Sparse and Graph Data:
Sparse اور Graph ڈیٹا:بہت سے حقیقی دنیا کے مسائل کم اعداد و شمار سے متعلق ہیں: سماجی نیٹ ورک، سفارش کے انجن، اور سائنسی نمائش.
ان کو گہری مٹیز کے طور پر نمائندگی کرنا ضائع ہے.
ان کو گہری مٹیز کے طور پر نمائندگی کرنا ضائع ہے.
GPU پر ان کی پروسیسنگ غیر معمولی میموری تک رسائی کے نمونے کی وجہ سے ہوتی ہے، جو GPU کی میموری کو ایکسچینج کرنے کے لئے بہتر بنانے اور کارکردگی کو کم کرتی ہے.
Again, MLIR provides the answer.
- ایک "graph dialect" یا "sparse tensor dialect" ان اعداد و شمار کی ساختوں کو لاطینی طور پر نمائندگی کر سکتا ہے.
- کمپریسر اس کے بعد کمزوری کا انتظام کرنے کے لئے خصوصی تعینات کو لاگو کرسکتا ہے.
- مثال کے طور پر، یہ میموری کی پوزیشن کو بہتر بنانے کے لئے نڈوس کو دوبارہ ترتیب دے سکتا ہے یا کمپریس سٹوریج فارمیٹس کا استعمال کر سکتا ہے.
-
یہ کسی بھی ہارڈ ویئر پر کم از کم اعداد و شمار کے لئے مؤثر طریقے سے ایک اعلی درجے کی الگورتھم میں لکھا جا سکتا ہے.
This allows a high-level algorithm written in Mojo to be efficiently compiled for sparse data on any hardware.
یہ کچھ ہے جو آج بہت مشکل ہے.
اور غیر ممکن کے ساتھ CUDA.
اور غیر ممکن کے ساتھ CUDA.
Quantum Computing Simulation
Quantum Computing Simulation کے مترادفاتSimulating a quantum computer on a classical computer is essential for developing and testing quantum algorithms.
سب سے زیادہ عام طریقہ State Vector Simulation ہے.
ایک N-qubit کوانٹمی نظام کی حالت 2^N پیچیدہ اعداد و شمار کے ایک ویکٹر کی طرف سے نمائندگی کی جاتی ہے.
صرف 50 qubits کے لئے، اس ویکٹر میں 2^50 (ایک quadrillion سے زیادہ) عناصر ہیں، جو میموری کے پٹیابائٹ کی ضرورت ہوتی ہے.
For just 50 qubits, this vector has 2^50 (over a quadrillion) elements, requiring petabytes of memory.
ایک کوانٹمی algorithm ایک "Gates" کے سلسلے ہے.
ہر بندرگاہ ایک بہت بڑا، بہت چھوٹا مٹریکس کے ساتھ بڑے پیمانے پر ریاست کے ویکٹر کو متغیر کرنے کے برابر ہے.
یہ ایک کاروباری بوجھ ہے جو کمپیوٹرنگ کی شدت سے اور میموری بینڈوائیڈ سے منسلک ہے.
NVIDIA نے اپنے cuQuantum لائبریری، ایک اعلی کارکردگی CUDA پر مبنی حل کے ساتھ یہاں بہت سرمایہ کاری کی ہے.
cuQuantum NVIDIA GPUs پر بہت تیزی سے ہے، لیکن اس میں کلاسیکی CUDA محدودیاں ہیں:
- ونڈرس Lock-In: آپ کی کوانٹمی نمائش NVIDIA ہارڈ ویئر سے منسلک ہے.
- Low-Level Optimization: کمپیوٹر صرف میٹرکس ویکٹر multiplications دیکھتا ہے.
- کوئی ڈومین فائدہ: یہ کوانٹمی میکانک کے لئے کوئی بہتر بنانے کی ضرورت نہیں ہے، LLVM پر مبنی ہے (سیمانٹک گڑیا).
The MLIR/Mojo Advantage for Quantum Simulation:
Quantum Simulation کے لئے MLIR / Mojo فوائد:MLIR نقطہ نظر کمپیوٹر میں بہت زیادہ علم کی سطح کی اجازت دیتا ہے.
- ایک "quantum dialect" MLIR میں بیان کیا جا سکتا ہے.
- یہ زبان دروازوں کو میٹرکس کے طور پر نمائندگی نہیں کرے گا؛ یہ ان کے کوانٹمی اشیاء کے طور پر ان کی نمائندگی کرے گا: Hadamard، CNOT، Toffoli.
- ایک ڈویلپر ان کے کوانٹمی چارٹ کو Mojo میں ان اعلی درجے کے اشیاء کا استعمال کرتے ہوئے لکھے گا.
- MLIR کمپریسر اس کے بعد کسی بھی مٹیز کو بھی پیدا کرنے سے پہلے کوانٹمی مخصوص تعینات کرسکتے ہیں.
مثال کے طور پر، کمپیوٹر کو پتہ چلتا ہے کہ ایک Hadamard پورٹ (H) کو دو بار ایک سلسلے میں لاگو کرنا ایک شناختی عمل ہے اور مکمل طور پر خارج کیا جا سکتا ہے.
یہ جاننا چاہتا تھا کہ دروازوں کے کچھ سلسلے کو ایک واحد، زیادہ مؤثر دروازے میں "مزید" کیا جا سکتا ہے.
مثال کے طور پر، کمپیوٹر کو پتہ چلتا ہے کہ ایک Hadamard پورٹ (H) کو دو بار ایک سلسلے میں لاگو کرنا ایک شناختی عمل ہے اور مکمل طور پر خارج کیا جا سکتا ہے.
یہ جاننا چاہتا تھا کہ دروازوں کے کچھ سلسلے کو ایک واحد، زیادہ مؤثر دروازے میں "مزید" کیا جا سکتا ہے.
یہ ایک مکمل تعمیراتی کلاس ہے جو CUDA کمپیوٹر کے لئے ناممکن ہے، جو LLVM کا شکریہ صرف عام مٹیز دیکھتا ہے.
This is an entire class of optimization that is invisible to the CUDA compiler, which only sees generic matrices, thanks to LLVM.
ان اعلی درجے کے algebraic سادہ کاریوں کو انجام دینے کے بعد، MLIR کمپیوٹر اس کے بعد ہدف ہارڈ ویئر کے لئے تھوڑا سا میٹرکس آپریشنوں کی ایک بہتر سلسلہ میں سادہ چارٹ کو کم کرے گا.
کیونکہ یہ سب MLIR پر تعمیر کیا گیا ہے، اسی اعلی درجے کے کوانٹمی چارٹ کو Mojo میں لکھا جا سکتا ہے کہ ایک NVIDIA GPU، ایک AMD GPU، یا ایک CPU کلسٹر پر چلانے کے لئے جمع کیا جا سکتا ہے.
Because this is all built on MLIR, the same high-level quantum circuit written in Mojo could be compiled to run on an NVIDIA GPU, an AMD GPU, or a CPU cluster.
یہ دونوں اعلی کارکردگی کی پیشکش کرتا ہے (ایک سمارٹ آپریٹنگ کی وجہ سے) اور مکمل ہارڈ ویئر آزادی.
NVIDIA کو کوانٹمی نمائش کے ہارڈ ویئر اور سافٹ ویئر اسٹاک میں بہت زیادہ سرمایہ کاری کر رہا ہے.
لیکن اس کی CUDA-Q پلیٹ فارم اب بھی LLVM پر مبنی ہے.
MLIR پر مبنی Mojo نہ صرف اعلی درجے کی بہتر بنانے کی پیشکش کر سکتا ہے - یہ بھی سادہ پروگرامنگ فراہم کرتا ہے.
MLIR-based Mojo can not just offer advanced optimization - it also offers simpler programming.
Final Verdict: Today vs. The Inevitable Future
آخری فیصلہ: آج vs. غیر متوقع مستقبلThe Verdict Today (2025):
آج کا فیصلہ (2025):- یہ پہاڑ کا بادشاہ ہے اور یہ پہاڑ بڑا ہے.
- اس کی بالغ ماحولیاتی نظام، وسیع لائبریریوں، اور بڑی کمیونٹی طاقتور اثاثے ہیں.
- ایک ٹیم کے لئے جو پہلے سے ہی NVIDIA ہارڈ ویئر میں سرمایہ کاری کر رہا ہے اور فوری طور پر ایک مصنوعات کو بھیجنے کی ضرورت ہے، CUDA عملی انتخاب ہے.
- حکومت کی ایک دہائی کی توازن ایک طاقتور طاقت ہے.
- میوزیم ابھی بھی نوجوان ہے
- اس کا تعمیراتی نظام حیرت انگیز تیزی سے بڑھ رہا ہے، لیکن یہ ابھی تک CUDA کی لڑائی کی جانچ پڑتال شدہ لائبریریوں کی وسیع پیمانے پر نہیں مل سکا.
The Verdict for the Long Run:
طویل عرصے کے لئے فیصلہ:- مستقبل heterogeneous ہے
- یہ کوئی تخمینہ نہیں، یہ ایک حقیقت ہے.
- اپنی مرضی کے مطابق AI سلیکون اور AMD اور انٹیل کی طرف سے دوبارہ مقابلہ کی بڑھتی ہوئی ترقی نے فراہم کنندہ کو ایک غیر قابل قبول کاروباری اور تکنیکی خطرہ بنا دیا ہے.
- مستقبل کے مسائل - غریب اعداد و شمار، neuromorphic AI، blockchain mining، اور کوانٹمی کمپیوٹرنگ - آج کے GPUs کی سخت SIMT ماڈل میں اچھی طرح سے شامل نہیں ہیں.
- MLIR اس مسئلہ کو حل کرنے کے لئے ڈیزائن کردہ صرف موجودہ، صنعت کی حمایت کی آرکیٹیکل ہے.
- گوگل، ایپل، انٹیل، AMD، اور ARM کی طرف سے اس کی قبولیت کمپیوٹرز کے مستقبل میں اس کے مرکزی کردار کا واضح اشارہ ہے.
- موجو صرف ایک ہی زبان ہے جو اس طاقت کو استعمال کرنے کے لئے بنایا گیا ہے.
میوزیم :
- دو زبانوں کا مسئلہ حل
- کارکردگی کے ساتھ استعمال کا مجموعہ
- پوری MLIR ماحولیاتی نظام کے لئے ایک دروازہ فراہم کرتا ہے.
CUDA سے ایک MLIR پر مبنی دنیا میں منتقل کرنے کے لئے تیزی سے ہو جائے گا، لیکن یہ ضروری ہے.
یہ ایک بنیادی تبدیلی ہے، ایک بند، ہارڈ ویئر پر مبنی ماڈل سے ایک کھلی، سافٹ ویئر کی بنیاد پر مستقبل.
Mojo کے نقصانات
- Mojo اب بھی ترقی میں ہے.
- اس کے پاس ابھی تک کلاس نہیں ہے.
- اس کے تیسرے فریق لائبریریز تھوڑے ہیں، لیکن ایک حیرت انگیز رفتار میں بڑھ رہا ہے.
- یہ ہر جگہ ایپلی کیشنز ہے جہاں پائٹون استعمال کیا جاتا ہے - لیکن اسے پائٹون کے ساتھ ترقی کی ضرورت ہے.
- پوری زبان اب تک کھلے ذریعہ نہیں ہے، اگرچہ ماہرین کا کہنا ہے کہ یہ جلد ہی بدل جائے گا.
- یہ ونڈوز کی حمایت نہیں کرتا (بھی).
- اور یہ Android، iOS، اور Edge IOT سسٹموں پر پورٹنگ کی ضرورت ہے.
کیا وہ طویل عرصے سے جیتنے والا ہے؟
I believe it will, and developers will be happier with Mojo than CUDA.
نتیجہ
CUDA نے آج کی اعلی کارکردگی کی کمپیوٹرنگ کی حیرت انگیز عمارت کی تعمیر کی.
CUDA built the impressive palace of today's high-performance computing.
یہ ایک کمرے ہے.
But it is a cage.
MLIR اور Mojo ہر ڈویلپر کو اس کو کھولنے اور مستقبل کی تعمیر کرنے کے لئے کلید دے رہے ہیں جو وہ منتخب کرتے ہیں.
MLIR and Mojo are handing every developer the key to unlock it and build the future on any foundation they choose.
اور یہ بنیاد MLIR اور Mojo ہونا چاہئے.
اور یہ بنیاد MLIR اور Mojo ہونا چاہئے.
The simplest reason - the budget.
بودجه کےاس وجہ سے، جب تک کہ NVIDIA پیویٹ نہیں کرتا، اور جلد ہی:
یہ Nvidia کی حکمرانی کا خاتمہ ہو گا - اگر وہ بھی MLIR کو تسلیم نہیں کرتے!
This will be the end of the dominance of Nvidia - unless they embrace MLIR as well!
References کے
Official Project Pages
- MLIR (Multi-Level Intermediate Representation)
- Text description: The official homepage for the MLIR project, hosted by LLVM. This is the canonical source for documentation, talks, and the project's overall mission statement.
- https://mlir.llvm.org/
- Mojo Programming Language
- The official documentation for the Mojo programming language from Modular, the company that created it. This is the primary resource for learning the language.[2]
- https://docs.modular.com/mojo/
- NVIDIA CUDA Toolkit
- The official portal from NVIDIA for downloading the CUDA Toolkit, which includes the compilers, libraries, and tools necessary for CUDA development.
- https://developer.nvidia.com/cuda-toolkit
- LLVM Compiler Infrastructure Project
- The main homepage for the LLVM project, which provides an overview of the entire ecosystem, including Clang, LLDB, and other sub-projects. MLIR is a part of this larger project.
- https://llvm.org/
- Chris Lattner's Homepage
- The personal homepage of Chris Lattner, the creator of LLVM, Clang, Swift, MLIR, and Mojo. It provides his work history and links to his talks and papers, offering direct insight into the creation of these technologies.
- https://nondot.org/sabre/
AI and Attention Mechanism (FlashAttention)
- FlashAttention Original Paper (arXiv)
- The original scientific paper, "FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness," which introduced the algorithm. This is the primary source for understanding the technical details and performance benefits.
- https://arxiv.org/abs/2205.14135
- FlashAttention-2 Paper (arXiv)
- The follow-up paper describing FlashAttention-2, which details further optimizations for parallelism and work partitioning to achieve even greater speedups on modern GPUs.
- https://arxiv.org/abs/2307.08691
- FlashAttention GitHub Repository
- The official GitHub repository containing the source code for the FlashAttention and FlashAttention-2 CUDA kernels.
- https://github.com/Dao-AILab/flash-attention
Quantum Computing Simulation
- NVIDIA cuQuantum Official Page
- NVIDIA's official product page for the cuQuantum SDK, outlining its features for accelerating quantum computing simulations on GPUs.
- https://developer.nvidia.com/cuquantum
- NVIDIA cuQuantum Documentation
- The detailed technical documentation for the cuQuantum SDK, providing a high-level overview and API references for the libraries.
- https://docs.nvidia.com/cuda/cuquantum/index.html
Specialized Hardware (Neuromorphic & ASICs)
- Intel Neuromorphic Computing Overview
- Intel's official overview of their neuromorphic computing research, which discusses the goals of the program and the Loihi research chips.
- https://www.intel.com/content/www/us/en/research/neuromorphic-computing.html
- CIRCT (Circuit IR Compilers and Tools) Project
- The official homepage for the CIRCT project, an LLVM/MLIR incubator looking to apply compiler technology to hardware design, including High-Level Synthesis (HLS) for FPGAs and ASICs.
- https://circt.llvm.org/
- CIRCT GitHub Repository
- The official GitHub repository for the CIRCT project, containing the source code, dialects, and tools for hardware compiler design.
- https://github.com/llvm/circt
گوگل AI سٹوڈیو اس مضمون کے لئے خلاصہ اور تحقیق کے لئے استعمال کیا گیا تھا. آپ اسے یہاں تلاش کرسکتے ہیں:
گوگل AI سٹوڈیو اس مضمون کے لئے خلاصہ اور تحقیق کے لئے استعمال کیا گیا تھا. آپ اسے یہاں تلاش کرسکتے ہیں:
تمام تصاویر مصنف کی طرف سے NightCafe سٹوڈیو کے ساتھ آزادانہ طور پر پیدا کیا گیا تھا، ذیل میں لنک پر دستیاب ہے:
تمام تصاویر مصنف کی طرف سے NightCafe سٹوڈیو کے ساتھ آزادانہ طور پر پیدا کیا گیا تھا، ذیل میں لنک پر دستیاب ہے:
https://creator.nightcafe.studio/