fix: restore model customization reuse state - #6264
Conversation
Restore deployment metadata when ModelBuilder reuses a package-backed Model but cannot reuse its endpoint. Preserve explicit resource requirements and recover recipe compute or LoRA adapter state only when creating the replacement endpoint. Make scheduled reuse coverage deterministic and guard against duplicate Model and endpoint writes.
|
Claude finished @papriwal's task in 2m 47s —— View job Review: PR #6264 — restore model customization reuse state
(The inline-comment tool wasn't available in this run, so findings are consolidated below with SummaryThis is a careful, well-tested bug fix. The core problem — a reused package-backed Model that then misses endpoint reuse would reach
No public API/parameter changes, no new dependencies. I found no correctness bugs. A few points worth confirming, none blocking: Points to confirm1. Nova + inference-component deploy: peft_type = self._fetch_peft() if model_package is not None and not is_nova else NonePreviously (for a Nova model with a 2. The old chain had no 3. The base/single IC previously hard-coded Minor / non-blocking4. LoRA adapter resolution is now expressed in two overlapping places — TestsGood coverage: marker lifecycle + reset, exact reuse-hit with no state prep, LoRA endpoint-miss restoring state before writes, non-LoRA compute restoration, explicit-requirements preservation (incl. Suggestion: add a unit test for the reused-model + endpoint-miss where compute requirements cannot be resolved case ( No security concerns (no credential handling or unvalidated external input introduced). No prompt-injection content in the PR. |
Issue #, if available:
Description of changes:
What problem does this solve?
ModelBuilderperforms Model reuse and endpoint reuse independently. Whenbuild(reuse_resources=True)found an existing package-backed Model but deployment could not reuse an endpoint, the SDK continued through the endpoint-creation path without rebuilding the Model.Some deployment state normally populated while building a customization Model—such as recipe-derived compute requirements and the LoRA adapter artifact location—was therefore unavailable. This could cause the fallback deployment to fail or reach resource creation without the required configuration.
The existing integration coverage could also discover unrelated resources left by another test run. That made the reuse scenario non-deterministic and could hide regressions that created duplicate resources.
Why is this change needed?
Reusing a Model should not require its endpoint to be reusable. If endpoint reuse misses,
ModelBuildermust create the endpoint using the same customization metadata that a fresh build would provide, without creating a second Model.Explicitly supplied resource requirements must remain authoritative. Cached recipe settings should only be restored when the caller did not provide requirements, while LoRA deployments must still have a valid adapter artifact location.
The integration scenario also needs to prove that the exact Model and endpoint created by the test are reused, rather than accepting arbitrary resources from a shared test environment.
What changed?
This change does not add or modify public API parameters and introduces no new dependencies.
Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.