Source-linked AI summary

Learning Exact NVIDIA SASS Encoders with $\mathbb{F}_2$ Linear Algebra

Jiading Gai

arXiv:2608.20532v1cs.LG

TL;DR

Recent NVIDIA data-center GPUs lack a public SASS assembler, limiting controlled rewriting of machine code. F2Asm learns exact 128-bit encoders over F2 from paired disassembly and CUBIN words, separating shared learning from target-specific rules. In round-trip tests, it reproduces all compared executable text sections exactly, while its supported architecture families remain bounded to specified targets.

  • Problem

    Recent NVIDIA data-center GPUs lack a public SASS assembler, limiting controlled machine-code rewriting.

  • Method

    F2Asm learns exact 128-bit SASS encoders as affine maps over F2 using Gaussian-elimination bases, with target-specific control, relocation, and metadata rules separated from learning.

  • Results

    All 3,225 text-bearing CUBINs passed round-trip testing, reproducing 150,214 executable sections and 3,407,092,992 bytes byte-for-byte.

  • Takeaways & Limitations

    F2Asm provides an open-source SASS assembler supporting Rubin SM107 and enables controlled SASS rewriting across current and future NVIDIA GPUs.

  • Takeaways & Limitations

    The reported results do not extend to SM100f, SM107a, or SM107f, and symbolic-address rows lacking unambiguous relocations are excluded from training.

Abstract

from arXiv · show

NVIDIA provides a SASS disassembler but no public SASS assembler for recent data-center GPUs, limiting controlled machine-code rewriting. We present F2Asm, which learns exact 128-bit SASS encoders from paired disassembly and original CUBIN instruction words. To our knowledge, F2Asm is the first system to learn SASS instruction encoders as vector-valued affine maps over F2 and the first open-source NVIDIA SASS assembler to support Rubin SM107. F2Asm uses Gaussian elimination over F2 to incrementally build a compact basis, detect inconsistencies, and reject inputs outside the learned span. F2Asm separates target-specific control bits, relocation rules, and CUBIN metadata from its learning algorithm. We train encoders for Hopper SM90/SM90a, Blackwell SM100, and Rubin SM107 using 3,225 CUBINs from pinned NVIDIA and third-party production libraries, CUDA 13.3 packages, and CUDA 13.4 Developer Preview archives. In round-trip tests, F2Asm reassembles the disassembled SASS for each CUBIN, and all compared executable text sections match the originals exactly.

1 INTRODUCTION

F2Asm addresses the lack of a public assembler for recent NVIDIA SASS by learning exact encoders from disassembly and original CUBIN words. It supports systematic SASS rewriting across GPU targets and achieves exact round-trip reconstruction.

  • Motivation: Recent NVIDIA data-center GPUs lack a public SASS assembler, despite nvdisasm recovering readable SASS from CUBIN machine code.This limits controlled materialization of selected SASS candidates as executable CUBINs.
  • Approach: F2Asm learns exact 128-bit SASS encoders from parsed disassembly paired with original CUBIN instruction words.Its learned encoders are represented as vector-valued affine maps over F2.
  • Architecture: Target-specific control bits, relocation rules, and CUBIN metadata are separated from the shared learning algorithm.This separation supports extension across Hopper, Blackwell, Rubin, and future GPU targets.
  • Application: F2Asm can serve a downstream SASS agent that searches for post-PTX optimizations, materializes supported candidates, rebuilds CUBINs, and enables external testing.The workflow follows CUDA-source optimization and compilation, then applies SASS-level search and deterministic assembly.
  • Approach: F2Asm uses incremental bitset Gaussian elimination to detect inconsistent evidence and retain a compact basis rather than every instruction-word pair.The algorithm supports deterministic training and exact support checks for learned encodings.
  • Evaluation: 3,225 CUBINs yielded exact round-trip reconstruction of 150,214 executable text sections containing 3.41 billion bytes.Every compared executable text section matched the original byte-for-byte.

2 EXACT BIT-LINEAR ENCODING

F2Asm models each architecture-specific instruction context as an exact affine encoder over F2, learning only mappings supported by observed feature rows. Streaming elimination maintains a compact basis, detects inconsistency, and emits words only for supported queries.

  • Feature representation: Each encoding model maps deterministic feature vectors for a form–partition pair to 128-bit instruction words over F2.Forms combine mnemonics with ordered operand types, while partitions separate regimes involving modifiers, signs, sentinels, and operand equalities.
  • Feature representation: The feature map includes a constant bit, little-endian operand bits, one-hot modifiers, sentinel flags, and selected pairwise interactions.The constant and operand subvectors are explicitly defined, making ϕ deterministic bit-vectorization rather than a learned embedding.
  • Affine encoding: Over F2, matrix multiplication selects feature-conditioned rows and combines them with XOR to produce each output bit.Scalar multiplication is AND, addition is XOR, and the output rows w_j are rows of W.
  • Streaming training: Streaming Gaussian elimination stores only linearly independent augmented rows, reducing memory use to the retained basis rather than the observation count.Each retained pair (r_k, z_k) records a feature equation and its transformed 128-bit output.
  • Consistency and support: Training reports contradictions for zero-input, nonzero-output residuals and requires consistency rather than full feature rank.The learned map is unique on the observed span, while extensions outside that span need not be unique.
  • Consistency and support: A query is encoded only when elimination reduces its feature vector to zero residual; otherwise F2Asm rejects it as unsupported.The accumulated transformed output is the unique supported value on the observed span.

3 TRAINING DATA AND PIPELINE

F2Asm builds authenticated, architecture-specific training corpora through checkpointed deterministic stages and isolates each encoding family in a target profile. The resulting basis compresses the observations substantially, while the reported scope excludes several architecture variants.

  • Training data: Training pairs come from authenticated, SHA-256-deduplicated CUBINs spanning pinned production libraries, CUDA 13.3 packages, and CUDA 13.4 Developer Preview archives.The corpora cover SM90/90a, SM100, and SM107.
  • Collector pipeline: The collector authenticates and validates CUBINs, parses verified disassembly shards, then replays records through streaming elimination with atomic manifests.Its three stages are checkpointed and preserve corpus order for model training.
  • Collector pipeline: The pipeline is deterministic, non-interactive, and emits machine-readable pass/fail manifests for automated target onboarding.An agent can use manifest failures to guide subsequent target-profile, corpus, training, and round-trip-test iterations.
  • Architecture scope: Each architecture profile fixes instruction width, control fields, relocation and metadata rules, parser recovery, and repository identity.SM90/90a share one qualified family, whereas SM100 and SM107 use separate families.
  • Architecture scope: The reported results do not extend to SM100f, SM107a, or SM107f.These variants lie outside the architecture families covered by the stated profiles.
  • Disassembly recovery: nvdisasm can hide encoding-significant distinctions, so F2Asm consults original instruction bits and restores them when safe.For one Rubin SM107 WARPSYNC.COLLECTIVE case, it recovers the omitted .PHASE1 modifier from bit 18.
  • Basis reduction: 212,937,948 observed instructions became 1,063,639 independent basis rows, a 200.2× reduction, with no invalid rows or contradictory mappings found.Excluded relocation-bearing observations were expected and audited.

4 ROUND-TRIP EXPERIMENTS

F2Asm uses strict round-trip reconstruction to qualify its encoders across CUBIN corpora and evaluates normalization requirements and Rubin-specific encoding coverage. The results show byte-exact reconstruction at scale and substantial compaction of observed SM107 encodings.

  • Strict round-trip qualification: All 3,225 text-bearing CUBINs passed strict round-trip testing with 0 failures and 0 errors.F2Asm reconstructed 150,214 executable sections containing 3,407,092,992 bytes byte-for-byte.
  • SM100 evaluation: SM100 normalization of exact QNaN payloads, symbolic registers, and PC-relative WARPSYNC targets reduced F2 conflicts from 5,830 to zero.The same 25,089,192 observations were used before and after normalization.
  • SM100 evaluation: The Blackwell corpus preserves its parallel per-kernel ELF namespace and associated metadata without relying on undocumented capsule semantics.All 30,491 .text.* sections have matching .nv.capmerc.text.* sections with accompanying metadata, relocations, symbols, and debug data.
  • SM107 results: SM107 compresses 17,977,652 admitted instruction occurrences into 238,190 basis rows, a 75.5× reduction.The median context rank is 3, and 95% of contexts have rank at most 21.

5 RELATED WORK

F2Asm extends prior CUDA assemblers by learning vector-valued affine encoding maps over F2, while treating instruction encoding and scheduling as separate problems. Its scheduler limitation defines a clear boundary around the current system.

  • Encoding approaches: F2Asm differs from earlier assemblers by learning vector-valued affine maps over F2 from disassembly–binary relationships.Earlier systems used manually recovered rules, automated format recovery, or arithmetic encoding relations.
  • Scheduling scope: F2Asm encodes explicitly supplied scheduler-control fields but does not synthesize or optimize them.Automatic scheduling requires latency models, dependency analysis, scoreboard-barrier allocation, and hardware validation.
  • Scheduling scope: Extending F2Asm with a target-aware scheduler remains future work, unlike CuAsmRL’s local schedule search with modeled safety constraints.CuAsmRL preserves original control fields while rejecting swaps that violate modeled register, barrier, latency, or synchronization constraints.

6 CONCLUSION

F2Asm provides an open-source, exact SASS encoding and CUBIN reconstruction system based on affine maps over F2, with support for Rubin SM107. Its scope includes qualified GPU targets and authenticated evidence, while some relocation-bearing observations remain constrained.

  • Conclusion: F2Asm learns exact 128-bit SASS encoders as affine maps over F2 and rejects unsupported inputs.Streaming Gaussian elimination builds compact bases and detects inconsistent evidence.
  • Conclusion: F2Asm is the first open-source SASS assembler reported to support instruction encoding and CUBIN reconstruction for Rubin SM107.The system is intended to support SASS coding agents, hand-tuned kernels, and direct-machine-code microbenchmarks.
  • Scope and qualification: Symbolic-address rows with ambiguous disassembly-to-relocation matches are excluded from training because instruction and linker-controlled bits cannot be safely separated.Unexpected skips were zero, and all CUBINs passed strict round-trip testing.

A SUPPORTED TARGETS

The evaluated implementation supports specific GPU targets with trained encoders and strict round-trip qualification, while additional architectures remain future work.

  • Supported targets have a trained encoder and completed strict round-trip release qualification.
  • SM90/SM90a share one encoder.
  • Extending F2Asm to additional SM architectures is future work.Onboarding requires a target profile, authenticated CUBIN training data, and strict round-trip qualification rather than a new learning algorithm.

B END-TO-END INSTRUCTION LIFECYCLE

F2Asm turns parsed SASS into an exact instruction word through offline basis construction and runtime basis queries, while keeping scheduler control separate from the learned payload.

  • An HMMA instruction is parsed into scheduler control, form, modifiers, and operand-role values before encoding.The example uses HMMA.16816.F32.BF16 with operands ordered as destination, source A, source B, and accumulator.
  • Gaussian elimination applies identical XOR row operations to feature equations and observed 128-bit instruction words.The resulting stored pairs contain reduced feature vectors and corresponding reduced instruction words.
  • The instruction lifecycle has training and runtime assembly phases.Training constructs a reusable exact basis; runtime assembly queries it and fails when the feature vector is unsupported.
  • A rank-16 basis supplies five selected stored pairs for the worked HMMA query.The remaining 11 basis pairs have zero reduction coefficient for this query.
  • F2Asm reconstructs the payload, merges separately represented scheduler control, emits 16 little-endian bytes, and verifies the rebuilt CUBIN.The rebuilt CUBIN passes the same byte-exact executable-text comparison used for strict whole-corpus qualification.

C STREAMING GAUSSIAN ELIMINATION EXAMPLE

The toy example shows streaming F2 elimination retaining one pair per pivot, detecting contradictions, and accepting or rejecting queries based on span membership.

  • The streaming basis stores at most one reduced pair per pivot and uses the highest set residual bit as the pivot.Real models apply the same algorithm to larger feature vectors and 128-bit instruction words.
  • Training processes observations incrementally and stores new rows only when they increase the rank.Observation order determines a deterministic basis, while redundant zero residuals are discarded.
  • A redundant observation with zero residuals is discarded, whereas a conflicting output for identical features produces a contradiction.The example contrasts a redundant observation with an alternative output that would leave a nonzero output residual.
  • An unseen query is supported when pivot reduction reaches zero residual and its accumulator gives the encoded instruction.The toy query 1110 visits pivots 3, 2, and 1 before successful reconstruction.
  • A nonzero residual proves the query lies outside the learned basis, so F2Asm discards partial output and reports it unsupported.
Loading 2608.20532v1…