Add torch211-cxx11-cu130-aarch64-linux SM110 artifact
Browse filesFiles changed (4)
54 unmodified lines55565758596040 unmodified lines10110210310410510622 unmodified lines12913013113213313485 unmodified lines22022122222322422522622754 unmodified linesreturn None@torch.library.register_fake(add_op_namespace_prefix("fp8_linear_bias_gelu_quant_bf16"))def _fp8_linear_bias_gelu_quant_bf16_fake(input: torch.Tensor,40 unmodified linesreturn Nonedef _scalar_scale_like(input: torch.Tensor, value: float = 1.0) -> torch.Tensor:return torch.tensor([value], device=input.device, dtype=torch.float32)22 unmodified linesreturn outdef fp8_linear_bias_gelu_quant_bf16(input: torch.Tensor,weight: torch.Tensor,85 unmodified linesreturn out__all__ = ["fp8_gemm_bf16","fp8_gelu_mlp_bf16","fp8_linear_bias_gelu_quant_bf16",]54 unmodified lines55565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310440 unmodified lines14514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717822 unmodified lines20120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223385 unmodified lines31932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244354 unmodified linesreturn None@torch.library.register_fake(add_op_namespace_prefix("fp8_linear_bias_bf16"))def _fp8_linear_bias_bf16_fake(input: torch.Tensor,weight: torch.Tensor,bias: torch.Tensor,input_scale: torch.Tensor,weight_scale: torch.Tensor,out: torch.Tensor,) -> None:if input.dim() != 2 or weight.dim() != 2:raise RuntimeError("input and weight must be rank-2 tensors")if bias.shape != (weight.shape[0],):raise RuntimeError("bias shape must be (weight.shape[0],)")if out.shape != (input.shape[0], weight.shape[0]):raise RuntimeError("out shape must be (input.shape[0], weight.shape[0])")return None@torch.library.register_fake(add_op_namespace_prefix("bf16_fp8_linear_bias_bf16"))def _bf16_fp8_linear_bias_bf16_fake(input: torch.Tensor,weight: torch.Tensor,bias: torch.Tensor,input_scale: torch.Tensor,weight_scale: torch.Tensor,input_fp8: torch.Tensor,out: torch.Tensor,) -> None:if input.dim() != 2 or weight.dim() != 2:raise RuntimeError("input and weight must be rank-2 tensors")if input.shape[1] != weight.shape[1]:raise RuntimeError("input.shape[1] must match weight.shape[1]")padded_m = input_fp8.shape[0]if padded_m < input.shape[0]:raise RuntimeError("input_fp8 padded rows must cover input rows")if input_fp8.shape != (padded_m, input.shape[1]):raise RuntimeError("input_fp8 must have shape (padded_m, input.shape[1])")if bias.shape != (weight.shape[0],):raise RuntimeError("bias shape must be (weight.shape[0],)")if out.shape != (padded_m, weight.shape[0]):raise RuntimeError("out must have shape (padded_m, weight.shape[0])")return None@torch.library.register_fake(add_op_namespace_prefix("fp8_linear_bias_gelu_quant_bf16"))def _fp8_linear_bias_gelu_quant_bf16_fake(input: torch.Tensor,40 unmodified linesreturn None@torch.library.register_fake(add_op_namespace_prefix("bf16_fp8_gelu_mlp_bf16"))def _bf16_fp8_gelu_mlp_bf16_fake(input: torch.Tensor,up_weight: torch.Tensor,up_bias: torch.Tensor,down_weight: torch.Tensor,down_bias: torch.Tensor,input_scale: torch.Tensor,up_weight_scale: torch.Tensor,hidden_scale: torch.Tensor,down_weight_scale: torch.Tensor,input_fp8: torch.Tensor,hidden_bf16: torch.Tensor,hidden_fp8: torch.Tensor,out: torch.Tensor,) -> None:padded_m = input_fp8.shape[0]if input_fp8.shape != (padded_m, input.shape[1]):raise RuntimeError("input_fp8 must have shape (padded_m, input.shape[1])")if hidden_bf16.shape != (padded_m, up_weight.shape[0]):raise RuntimeError("hidden_bf16 has an invalid padded shape")if hidden_fp8.shape != hidden_bf16.shape:raise RuntimeError("hidden_fp8 must match hidden_bf16")if out.shape != (padded_m, down_weight.shape[0]):raise RuntimeError("out has an invalid padded shape")return Nonedef _scalar_scale_like(input: torch.Tensor, value: float = 1.0) -> torch.Tensor:return torch.tensor([value], device=input.device, dtype=torch.float32)22 unmodified linesreturn outdef fp8_linear_bias_bf16(input: torch.Tensor,weight: torch.Tensor,bias: torch.Tensor,input_scale: torch.Tensor,weight_scale: torch.Tensor,out: torch.Tensor | None = None,) -> torch.Tensor:"""Run an FP8-weight linear projection with BF16 bias and output.``input`` and ``weight`` use FP8 E4M3 with shapes ``(M, K)`` and``(N, K)``. Scales are device float32 scalar tensors. Pass ``out`` to keepthe call allocation-free for CUDA Graph capture."""if out is None:out = torch.empty((input.shape[0], weight.shape[0]),device=input.device,dtype=torch.bfloat16,)ops.fp8_linear_bias_bf16(input, weight, bias, input_scale, weight_scale, out)return outdef fp8_linear_bias_gelu_quant_bf16(input: torch.Tensor,weight: torch.Tensor,85 unmodified linesreturn outdef _midm_padded_rows(input: torch.Tensor) -> int:rows = input.shape[0]if (torch.version.hip is Noneand input.is_cudaand torch.cuda.get_device_capability(input.device) == (11, 0)and 9 <= rows <= 128):return ((rows + 63) // 64) * 64return rowsdef bf16_fp8_linear_bias_bf16(input: torch.Tensor,weight: torch.Tensor,bias: torch.Tensor,input_scale: torch.Tensor,weight_scale: torch.Tensor,input_fp8: torch.Tensor | None = None,out: torch.Tensor | None = None,*,pad_to: int | None = None,) -> torch.Tensor:"""Run a static-scale FP8 linear projection from a BF16 boundary.This traceable region entry quantizes ``input`` and computes the FP8projection with BF16 bias/output. Thor SM110 pads M=9..128 to a multiple of64 by default. Preallocate ``input_fp8`` and ``out`` for allocation-freeCUDA Graph replay."""logical_m = input.shape[0]padded_m = _midm_padded_rows(input) if pad_to is None else pad_toif padded_m < logical_m:raise ValueError("pad_to must be >= input.shape[0]")if input_fp8 is None:input_fp8 = torch.empty((padded_m, input.shape[1]), device=input.device, dtype=_fp8_dtype())if out is None:out = torch.empty((padded_m, weight.shape[0]),device=input.device,dtype=torch.bfloat16,)ops.bf16_fp8_linear_bias_bf16(input, weight, bias, input_scale, weight_scale, input_fp8, out)return out[:logical_m]def bf16_fp8_gelu_mlp_bf16(input: torch.Tensor,up_weight: torch.Tensor,up_bias: torch.Tensor,down_weight: torch.Tensor,down_bias: torch.Tensor,input_scale: torch.Tensor,up_weight_scale: torch.Tensor,hidden_scale: torch.Tensor,down_weight_scale: torch.Tensor,input_fp8: torch.Tensor | None = None,hidden_bf16: torch.Tensor | None = None,hidden_fp8: torch.Tensor | None = None,out: torch.Tensor | None = None,*,pad_to: int | None = None,) -> torch.Tensor:"""Run a static-scale FP8 GELU MLP from a BF16 region boundary.The op quantizes ``input`` and executes both FP8-weight GEMMs in onetraceable package call. Thor SM110 pads rows 9..128 to a multiple of 64;other targets keep the logical M unless ``pad_to`` is supplied. Passpreallocated buffers for allocation-free CUDA Graph replay. This is onecustom-op boundary, not a single CUDA launch."""logical_m = input.shape[0]padded_m = _midm_padded_rows(input) if pad_to is None else pad_toif padded_m < logical_m:raise ValueError("pad_to must be >= input.shape[0]")device = input.deviceif input_fp8 is None:input_fp8 = torch.empty((padded_m, input.shape[1]), device=device, dtype=_fp8_dtype())if hidden_bf16 is None:hidden_bf16 = torch.empty((padded_m, up_weight.shape[0]), device=device, dtype=torch.bfloat16)if hidden_fp8 is None:hidden_fp8 = torch.empty_like(hidden_bf16, dtype=_fp8_dtype())if out is None:out = torch.empty((padded_m, down_weight.shape[0]), device=device, dtype=torch.bfloat16)ops.bf16_fp8_gelu_mlp_bf16(input,up_weight,up_bias,down_weight,down_bias,input_scale,up_weight_scale,hidden_scale,down_weight_scale,input_fp8,hidden_bf16,hidden_fp8,out,)return out[:logical_m]__all__ = ["bf16_fp8_linear_bias_bf16","bf16_fp8_gelu_mlp_bf16","fp8_gemm_bf16","fp8_gelu_mlp_bf16","fp8_linear_bias_bf16","fp8_linear_bias_gelu_quant_bf16",]
123version https://git-lfs.github.com/spec/v1oid sha256:ec0844b1d17575d1e324ef9aac70c4ba78d464615bee9a1a9f3ae4bca51e8a41size 256720123456import torchfrom . import _flashrt_fp8_ffn_cuda_4a17df5ops = torch.ops._flashrt_fp8_ffn_cuda_4a17df5def add_op_namespace_prefix(op_name: str):return f"_flashrt_fp8_ffn_cuda_4a17df5::{op_name}"123456import torchfrom . import _flashrt_fp8_ffn_cuda_255584fops = torch.ops._flashrt_fp8_ffn_cuda_255584fdef add_op_namespace_prefix(op_name: str):return f"_flashrt_fp8_ffn_cuda_255584f::{op_name}"
1234567891011121314{"name": "flashrt-fp8-ffn","id": "_flashrt_fp8_ffn_cuda_4a17df5","version": 1,"license": "Apache-2.0","python-depends": [],"backend": {"type": "cuda","archs": ["11.0","12.1+PTX"]}}12345678910111213141516171819202122{"name": "flashrt-fp8-ffn","id": "_flashrt_fp8_ffn_cuda_255584f","version": 1,"license": "Apache-2.0","python-depends": [],"backend": {"type": "cuda","archs": ["11.0"]},"digest": {"algorithm": "sha256","files": {"__init__.py": "Lfpi4OMG3jS0AMFqtyCpL5H/nNuAzqtpwFaUnv2wgqo=","_flashrt_fp8_ffn_cuda_255584f.abi3.so": "7AhEsdF1ddHjJO+arHDEunjUZGFb7poanzrkvKUeikE=","_ops.py": "DjRVHDqNFmTPfak1/oS9Kq0Gncu1ODIrvbLkhemqRzI=","flashrt_fp8_ffn/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="}}}
build/torch211-cxx11-cu130-aarch64-linux/__init__.py+216
build/torch211-cxx11-cu130-aarch64-linux/_flashrt_fp8_ffn_cuda_255584f.abi3.soAdded+3
build/torch211-cxx11-cu130-aarch64-linux/_ops.py+3-3
build/torch211-cxx11-cu130-aarch64-linux/metadata.json+11-3