Repository navigation
studio: lift the H3 binary preflight into its own method - #8570
danielhanchen wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55079a9101
ℹ️ 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".
| native_device, listed_accelerator, binary = self._h3_native_binary( | ||
| cancel_event = cancel_event | ||
| ) |
There was a problem hiding this comment.
Honor cancellation before acquiring sd-cli
When unload() sets the load's cancellation event before this worker reaches the call—or while acquisition is running—the new ordering still enters ensure_h3_sd_cpp_binary, whose installer does not consume cancel_event and may download/extract an entire prebuilt before the later asset-loop check notices cancellation. Previously, an already-cancelled H3 load stopped at the first asset-loop check before reaching binary installation. Check the event before this call and make the acquisition path cancellable so cancelling a load does not leave a potentially minutes-long background download running.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in cf6c648. _h3_native_binary now raises VIDEO_CANCELLED_MSG when cancel_event is already set, restoring the stop the download loop's own first check used to provide. Making the install itself consume cancel_event is a separate change: ensure_h3_sd_cpp_binary and the prebuilt installer take no cancel token, and that was equally true before this reorder, so this fix is scoped to the case the reorder actually regressed. Regression test: test_h3_native_load_stops_on_an_already_cancelled_load_before_acquiring.
| native_device, listed_accelerator, binary = self._h3_native_binary( | ||
| cancel_event = cancel_event | ||
| ) |
There was a problem hiding this comment.
Publish H3 companion repos before acquiring sd-cli
When sd-cli installation takes time and a user deletes H3_GGUF_REPO or H3_COMPONENT_REPO concurrently, this new call runs before _loading.asset_repos is populated, so the cached-model deletion guard can admit the delete and reserve it before the H3 download begins. Publishing the repos later does not revoke an already-started deletion, which can then remove cached or newly resolved files underneath this load. Move the companion-repo publication ahead of binary acquisition while leaving the byte estimate update where it is.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in cf6c648. The base_repo and asset_repos claim now happens before _h3_native_binary, so the delete-cached guard cannot admit a delete of the H3 companion repos during an install that may run for minutes. The byte estimate stays where it was, since the sizes are not known any earlier. Regression test: test_h3_native_load_claims_the_companion_repos_before_acquiring_the_binary, which asserts the claim is already visible inside the acquisition.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2e5dd38c4
ℹ️ 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".
| native_device, listed_accelerator, binary = self._h3_native_binary( | ||
| cancel_event = cancel_event | ||
| ) |
There was a problem hiding this comment.
Re-vet unmanaged binaries after the download
When SD_CLI_PATH/UNSLOTH_SD_CPP_PATH points to a user-supplied binary that is replaced while the tens-of-GB bundle downloads, this early check vets the old file, but the final check only calls sd_cpp_supports_minimax_h3 and compares accelerator support when is_managed_binary(binary) is true. The replacement therefore needs only to pass engine.version() before its identity is committed, so an older or differently accelerated external build can make the load report ready and then fail generation or violate device accounting. Re-run the capability/device checks for unmanaged binaries after the download as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in 372da2c. The is_managed_binary guard was sound while the vet sat immediately above the re-vet, since only an install can replace a copy we own, but vetting before the download turns that window into the whole bundle. _h3_native_binary now returns the identity of the file its answers came from, and the re-vet re-opens both the capability and the accelerator question whenever that identity changed, managed or not. Gating on identity rather than probing unconditionally keeps the ordinary case free, since an unchanged file cannot have changed its answers. Regression test: test_h3_native_load_rejects_a_user_binary_swapped_during_the_download, which swaps the binary from inside the download callback.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Status check on this PR's CI, since the board looks far worse than it is.
The last head with a completed CI set is That is main's own defect, reproduced on a clean checkout with no PR applied, and it is what #8590 and #8608 fix. This PR is blocked behind those two merging, not broken. Local runs on this head: The single local failure, Stated plainly: head |
_run_load_h3_native is about assets, and the block that acquires the sd-cli, installs it, probes its device list and decides native_device now sits at the top of it because #8560 moved that work in front of the download. Nothing in the block reads a resolved path, so it reads better as _h3_native_binary returning the three values the rest of the load needs. Pure move. The behaviour it encodes -- the entry and exit cancellation checks, the accelerator fallback, the refusal when no binary could be produced -- is unchanged, which the 168 platform x GPU vendor cases in test_sd_cpp_h3_matrix.py pin without modification.
d099ab4 to
781ea7e
Compare
|
Rewritten against main now that #8560 has landed. The reordering this PR opened for is on main, along with several things that turned out to be needed alongside it: the refusal when no binary can be produced, cancellation checks either side of the ensure, and a post-download re-vet that covers identity, capability and the accelerator reading for user-supplied builds rather than only managed ones. Keeping those here would have been a duplicate, so the branch has been reduced to the structural half it also carried, and force-pushed. What remains is the extraction of the acquisition block into |
|
Superseded by #8560, which landed the preflight hoist and the cancel check with the same reasoning, and also did the unmanaged re-vet. #8560's version of that last one is better than mine: it drops the is_managed_binary test outright rather than gating on a changed identity, checks sd.cpp identity as well as the H3 marker (--ref-video alone is a plain option name an unrelated tool could expose), and uses a verdict form for the accelerator probe that does not fold 'could not tell' into True, which removes a false-refusal my version still carried. The one thing left over is the companion-repo claim ordering: asset_repos is still set after the preflight on main, so the delete-cached guard is blind for the whole prebuilt install. That is now #8657, cut fresh from main with its regression test. |
Summary
Lifts the MiniMax-H3 binary preflight out of
_run_load_h3_nativeinto its own_h3_native_binarymethod. Pure refactor, no behaviour change.Why this PR shrank
It originally moved the preflight in front of the four-file download. #8560 shipped that, along with the refusal when no binary can be produced, the cancellation checks either side of the ensure, and a post-download re-vet that covers identity, capability and the accelerator reading for user-supplied builds as well as managed ones. All of that is on main, so it has been dropped from here and the branch rewritten against main.
What is left is the structural half.
_run_load_h3_nativeis about assets, and the block that acquires the sd-cli, installs it, probes its device list and decidesnative_devicenow sits at the top of it. Nothing in that block reads a resolved path, so it reads better as a named method returning the three values the rest of the load needs.Validation
test_sd_cpp_h3_matrix.py(168 cases over platform x GPU vendor x binary state) passes unmodified, which is the evidence the move changes nothing: those cases pin the cancellation ordering, the download-count on every refusal, the accelerator fallback and the device-probe count.test_video_backend.py,test_sd_cpp_backend.py,test_sd_cpp_engine.py: 530 passed. The one failure,test_a_quantized_reference_load_resolves_the_reference_denoiser, fails on main too and is environmental (the installed diffusers lacks the bundled H3 revision).