Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/amd-exec/fp8block.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / amd-exec / fp8block.py` 314 lines · 16011 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Independent checkpoint oracle and private-output acceptance for fp8gemv_b128. 4 Python is a measuring instrument only. Objects are emitted by seeded Omega hsaco.om. 5 Run under an externally held queen pool lock and nice; see fp8block.md. 6 """ 7 import argparse 8 from fractions import Fraction 9 import hashlib 10 import json 11 from pathlib import Path 12 import runpy 13 import shutil 14 import struct 15 import subprocess 16 17 PIN = '`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`' 18 NAME = 'fp8gemv_b128' 19 SHAPES = ((17408, 5120), (5120, 17408), (12288, 5120), (1024, 5120), 20 (10240, 5120), (6144, 5120), (5120, 6144)) 21 22 23 def sha(path): 24 with Path(path).open('rb') as f: 25 return hashlib.file_digest(f, 'sha256').hexdigest() 26 27 28 def ocp(byte, sg): 29 """F8_E4M3: sign, exponent bias7, 3 fraction bits, signed zero, two NaNs. 30 No executor/native-FNUZ conversion routine is used to construct this table. 31 """ 32 sign, exponent, fraction = byte >> 7, (byte >> 3) & 15, byte & 7 33 if exponent == 15 and fraction == 7: 34 return 0x7fc00000 35 if exponent == 0: 36 value = Fraction(fraction, 512) 37 else: 38 value = Fraction(8 + fraction, 8) * Fraction(2) ** (exponent - 7) 39 return sg['round32'](-value if sign else value) | (sign << 31) 40 41 42 def result(weights, x, scales, table, sg): 43 # Explicit wave order, not a claim of bit equality with serial Rust dot(). 44 acc = 0 45 for base in range(0, len(weights), 128): 46 lanes = [0] * 64 47 for lane in range(64): 48 for col in (base + lane, base + lane + 64): 49 if col < len(weights): 50 lanes[lane] = sg['fma'](table[weights[col]], x[col], lanes[lane]) 51 for xor in (32, 16, 8, 4, 2, 1): 52 lanes = [sg['fma'](a, 0x3f800000, lanes[i ^ xor]) for i, a in enumerate(lanes)] 53 acc = sg['fma'](scales[base // 128] << 16, lanes[0], acc) 54 return acc 55 56 57 def fixture(m, k, rows, table, sg, real=None, all_bytes=False): 58 nb, mb = (k + 127) // 128, (m + 127) // 128 59 wp = 64 60 xp = (wp + m * k + 63) & ~3 61 sp = xp + k * 4 + 64 62 yp = (sp + mb * nb * 2 + 67) & ~3 63 data = bytearray(b'\xa5') * (yp + m * 4 + 64) 64 struct.pack_into('