Skip to content

sass identity: nvcc under setarch -R, so unchanged rebuilds repeat - #5170

Merged
ashhart merged 4 commits into
ashhart:mainfrom
atakann:sass-no-aslr
Nov 26, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
atakann:sass-no-aslr

Conversation

@atakann

@atakann atakann commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What this changes

cuda_sass_compare.py builds every image with its usual nvcc command, now under setarch <machine> -R, and stops before any build when setarch is refused. Before, unchanged rebuilds on a GB10 could disagree because nvcc's front end emits PTX whose form follows heap addresses (#5123), so the control stage failed as unstable.

Measurements on the GB10, nvcc 13.3.73 in the TensorFold build image, zig/kernels/cuda/inkling2/ops.cu with the image's glue flags:

build repeats distinct
nvcc -ptx, compute_120, randomization on 6 3 PTX
the same under setarch aarch64 -R 6 1 PTX
the tool's nvcc -fatbin, five SMs, under setarch -R 5 1 SASS on every SM

Checks on this head

Receipt

n/a: a tool change, no kernel source or build file changes. Used for #5068's qualified run: SUMMARY PASS images=1 functions=90 scope=all-reached (https://gist.github.com/atakann/7e6ad7b48ca51f4ca7827b807f3288a4).

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

@Bizuayeu

Copy link
Copy Markdown
Contributor

The note in #5157 stays true: this makes a run's builds repeat on one machine, it does not pick a canonical form.

[...] so base, head and control builds have to run in one environment, which the tool already does.

(#5170)

That holds, and since that comment I checked the images, which bears on this change (my correction on #5157: #5157 (comment)). The router-tiles PTX forms that keep the common register count assemble to the common cubin byte for byte. Under setarch -R, all eight environments I tried gave the common router-tiles image: nvcc 13.0.88 and 13.3.73, compute_80 and compute_86, a 200-character source directory, and 1 KiB or 4 KiB more environment. That includes one environment where the PTX form moved: 13.3.73 at compute_80 repeated a4752fb0 by default and b5e37081 with 4 KiB more, and both assemble to one cubin. With randomization on, the same kernel changed the image in 1 to 9 of 100 compute_80 compiles, so for the router tiles these runs support building under setarch -R. They cover those kernels only, and eight layouts.

One case "one environment" may leave open: the nvcc command names the tree (-I{tree}/zig/kernels/cuda and the source path), so when base and head are given as checkout directories at paths of different lengths, their compiles differ in argument size, and the layout can follow that. In my runs one size change moved a PTX form (the 4 KiB one on 13.3.73) and none changed the image; I haven't measured whether equal-length paths give equal layouts.

If the recipe gets a line for this change, one sentence of #5157's section could say the images' side too: "a register count alone does not establish stability" holds for the PTX, but in every form I have seen, the image changed only when the register count did, and the record comments' "(8/100, 9/50)" are 13.3.73's PTX counts (its image counts were 1 of 100 and 0 of 50).

@ashhart

ashhart commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thank you, @atakann. The implementation does the important parts: every compiler build uses setarch <machine> -R, a refused personality change stops before compilation, and the base/head/control trees and compile folders now have equal-length names. The branch merges cleanly.

Two small changes remain:

  • tools/zig/cuda_sass_compare.py:185: the added one-line docstring is 135 columns; please shorten it to the 120-column limit while retaining the equal-length path rationale.
  • tools/zig/cuda_sass_identity_test.py:91-94: the test checks only the FIXED constant, so it still passes if build stops using it. Please mock the subprocess call, invoke build, and assert that the actual compiler command contains setarch <machine> -R before nvcc.

Your unchanged-build measurements are useful evidence; no further source issue was found in this read-only review.

  • Synthena

@ashhart

ashhart commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thank you—both requested changes are now addressed. The docstring fits the line limit while preserving the path-length rationale, and the test now exercises the real build path and checks the actual compiler command.

The fixed-address probe stops on refusal, every compiler build uses the wrapper, and the base, head and control paths keep equal lengths. I found no further source issue in this review.

The remaining validation is one unchanged-image comparison on the target compiler device: repeat the builds, require exact instruction and encoding identity across the supported targets, keep the planted controls enabled, and confirm the recorded command uses the fixed-address wrapper. No checkpoint is needed.

  • Synthena

@atakann

atakann commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The unchanged-image comparison on the GB10 with this branch's tool (62cb16b; 570ffbc only names the control's compile folder once, rewords its docstring and extends the test): main 67ae36c against #5068's head 254f961, nvcc 13.3.73, sm_80/86/89/120/121. SUMMARY PASS images=1 functions=90 scope=all-reached, qualified: true; every function and encoding equal, and the unchanged rebuilds repeat. Each recorded command starts nice -n 19 setarch aarch64 -R /usr/local/cuda/bin/nvcc -fatbin.

Both planted controls stayed enabled and were detected. With equal-length paths the fp4pair control is now found in the NVFP4 expert kernels that read that constant (105 functions over 65 images). In the earlier run with control-0 paths it had stopped at tf_ctl_exl3_grouped_old_0/2, which as far as I can see do not read it, so the longer path had moved them. The warp_sum order control changes 127 functions in contract_controls.

@ashhart
ashhart merged commit c6f2f86 into ashhart:main Nov 26, 2026
2 of 12 checks passed
@ashhart

ashhart commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thank you @atakann. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants