[PR #1261] tools/rdna2spirv: balance --shard by file size and fail fast on stat error (OLD-9779) #1293

Open
opened 2026-11-26 20:20:45 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1261
Author: @ambroseautomation
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: carry/old-9779-shard-size-balance


📝 Commits (2)

  • 533e3fa tools: --shard balances by size instead of taking every n-th shader
  • daf7362 rdna2spirv: a shard stops when it cannot size a file, instead of guessing 0

📊 Changes

2 files changed (+115 additions, -3 deletions)

View changed files

➕ tests/test_rdna2spirv_shard.py (+83 -0)
📝 tools/rdna2spirv.py (+32 -3)

📄 Description

Claimed in the coordination issue as: OLD-9779 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144358109)

What and why

Carries forward old-pr/9779 (draft #57, original commit author pes7 preserved across both commits; indexed in #17), rebased cleanly onto current main (0b45fdc21).

Replaces round-robin files[index::count] sharding in tools/rdna2spirv.py with deterministic size-balanced greedy bucketing (shard_bucket()):

  • Sorts input .asm files largest-first by os.path.getsize and assigns each to the lightest bucket so far, then returns the requested shard's bucket in name order — reducing parallel shader-stage makespan on skewed shader corpora while producing byte-identical output and requiring no inter-process coordination.
  • Fails fast with the failing file path if os.path.getsize raises OSError instead of silently substituting weight 0 (which could cause two shards to disagree on the partition and produce duplicates/holes on merge).
  • Adds tests/test_rdna2spirv_shard.py covering partition completeness/disjointness, cross-process determinism, single-shard passthrough, skewed-corpus balance vs. round-robin, and fail-fast behavior on unreadable file sizes.

Tested

  • python -I tests/test_rdna2spirv_shard.py -v: 5 tests, OK.
  • python -m compileall -q make_game.py tools tests: exit 0.
  • python -I tools/rdna2spirv.py --help: exit 0.
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_rdna2spirv_shard.py: exit 0 (no game data).

GPUs tested: n/a (CLI sharding logic + stdlib unit tests on Windows 11 Pro 64-bit, Python 3.12.10)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — CLI sharding only, no codegen changes)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1261 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `carry/old-9779-shard-size-balance` --- ### 📝 Commits (2) - [`533e3fa`](https://github.com/ubiquitarianism/leonida/commit/533e3faab3e67e345136e2399b6352bfe4bddc47) tools: --shard balances by size instead of taking every n-th shader - [`daf7362`](https://github.com/ubiquitarianism/leonida/commit/daf7362419ee2d4a700b95d1bbe046338dfdcc78) rdna2spirv: a shard stops when it cannot size a file, instead of guessing 0 ### 📊 Changes **2 files changed** (+115 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_rdna2spirv_shard.py` (+83 -0) 📝 `tools/rdna2spirv.py` (+32 -3) </details> ### 📄 Description Claimed in the coordination issue as: OLD-9779 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144358109) ### What and why Carries forward `old-pr/9779` (draft #57, original commit author `pes7` preserved across both commits; indexed in #17), rebased cleanly onto current `main` (`0b45fdc21`). Replaces round-robin `files[index::count]` sharding in `tools/rdna2spirv.py` with deterministic size-balanced greedy bucketing (`shard_bucket()`): - Sorts input `.asm` files largest-first by `os.path.getsize` and assigns each to the lightest bucket so far, then returns the requested shard's bucket in name order — reducing parallel shader-stage makespan on skewed shader corpora while producing byte-identical output and requiring no inter-process coordination. - Fails fast with the failing file path if `os.path.getsize` raises `OSError` instead of silently substituting weight 0 (which could cause two shards to disagree on the partition and produce duplicates/holes on merge). - Adds `tests/test_rdna2spirv_shard.py` covering partition completeness/disjointness, cross-process determinism, single-shard passthrough, skewed-corpus balance vs. round-robin, and fail-fast behavior on unreadable file sizes. ### Tested - `python -I tests/test_rdna2spirv_shard.py -v`: 5 tests, OK. - `python -m compileall -q make_game.py tools tests`: exit 0. - `python -I tools/rdna2spirv.py --help`: exit 0. - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_rdna2spirv_shard.py`: exit 0 (no game data). GPUs tested: n/a (CLI sharding logic + stdlib unit tests on Windows 11 Pro 64-bit, Python 3.12.10) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — CLI sharding only, no codegen changes) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1293
No description provided.