New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
datettime.now() is not supported by Dynamo #125171
Comments
What's the real code actually doing? It seems reasonable for us to graph break here. |
My scenario is for full graph :) On my actual model, the user used def forward(self, ...):
start_time = datetime.now()
tt = (
self.get_img_features(img_embeds)
.to(target_device)
.to(target_dtype)
.reshape(-1, self.image_dim_out)
)
logger.info(f'img_embeds size: {img_embeds.size()}, loading time {datetime.now() - start_time}') When I was creating a |
Ah, OK, then this is pursuant to #116106 and we need to rope in @angelayi and @yanboliang The way I always imagined this sort of thing, was that we'd have a notion of "poison" values. When we encounter a datetime.now(), or anything else that doesn't have side effects, we create a PoisonVariableTracker for it. As long as poison doesn't escape or participate in compute (OK for poison to flow into logging statements which are removed), then it is fine and export succeeds. This model makes a lot more sense when the logging calls are being dropped as opposed to reordered to the end. IDK, there's probably other ways to do it. We could also just directly implement datetime.now(), it's not even that hard, should be handled similar to random.randint |
馃悰 Describe the bug
I am actually not sure what is the best behavior here.
On one hand, when
datetime.now()
is assigned to a variable that is only used for printing, it could be ignored, just like theprint
itself.However, what if the user model does something like
return torch.rand() + datetime.now().second()
? It should in theory be captured as a constant? Maybe this case is so weird that should be no-oped?Both
torch._dynamo.export
andtorch.export.export
suffer from this issueRepro
Error:
With
TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1
Versions
main
cc @ezyang @msaroufim @bdhirsh @anijain2305 @chauhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4
The text was updated successfully, but these errors were encountered: