Skip to content

Tests: stub the read-bytes probe in the load progress fraction tests - #17703

Merged
danielhanchen merged 1 commit into
mainfrom
tests-load-progress-fake-pid
Nov 13, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
tests-load-progress-fake-pid

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Three tests in studio/backend/tests/test_load_progress_ready_fraction.py fail now and then on PRs that do not touch the llama.cpp backend (seen on a (Python 3.13, g-l) run for #16564, an Appearance theme change):

test_mmap_phase_reports_raw_rss_fraction    assert 1.0 == 0.08
test_progress_fraction_is_monotonic         assert 1.0 == 0.9
test_none_when_rss_unreadable               assert {'phase': 'mmap', 'bytes_loaded': 10000, ...} is None

The tests build a backend whose fake process has pid 4321 and stub _read_rss_bytes. Since #14909, load_progress also reads _read_load_bytes(pid), which opens the real /proc/<pid>/io. These tests never stubbed it. When a process with pid 4321 happens to exist on the runner and is readable, its rchar (far above the 10,000 byte fake shard) becomes bytes_loaded, so the fraction reads 1.0 and the "RSS unreadable" case no longer returns None.

load_progress is right to take the larger of RSS and bytes read; the tests were missing a stub.

Change

  • An autouse fixture stubs LlamaCppBackend._read_load_bytes to None for this file. These tests pin the RSS arithmetic; the read-bytes probe has its own coverage in test_llama_weight_placement.py.
  • The fake process now uses the test's own pid instead of 4321. That pid is always live and readable, so a test that forgets the stub fails every time instead of only when the pid happens to be taken.

Test only, no product code changes.

Testing

  • test_load_progress_ready_fraction.py: 9 passed.
  • Main's file with the pid set to a live one fails exactly the three tests above, with the same assertions as CI.
  • This file with the fixture made non-autouse fails the same three.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T19:57:38.606573Z 7bfef8d Manual request
ℹ️ 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

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 7bfef8d92a

ℹ️ 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 178b5c3 into main Nov 13, 2026
@danielhanchen
danielhanchen deleted the tests-load-progress-fake-pid branch November 13, 2026 20:00
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