Skip to content

docs(design): tidy the f16 frexp/ldexp row - #4797

Open
liang-kai-shui wants to merge 1 commit into
ItsNotRexed:mainfrom
liang-kai-shui:proc-235-frexp-row
Open

liang-kai-shui wants to merge 1 commit into
ItsNotRexed:mainfrom
liang-kai-shui:proc-235-frexp-row

Conversation

@liang-kai-shui

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #4683 (comment)

Fixes PROC-235 (found by @Krashgamer): the contract row for v_frexp_mant_f16, v_frexp_exp_i16_f16 and v_ldexp_f16 in docs/design.md (line 415 on 98fa503f) contradicted itself in four ways, so a reader could not tell which rule the translation follows.

What changed (text only)

  • infinities and NaNs give the input unchanged and exponent 0 appeared twice, and the first copy still said denormals are "read as zero" next to "f16 denormals are kept"; now: zero -> signed zero / exponent 0, infinities and NaNs -> input unchanged / exponent 0, f16 denormals kept and normalized (with the measured 0x0001, 0x03ff words);
  • v_ldexp_f16 claimed "no denormal results" and then listed measured denormal results rounded to nearest even; now one rule: S1 clamped to [-64, 64], overflow -> ?infinity, below the smallest normal -> denormal rounded to nearest even (measured 0x0200, 0x0002, 0x0001, 0x0400 cases), zero/inf/NaN ignore S1;
  • "clamp and the output multipliers are rejected as unsupported" contradicted the later measured clamp behaviour; now: VOP3 clamp acts on the FP16 result of v_frexp_mant_f16/v_ldexp_f16 (hardware-verified on gfx1036, 302 kernels), omod (mul:2/mul:4/div:2) is rejected, and clamp on v_frexp_exp_i16_f16 is rejected;
  • "Not measured on hardware ... whether v_frexp_exp_i16_f16 keeps the high half ... is the translator's choice" contradicted the next sentence's gfx1036 measurement; now the measured paragraph says the high half is kept by all three, and only the NaN payload (and the IEEE 1 signalling-NaN quieting) remain not modelled.

The measured words (gfx1036, tools/hw_oracle, 65,536 inputs per frexp op and v_ldexp_f16 under 16 exponents) and the current translator behaviour are unchanged; tests/semantic/test_alu_frexp_ldexp_f16.py still holds the words quoted.

Tested

  • python -I tests/test_docs_links.py -> 6 tests OK; python -I tests/test_docs_design_rows.py -> 4 tests OK (the row's first cell is unchanged, so it is still one topic per table).
  • git diff --check clean; docs/design.md only, one row (1 insertion / 1 deletion).
  • No game data, no GPU.

Overlap: #2171 and #4311 edit this same row and are still open; this can be folded into whichever lands first (the text is the same rule set either way).

AI-assisted.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md ??not applicable (documents already-implemented rules).

@Krashgamer

Copy link
Copy Markdown
Contributor

Thanks for taking PROC-235. On the overlap with #2171: its only change to this row is the last sentence, which gains the GPU check. This PR leaves that sentence as main has it, so the conflict is mechanical: keep #2171's version of that sentence and your rewrite of the rest. #2171's sentence:

Checked on the CPU by tests/semantic/test_alu_frexp_ldexp_f16.py, which holds measured words (including VOP3 clamp), and on the GPU by runtime/test/shaders/cs_f16_frexp_ldexp.asm: check.py and run_gpu_tests.py compare the translated program's words for all 65,536 inputs of the three ops, v_ldexp_f16 under 21 exponents, with the same rule (exact on an RTX 3080, NVIDIA 610.88); not run on the shader corpus.

If this one lands first, I'll rebase #2171 onto it the same way.

@liang-kai-shui

Copy link
Copy Markdown
Contributor Author

Thanks - that is the plan. This PR only rewrites the contradictory rule sentences; the final "Checked on the CPU by ..." sentence is untouched, so when #2171 lands I will keep its GPU-check version of that sentence on top of the rewrite (mechanical conflict, as you said).

If #4311 lands first, the only text it should change is the omod clause: this rewrite currently states omod (mul:2/mul:4/div:2) is rejected, matching main's translator; if #4311 starts supporting them, that clause needs its measured wording from that PR. Nothing else in the row depends on it.

AI-assisted.

@DenRakEiw

Copy link
Copy Markdown
Contributor

Tested PR #4797 (565f095d1027bd38064e08ccd714dca0cdbe284d) on Windows 11 / Python 3.12.10.

  • Trial merge against origin/main (d974c88a): clean (exit 0), git diff --cached --check passed.
  • Tests:
    • python -I tests/test_docs_design_rows.py: Ran 4 tests in 0.046s — OK
    • python -I tests/test_docs_links.py: Ran 6 tests in 0.483s — OK
  • Code read: Docs-only cleanup of the v_frexp_mant_f16/v_frexp_exp_i16_f16/v_ldexp_f16 row in docs/design.md removing leftover pre-measurement/stale sentences (denormal flushing, rejected clamp, unmeasured claim) so the row consistently describes the hardware-verified behavior.

AI-assisted review (Gemini 4 Neon).

@kapitche

kapitche commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 565f095 merged with main 3faac55 on Linux (WSL2 Ubuntu, kernel 5.15), Python 3.12.16: pass.

  • tests/test_docs_*.py (10 files): 30 run, 30 passed, 0 failed (design_rows, table_rows, table_ids, links, repo_paths, list_items, cli_flags, env_vars, python_deps, pr_template).
  • tests/semantic/test_alu_frexp_ldexp_f16.py (the row's own test): 25 run, 25 passed, 0 failed.
  • Claims checked against the code: the row keeps its Unsupported statements (mul:2 / div:2 on v_frexp_mant_f16 and v_ldexp_f16, and clamp / mul:2 on v_frexp_exp_i16_f16 are asserted with assertRaises in that test; I also ran mul:4 on the three ops and div:2 on v_frexp_exp_i16_f16 by hand and each raises Unsupported), and the VOP3 clamp for frexp_mant_f16 / ldexp_f16 is implemented in tools/rdna2spirv.py. The removed sentences (zero/denormals "read as zero", S1 clamp [-64, 64] stated twice, "no denormal results", "Not measured on hardware") are the ones the row's later text contradicts. No new table pipes or escapes; the row is a single line.
  • Negative control: not applicable (docs-only change, no behaviour or test change); the docs tests pass on main as well.

@memorypressure

Copy link
Copy Markdown

Verified on current main: the tidy merges cleanly into the row main has not otherwise touched, and all five docs-consistency tests (repo paths, CLI flags, design rows, contract rows, links) pass on the merged tree. Confirmed on the merged text that both dropped sentences are gone and the surviving mentions sit on the f32 row where they belong — the removed denormals-read-as-zero clause contradicted the same row's own f16-denormals-are-kept statement and its measured words, so nothing measured is lost. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

PROC-235: the contract row repeated "infinities and NaNs give the
input unchanged and exponent 0", said denormals are both read as zero
and kept, claimed v_ldexp_f16 produces no denormal results before
listing measured denormal results, contradicted itself on clamp (and
omod) support, and still called the destination's high half unmeasured
despite the gfx1036 measurement. Rewrite those sentences to one
self-consistent rule set; the measured words and the current translator
behaviour are unchanged.
@kapitche

Copy link
Copy Markdown
Contributor

Tested 54e0952 merged with main 8575d36 on Linux (WSL2) / Python 3.12.16: concern
The real merge conflicts in docs/design.md: main has changed the v_frexp_mant_f16, v_frexp_exp_i16_f16, v_ldexp_f16 row (the denormal sentence now differs), the same row this PR tidies. I aborted the merge, so no tests were run on the merged tree.
The PR's own diff is one line in docs/design.md and needs a rebase onto current main, redoing the tidy on main's text of that row.
Earlier comments on this PR are on 565f095; none is on this head.

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.

5 participants