Skip to content

Pipeline archive: a base the GPU compiler rejects is left to the device; a failed archive no longer fails the build - #494

Closed
v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:pso-compiler-limit
Closed

v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:pso-compiler-limit

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

What and why

Reported in LNPANDY/NX2Apple#98: --platform mac-app for Super Mario Odyssey 1.4.1 on an M1 (applegpu_g13g) stops at the pipeline archive, and with it the whole build: [RED] pso_offline: metal-tt failed for applegpu_g13g (exit 1): Max Unstruct ID 642 in function agc.main in shader 13566 exceeds supported limit (and shader 15729), then air-tt: applegpu-nt command failed. The archive is an optimization; without it the app builds its pipelines on its first start.

shader N is not an index into the script. It is a job counter of the backend: a script of P pipelines uses 0 to 3P - 1, three per pipeline, in an order that changes between runs (checked with metal-tt on small scripts; one bad pipeline gives two messages). The failing base cannot be read off the number.

What is not known. With AIR-TT 32023.921 the same message is only a note on G13/G14 (synthetic functions at Max Unstruct ID 801 and 3009 on g13g, g13s, g13d, g14g, g14s: exit 0, archive written; none on g15g and later), as the existing entry for Odyssey's 758/642 says. Why the reporter's run exits 1 with only those lines is not established (another toolchain version, or a function whose own failure prints nothing else); the real Odyssey libraries were not available. So the change does not depend on the message being the cause:

  • pso_offline.py: when metal-tt fails and its log has the limit message, the bases that fail alone are found by halving the script (the messages of a half are counted, so a half holding all of them settles the other without a run; at most 160 runs), dropped, and the archive is built of the rest (at most 3 rounds, then it fails as before). Their pairs go into rest_pairs.tsv (the device builds them, as for function constants), archive.tsv lists them, and the console prints [RED] pso_offline: <arch>: N bases the compiler rejects (...) left to the device. Any other failure, or the message with no base that fails alone, stays fatal for pso_offline.py.
  • The rejected set is part of the archive's key (rejected.<arch>.tsv); a key that does not match starts again from every base, so a compiler that accepts them rebuilds with them.
  • build_ipa_from_nsp.py (Mac app) and build_ipa.sh (IPA): if pso_offline.py still fails, the build warns ([RED] line, the log's last lines, the stage ends with a warning: ⚠ in the console, warn: true in the JSON event, not ✗) and packs the app without an archive. --pso-strict / DM_PSO_STRICT=1 fails instead (CI, regress).
  • Docs: entry Bases the GPU compiler rejects, symptom index, development.md, Odyssey's note.

Workaround without this change: --gpu none (or PSO_GPUS = 'none').

Run time (from the code, not observed): a base the host cannot build is [RED] failed to create render pipeline, remembered in g_pso_fail, and its draws are skipped unless a stand-in covers them. Whether the run-time compiler on an M1 rejects the same Odyssey shader is assumed.

Checked

  • Tests: test_pso_offline (new Rejected: two named bases dropped, archive of the rest, rejected listed in rest_pairs.tsv / archive.tsv; one base per run takes rounds, and the round limit; other failures and the message with no failing base stay fatal; search budget; key changes with the rejected set, and a new toolchain starts again), test_nsp_mac_app (failed archive is a warning and the app is packed without it; strict fails; run(fatal=False)), test_nsp_progress (warn stage end), all test_nsp_*, test_docs, test_ci_toolchain, test_shader_regressions. The new pso_offline tests fail on upstream/main's file.
  • Real metal-tt (AIR-TT 32023.921, g13g) with a xcrun wrapper that turns the note into exit 1, 12 synthetic bases of which 2 are over the budget: both found (2 rounds of runs, 11 s in all), archive of the other 10, rest_pairs.tsv with the two pairs, reused on the second run.
  • Lint: lint_python.py 0 new.
  • Games run: none. Devices: Apple silicon Mac, macOS 26, for the synthetic runs only. Not checked: the real Odyssey shaders, the reporter's toolchain, the run-time behaviour on an M1, the IPA path of build_ipa.sh (shell change read, not run), regress.py (no game builds on this machine).

Docs

  • The finding is in its game note and its docs/reference/shaders.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • No chain tool changed
  • No game files, keys or data extracted from a game in the change

…ce, and a failed archive no longer fails the build

metal-tt on an M1 (applegpu_g13g) failed the whole archive with 'Max Unstruct ID N ... in shader M exceeds supported limit' (LNPANDY/NX2Apple#98). M is the backend's job
counter, not an index into the script, so pso_offline.py finds the bases that fail alone by halving the script, drops them, builds the rest (at most three rounds), and
leaves their pairs to the device (rest_pairs.tsv, archive.tsv). The rejected set is part of the archive's key. The NSP script and build_ipa.sh pack the app without an
archive when pso_offline.py fails (--pso-strict / DM_PSO_STRICT=1 fail instead); the stage ends with a warning.
@github-actions github-actions Bot added packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers ios The iPhone and iPad app (dm/ios) tools Tools and scripts (dm/tools, scripts) docs Documentation game: 0100000000010000 Super Mario Odyssey labels Nov 3, 2026
seedds added a commit that referenced this pull request Nov 4, 2026
…led archive is a warning: the app is packed without one instead of the build stopping (PR #494)

More than 1,000 bases are compiled in sequential groups and merged with
metal-pack; --batch-size 0 keeps one compiler run. Odyssey's 32,864 bases for
applegpu_g13g on a 16 GB Mac: one run 690 s and 636 s with swap rising from
about 5 GB to 22 GB; groups 315 s, swap at most 5.7 GB, an archive 1.8% larger.
A host of that chain found all 16 bases it probed in a merged g18g archive.
Opening a merged archive on an iPhone is not tested.

The PR's search for bases the compiler rejects is not taken: the two Max Unstruct
ID 642 lines of the M1's report are notes from one base, which compiles alone
with exit 0, and the full script exits 0 with the same two lines.

Front-ends: interface: a build whose pipeline archive fails now exits 0 with an app without one: its stage_end has warn: true and a [RED] say line follows (on an IPA build only the say line); the app builds the bases on its first start.

Co-authored-by: v0lumehi <34629096+v0lumehi@users.noreply.github.com>
@seedds

seedds commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Landed part of this on main as c0e150f, with you credited as co-author. Thanks!

Taken: a failed archive no longer stops the build. The app is packed without one, with a [RED] line and warn: true on stage_end. Your finding that shader N is a job counter is in Odyssey's note. I left out --pso-strict / DM_PSO_STRICT, because nothing sets them and pso_offline.py run by itself still fails.

Not taken: the search for rejected bases. You had flagged the message as maybe not being the cause, and testing here supports that. Using the reporter's chain (157e1b96c8da) and GPU (applegpu_g13g) with Metal 32023.922:

  • 3c3435a62e05975b + 007d7e411ef14ebd alone prints both Max Unstruct ID 642 lines, exits 0 and writes its archive in 12.6 s.
  • All 32,864 bases in one metal-tt run also exit 0, with the same two lines.

So the search would have narrowed down to that base and found nothing to drop.

Likely cause: memory. The attached log has only those notes and applegpu-nt command failed, the same message as the paging-space kill in #1119. This is inferred: the reporter's memory, kernel log and toolchain version are unknown. On a 16 GB Mac, one run took swap from about 5 GB to 22 GB. So the same commit makes groups of 1,000 the default: 315 s against 636 to 690 s, swap at most 5.7 GB, and an archive 1.8% larger.

Not tested: a merged archive on an iPhone, and this change on an 8 GB Mac or the reporter's M1.

@seedds seedds closed this Nov 4, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…led archive is a warning: the app is packed without one instead of the build stopping (PR seedds#494)

More than 1,000 bases are compiled in sequential groups and merged with
metal-pack; --batch-size 0 keeps one compiler run. Odyssey's 32,864 bases for
applegpu_g13g on a 16 GB Mac: one run 690 s and 636 s with swap rising from
about 5 GB to 22 GB; groups 315 s, swap at most 5.7 GB, an archive 1.8% larger.
A host of that chain found all 16 bases it probed in a merged g18g archive.
Opening a merged archive on an iPhone is not tested.

The PR's search for bases the compiler rejects is not taken: the two Max Unstruct
ID 642 lines of the M1's report are notes from one base, which compiles alone
with exit 0, and the full script exits 0 with the same two lines.

Front-ends: interface: a build whose pipeline archive fails now exits 0 with an app without one: its stage_end has warn: true and a [RED] say line follows (on an IPA build only the say line); the app builds the bases on its first start.

Co-authored-by: v0lumehi <34629096+v0lumehi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0100000000010000 Super Mario Odyssey ios The iPhone and iPad app (dm/ios) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants