Skip to content

docs/design.md: v_pack_b32_f16 abs is implemented, not refused - #5574

Open
evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/7-pack-b32-abs-row
Open

evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/7-pack-b32-abs-row

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

The v_pack_b32_f16 "input neg" row of the translator contract table (docs/design.md:286) said the translator still refuses abs on this instruction, and cited tests/test_values.py and tests/semantic/test_vop3_const_mods.py as its check.

The code does the opposite: tools/rdna2spirv.py:6278-6283 clears bit 15 for an abs operand before the neg xor of bit 15 (accepted in 1062df5, the follow-up of #1570), and tests/semantic/test_pack_b32_f16_mods.py translates v_pack_b32_f16 v0, |v1|, v1, -|v1| and the op_sel:[1,0,0] high-half forms over the edge floats and pins the exact bits. tests/test_values.py:91-93 has the matching v_pack_b32_f16_abs_lo / _abs_snan / _neg_abs cases.

This rewrites that sentence to what the code and the tests do, cites the test that covers the rule, and points at the source-modifiers row below for the RDNA2 measurement instead of restating it.

Reported as #5517.

Test (docs-only change; the semantic test is the behaviour the row now describes):

python -I tests/semantic/test_pack_b32_f16_mods.py
Ran 6 tests in 0.696s
OK

python -I tests/test_docs_design_rows.py   -> OK
python -I tests/test_docs_table_rows.py    -> OK
python -I tests/test_docs_table_ids.py     -> OK
python -I tests/test_docs_links.py         -> OK

No GPU needed.

Notes

AI-assisted.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 07df005 on Windows 11. The revised description matches the translator. I used the source word 0xfc01bc00 with op_sel:[1,0,0] to select its high half. The CPU interpreter returns 0xfc01 for v1, 0x7c01 for |v1|, 0x7c01 for -v1, and 0xfc01 for -|v1|. The last case distinguishes clearing the sign before negation from clearing it afterward. The payload stays intact.

I ran py -3.14 -I scripts/run_gpu_tests.py --build E:/Leonida-review-work-build/RelWithDebInfo --filter ps_f16_pack_mods --require-pass with Vulkan validation enabled. The translated fixture matches all 4,096 expected pixels on the RTX 4090 and all 4,096 on the AMD Radeon iGPU. This checks the translated fixture. The separate raw ISA measurements remain those cited in the row.

All six tests in tests/semantic/test_pack_b32_f16_mods.py and all 14 tests in the four documentation checks named in the PR pass.

AI-assisted.

The 'input neg' row said abs is still refused and cited tests/test_values.py and tests/semantic/test_vop3_const_mods.py. tools/rdna2spirv.py:6278-6283 clears bit 15 for abs before the neg xor, and tests/semantic/test_pack_b32_f16_mods.py translates |v1|, -|v1| and op_sel halves and pins the bits. Say that, cite the tests, and point at the source-modifiers row for the RDNA2 measurement (issue ItsNotRexed#5517).

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head e755da4b5 (rebased onto current main 561b65a83; the earlier 07df005cb conflicted with the round-44 docs rewrite, this one is clean). Docs only; git diff --check clean (1 line).

Verified the new row against the code: v_pack_b32_f16 clears bit 15 for abs before the neg XOR. Tests: python -I -m pytest tests/test_values.py -q -> 59 passed; python tests/semantic/test_vop3_const_mods.py -> 11 tests OK; python tests/semantic/test_pack_b32_f16_mods.py -> 6 tests OK; ps_f16_pack_mods is in runtime/test/shaders/check.py:361.

Verdict: merge.

@memorypressure

Copy link
Copy Markdown

Verified against main 561b65a: the claim is accurate — the translator now implements abs for v_pack_b32_f16 as a bit-15 clear before neg (rdna2spirv.py:6977, measured on gfx1036 across 1,088 kernels per SHADER-260) while the row still says abs "is still refused … unmeasured", so the doc is genuinely stale. The conflict with current main is mechanical, not substantive: round-44 edited the adjacent "Packed 16-bit integer ops" row and git lands both edits in one hunk without an anchor line — keeping main's pk row plus your v_pack row resolves it, which is exactly what I did: all six docs guards pass, and test_pack_b32_f16_mods runs 6/6 with the named GPU fixture present. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@kapitche

Copy link
Copy Markdown
Contributor

Tested e755da4 merged with main 561b65a on Linux (WSL2), Python 3.12.16: pass

Docs-only (the v_pack_b32_f16 input neg row of docs/design.md). tests/test_docs_*.py: 11 files run, 11 OK, 0 failed. tests/semantic/test_pack_b32_f16_mods.py (named by the new text): 6 run, 6 passed.

Claim checked against main: tools/rdna2spirv.py v_pack_b32_f16 (line 6975 onward) does implement abs as & 0x7FFF on the selected half, applied before the neg XOR 0x8000, so "abs is still refused" was stale and the new sentence is correct. The files the row cites exist (tests/semantic/test_pack_b32_f16_mods.py, runtime/test/shaders/ps_f16_pack_mods.asm). The row still has the same cell count and no new pipes.

Unrelated to this PR, noticed while reading: the next row on main, "v_pack_b32_f16 source modifiers" (docs/design.md line 294), has garbled text in the middle (repeated "**neg, abs, and `-" fragments); it is the same on main, so not caused by this change.

Negative control: not applicable to a prose change.

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