• bitcoinBitcoin(BTC)$64,340.000.36%
  • ethereumEthereum(ETH)$1,872.470.71%
  • tetherTether(USDT)$1.000.00%
  • binancecoinBNB(BNB)$568.810.76%
  • usd-coinUSDC(USDC)$1.00-0.01%
  • rippleXRP(XRP)$1.100.75%
  • solanaSolana(SOL)$74.380.77%
  • tronTRON(TRX)$0.3312220.23%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.032.97%
  • HyperliquidHyperliquid(HYPE)$58.131.36%
  • dogecoinDogecoin(DOGE)$0.0717513.50%
  • USDSUSDS(USDS)$1.000.00%
  • RainRain(RAIN)$0.013808-1.88%
  • leo-tokenLEO Token(LEO)$9.700.78%
  • zcashZcash(ZEC)$483.94-0.59%
  • moneroMonero(XMR)$364.410.39%
  • whitebitWhiteBIT Coin(WBT)$56.150.49%
  • chainlinkChainlink(LINK)$8.370.53%
  • cardanoCardano(ADA)$0.1648930.63%
  • stellarStellar(XLM)$0.1784610.64%
  • CantonCanton(CC)$0.1219262.47%
  • daiDai(DAI)$1.000.00%
  • bitcoin-cashBitcoin Cash(BCH)$209.74-0.26%
  • USD1USD1(USD1)$1.00-0.01%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.491.95%
  • Ethena USDeEthena USDe(USDE)$1.000.00%
  • litecoinLitecoin(LTC)$46.500.53%
  • Global DollarGlobal Dollar(USDG)$1.00-0.01%
  • hedera-hashgraphHedera(HBAR)$0.0709040.26%
  • Circle USYCCircle USYC(USYC)$1.130.00%
  • avalanche-2Avalanche(AVAX)$6.787.82%
  • suiSui(SUI)$0.710.28%
  • shiba-inuShiba Inu(SHIB)$0.00000516.80%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.03%
  • crypto-com-chainCronos(CRO)$0.056493-1.14%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • tether-goldTether Gold(XAUT)$4,052.410.05%
  • nearNEAR Protocol(NEAR)$1.79-0.62%
  • uniswapUniswap(UNI)$3.68-2.32%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.140.14%
  • OndoOndo(ONDO)$0.379886-0.57%
  • BittensorBittensor(TAO)$191.530.41%
  • pax-goldPAX Gold(PAXG)$4,051.270.06%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.056132-2.26%
  • okbOKB(OKB)$83.111.02%
  • AsterAster(ASTER)$0.630.01%
  • HTX DAOHTX DAO(HTX)$0.000002-0.61%
  • MemeCoreMemeCore(M)$1.221.81%
  • Ripple USDRipple USD(RLUSD)$1.000.01%
  • usddUSDD(USDD)$1.000.00%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

Designing High-Performance GPU Kernels with TileLang: Tensor-Core GEMM, Fused Softmax, FlashAttention, and Autotuning

July 25, 2026
in AI & Technology
Reading Time: 3 mins read
A A
Designing High-Performance GPU Kernels with TileLang: Tensor-Core GEMM, Fused Softmax, FlashAttention, and Autotuning
ShareShareShareShareShare

YOU MAY ALSO LIKE

God Of War Laufey Will Hit PS5 On February 16

Meet Open Dreamer: A JAX/Flax Reproduction of the Dreamer 4 World Model Pipeline, With the Full Training Recipe Published

@tilelang.jit(out_idx=[-1])
def make_matmul(M: int, N: int, K: int,
               block_M: int = 128, block_N: int = 128, block_K: int = 32,
               num_stages: int = 3, threads: int = 128,
               use_swizzle: bool = False,
               dtype: str = "float16", accum_dtype: str = "float"):
   @T.prim_func
   def main(A: T.Tensor((M, K), dtype),
            B: T.Tensor((K, N), dtype),
            C: T.Tensor((M, N), dtype)):
       with T.Kernel(T.ceildiv(N, block_N),
                     T.ceildiv(M, block_M),
                     threads=threads) as (bx, by):
           A_shared = T.alloc_shared((block_M, block_K), dtype)
           B_shared = T.alloc_shared((block_K, block_N), dtype)
           C_local = T.alloc_fragment((block_M, block_N), accum_dtype)
           if use_swizzle:
               T.use_swizzle(panel_size=10, enable=True)
           T.clear(C_local)
           for ko in T.Pipelined(T.ceildiv(K, block_K), num_stages=num_stages):
               T.copy(A[by * block_M, ko * block_K], A_shared)
               T.copy(B[ko * block_K, bx * block_N], B_shared)
               T.gemm(A_shared, B_shared, C_local)
           T.copy(C_local, C[by * block_M, bx * block_N])
   return main
def smem_bytes(block_M, block_N, block_K, stages, itemsize=2):
   return (block_M * block_K + block_K * block_N) * itemsize * stages
def section_2():
   banner("2. MEMORY HIERARCHY — tiled tensor-core GEMM")
   M = N = K = 2048
   bm, bn, bk, st = 128, 128, 32, DEFAULT_STAGES
   while smem_bytes(bm, bn, bk, st) > SMEM_CAP and st > 1:
       st -= 1
   print(f"   config: {bm}x{bn}x{bk}, num_stages={st}, "
         f"smem={smem_bytes(bm,bn,bk,st)/1024:.0f} KB")
   kernel = make_matmul(M, N, K, bm, bn, bk, num_stages=st, threads=128)
   a = torch.randn(M, K, device=DEV, dtype=torch.float16)
   b = torch.randn(K, N, device=DEV, dtype=torch.float16)
   c = kernel(a, b)
   check(c, a @ b, "matmul 2048^3")
   flops = 2 * M * N * K
   ms = bench(lambda: kernel(a, b))
   ms_ref = bench(lambda: a @ b)
   print(f"   tilelang : {ms:7.3f} ms  ->  {flops/(ms*1e-3)/1e12:6.2f} TFLOP/s")
   print(f"   cuBLAS   : {ms_ref:7.3f} ms  ->  {flops/(ms_ref*1e-3)/1e12:6.2f} TFLOP/s")
   print(f"   ratio    : {ms_ref/ms*100:5.1f}% of cuBLAS from ~20 lines of Python")
   src = kernel.get_kernel_source()
   for needle in ("mma.sync", "wgmma", "ldmatrix", "cp.async", "tl::gemm"):
       if needle in src:
           print(f"   emitted: {needle}")
   return kernel
def section_3():
   banner("3. KNOBS — sweeping the schedule by hand")
   M = N = K = 2048
   a = torch.randn(M, K, device=DEV, dtype=torch.float16)
   b = torch.randn(K, N, device=DEV, dtype=torch.float16)
   flops = 2 * M * N * K
   candidates = [
       (64,  64,  32, 2, 128, False),
       (128, 128, 32, 2, 128, False),
       (128, 128, 32, 2, 128, True),
       (128, 128, 32, 3, 128, False),
       (128, 128, 64, 2, 256, False),
       (128, 256, 32, 2, 256, False),
   ]
   print(f"   {'tile':>16} {'stg':>4} {'thr':>4} {'swz':>4} {'smem':>7} "
         f"{'ms':>8} {'TFLOP/s':>9}")
   results = []
   for bm, bn, bk, st, thr, swz in candidates:
       need = smem_bytes(bm, bn, bk, st)
       tag = f"{bm}x{bn}x{bk}"
       if need > SMEM_CAP:
           print(f"   {tag:>16} {st:>4} {thr:>4} {str(swz):>4} {need//1024:>5}KB "
                 f"  SKIPPED (over smem budget)")
           continue
       try:
           k = make_matmul(M, N, K, bm, bn, bk, num_stages=st,
                           threads=thr, use_swizzle=swz)
           c = k(a, b)
           ok = (c - (a @ b)).float().norm() / (a @ b).float().norm() < 2e-2
           ms = bench(lambda: k(a, b), warmup=5, rep=20)
           results.append((ms, tag, st, thr, swz))
           print(f"   {tag:>16} {st:>4} {thr:>4} {str(swz):>4} {need//1024:>5}KB "
                 f"{ms:>8.3f} {flops/(ms*1e-3)/1e12:>9.2f}"
                 f"{'' if ok else '   <- NUMERICALLY WRONG'}")
       except Exception as e:
           print(f"   {tag:>16} {st:>4} {thr:>4} {str(swz):>4}     -  "
                 f"failed: {type(e).__name__}")
   if results:
       best = min(results)
       print(f"\n   winner: {best[1]}, stages={best[2]}, threads={best[3]}, "
             f"swizzle={best[4]}  ({best[0]:.3f} ms)")
   print("   Takeaway: the best schedule is arch- and shape-dependent, which is")
   print("   exactly why section 7 exists.")

Credit: Source link

ShareTweetSendSharePin

Related Posts

God Of War Laufey Will Hit PS5 On February 16
AI & Technology

God Of War Laufey Will Hit PS5 On February 16

July 25, 2026
Meet Open Dreamer: A JAX/Flax Reproduction of the Dreamer 4 World Model Pipeline, With the Full Training Recipe Published
AI & Technology

Meet Open Dreamer: A JAX/Flax Reproduction of the Dreamer 4 World Model Pipeline, With the Full Training Recipe Published

July 25, 2026
EU Says TikTok Hasn’t Done Enough To Ensure Minors’ Safety
AI & Technology

EU Says TikTok Hasn’t Done Enough To Ensure Minors’ Safety

July 25, 2026
The 20 Percent Rule For Solar Panels Can Help You Save Money In The Long Run
AI & Technology

The 20 Percent Rule For Solar Panels Can Help You Save Money In The Long Run

July 25, 2026
Next Post
Suspects arrested in connection with Texas swimmer’s death

Suspects arrested in connection with Texas swimmer’s death

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Teledyne Technologies Incorporated (TDY) Q2 2026 Earnings Call Transcript

Teledyne Technologies Incorporated (TDY) Q2 2026 Earnings Call Transcript

July 22, 2026
Stock Market Today: Dow Futures Edge Up, What to Watch — Live Updates – WSJ

Stock Market Today: Dow Futures Edge Up, What to Watch — Live Updates – WSJ

July 24, 2026
Nominal Versus Real Dollars

Nominal Versus Real Dollars

July 24, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!