Skip to content

Measure the block dequant peak in a fresh process - #14579

Merged
danielhanchen merged 1 commit into
mainfrom
fix-block-dequant-peak-subprocess
Oct 21, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-block-dequant-peak-subprocess

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #14561. test_block_dequant_is_checked_for_its_peak_intermediates[mxfp8] failed again on #14539's Backend CI (Python 3.13, a-k) run (job 119508973440). That base already had #14561's least-of-three readings:

E   AssertionError: ([50331648, 50331648, 50331648], 57405440)
E   assert ([50331648, 50331648, 50331648] and 50331648 >= (0.9 * 57405440))

The smallest of three readings was still about 7 MB above the charge, so the extra memory is not a one-off spike. It is steady for the life of that pytest worker. The product's estimate is not the problem: the same torch (2.10.0+cpu, Python 3.13) measured alone gives charge / growth of 0.98 to 1.07 for both formats at 1, 2, 4 and 8 torch threads. A raised glibc mmap or trim threshold does not reproduce it either. What differs in CI is the worker's history: thousands of earlier tests, their threads and their allocator state all count toward the process-wide RssAnon this test reads.

Change

The measurement runs in a fresh python -c subprocess: same tensors, same sampler, same least of three, same 0.9 bar. The parent test only checks the JSON the child prints. Nothing else lives in that process, so the reading is the dequant's own.

Testing

  • Both parameters pass in three back-to-back runs. The whole test_diffusion_comfy_block.py file passes: 55 passed, 5 skipped.
  • Sabotage: charging only the bf16 output, dropping chunk * per_row in diffusion_comfy_block.py, fails both formats ([33554432] vs 47.9 MB / 51.1 MB).

This failure did not reproduce locally, so the subprocess is aimed at the one variable that differs from a clean run, rather than at a confirmed allocator mechanism.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T23:21:15.397650Z 520191f Manual request
🔒 Security Review ⚠️ Failed 2026-10-21T23:19:40.989181Z
We couldn’t complete this review. Comment @codex security review to try again.
520191f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 520191ff14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit d79a4dc into main Oct 21, 2026
@danielhanchen
danielhanchen deleted the fix-block-dequant-peak-subprocess branch October 21, 2026 23:22
danielhanchen added a commit that referenced this pull request Oct 29, 2026
… a fresh process (#15912)

The `(Python 3.13, a-f)` shard on #15906's staging run failed one test
the PR does not touch:

```
tests/test_diffusion_comfy_block.py:979: in test_int8_fp8_dequant_is_checked_for_its_float32_peak
    assert seen and max(seen) >= 0.9 * growth, (seen, growth)
E   AssertionError: ([201326592], 237703168)
```

The test passes on main and on #15906's head when run on its own.

## Cause

This is the flake #14579 already fixed for
`test_block_dequant_is_checked_for_its_peak_intermediates`. RssAnon is
process-wide, and in a long-lived xdist worker it carries whatever
earlier tests left behind. #14579 moved that test into a fresh process,
with a `malloc_trim` baseline and the best of three. Two siblings in the
same file kept measuring in the worker:
`test_int8_fp8_dequant_is_checked_for_its_float32_peak` and the peak
half of `test_swap_nibbles_is_bit_identical_and_checked_for_its_peak`.

The CI reading shows how far off a worker reading can be. Measured on
its own, the int8 ConvRot dequant grows by about two thirds of what it
charges. The worker saw 237.7 MB against the 201.3 MB charge.

## Fix

Both now run through the same kind of fresh-process probe as #14579
(`_HOST_PEAK_PROBE`, driven by `_host_peak_in_a_fresh_process`). The
assertion is unchanged: the charge must cover at least 90% of the
measured peak. The bit-identity half of the nibble-swap test still runs
in process. `_rss_anon_now`, now unused, is removed.

## Verification

Charge over measured growth in the fresh process, three runs each:

| op | charge / growth |
|---|---|
| int8 ConvRot dequant | 1.50, 1.50, 1.50 |
| fp8 dequant | 1.031, 1.035, 1.048 |
| nibble swap | 1.179, 1.027, 1.097 |

Each case stays above the 0.9 the test requires.

- `test_diffusion_comfy_block.py`: 55 passed, 5 skipped (CUDA-only),
serially and under `-n 8`.
- Sabotage: undercharging `_dequant` (`codes.numel() * 4` instead of the
float32 intermediates) fails both `float32_peak` cases in the fresh
process.
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.

1 participant