fix(optim): support like factories for placeholder contexts - #785
Open
Zhaoxian-Wu wants to merge 1 commit into
Open
Zhaoxian-Wu wants to merge 1 commit into
Zhaoxian-Wu wants to merge 1 commit into
Conversation
Allow torch like-factory operations to use placeholder metadata without reading backing values, with CPU and CUDA regression tests. Signed-off-by: Zhaoxian Wu <wuzhaoxian97@gmail.com>
Zhaoxian-Wu
force-pushed
the
fix/placeholder-like-factories
branch
from
August 6, 2026 17:52
c729df2 to
836cdd8
Compare
Contributor
Author
|
Hi @PabloCarmona, Possible solution: tests/test_simulator_tiles.py:686 compares only one randomly selected noisy-output pair, so it can falsely fail when both samples quantize to the same value. |
Zhaoxian-Wu
marked this pull request as ready for review
August 7, 2026 00:34
Collaborator
|
Thanks @Zhaoxian-Wu ! I will take a look at the PR and what are you talking about the tests for the random noisy value, we are aware of it, we will take a look again. Thanks again! |
PabloCarmona
requested review from
PabloCarmona and
maljoras
and
a lite review from Copilot
and removed request for
Copilot
August 25, 2026 10:59
Collaborator
|
@Zhaoxian-Wu could you sync up this branch with the master branch? We are planning to launch a new release very soon. Thanks again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
AnalogContextexposes placeholder data by default so public tensor operations cannot accidentally read meaningless backing weights. Tensor*_likefactories only need metadata such as shape, dtype, and device, and should be valid in this mode. Before this change, they were rejected as value-reading operations.This is related to the placeholder-data feature introduced by IBM/aihwkit#765, and completes its compatibility with standard PyTorch
*_likefactories.Failure case
Before this fix, the final line raised:
This prevented metadata-only tensor construction during CUDA model setup and other generic PyTorch code paths.
What changed
empty_like,full_like,ones_like,rand_like,randint_like,randn_like, andzeros_likein placeholder mode.*_likefactories and a CUDA regression test forzeros_like.