Skip to content

Define _recover_vulkan_stall below the CPU fallback it calls - #15261

Merged
danielhanchen merged 1 commit into
mainfrom
ci-vulkan-stall-def-order
Oct 25, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-vulkan-stall-def-order

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

studio/backend/tests/test_model_memory_settings.py::TestNoNestedHelperIsUsedBeforeItsDef::test_every_nested_def_precedes_its_calls fails on main, so (Python 3.13, g-r) is red on unrelated PRs (for example #15225):

AssertionError: UnboundLocalError at runtime: _try_auto_vulkan_cpu_fallback called at 8198, defined at 8232

#14521 (load GGUF on CPU when the auto-selected Vulkan driver hangs) added the nested _recover_vulkan_stall inside load_model. It calls _try_auto_vulkan_cpu_fallback, which is defined about 40 lines further down. Today this does not raise: all three callers of _recover_vulkan_stall sit below both definitions, and a closure looks the name up when it runs. But the guard's rule is "a nested helper is defined above every textual use", because the looser version (the call is fine as long as every caller of the caller runs late enough) already shipped broken once and aborted every full-offload launch. Keeping that simple rule true is cheaper than teaching the guard call-graph ordering.

Change

  • Move _recover_vulkan_stall (unchanged, 19 lines) from just above _vulkan_stall_pending to just below _try_auto_vulkan_cpu_fallback. It is still above its first caller. Only defs sit between the old and new spots, and the defaults are literals, so nothing evaluates differently.

Verification

  • The diff is a pure move: every removed line is added back once.
  • test_every_nested_def_precedes_its_calls: fails on main, passes with this change.
  • test_vulkan_no_device_cpu_route.py, test_gpu_init_crash_message.py, test_load_mode_fit_matrix.py, test_vram_budget_settings.py, test_model_memory_settings.py: 1 failed, 2402 passed on main (the guard), 2403 passed with this change.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T13:08:17.920104Z — 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. Bravo.

ℹ️ 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 5cc1e43 into main Oct 25, 2026
2 of 47 checks passed
@danielhanchen
danielhanchen deleted the ci-vulkan-stall-def-order branch October 25, 2026 13:13
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