[bugfix] enable faster rcnn and sd model with oneflow backend#10439
Open
crazy-JiangDongHua wants to merge 2 commits intomasterfrom
Open
[bugfix] enable faster rcnn and sd model with oneflow backend#10439crazy-JiangDongHua wants to merge 2 commits intomasterfrom
crazy-JiangDongHua wants to merge 2 commits intomasterfrom
Conversation
levi131
reviewed
Mar 6, 2024
|
|
||
| of_g = OfGraph() | ||
| of_g._dynamic_input_graph_cache.set_cache_size(9) | ||
| of_g._dynamic_input_graph_cache.enable_shared(True) |
Contributor
There was a problem hiding this comment.
这两个参数是不是对应了 compile_from_torch 接口 option 中 size 和 dynamic 参数。torch.compile接口参数中有dynamic 参数,我理解应该使用用户传进来的dynamic 参数而不是固定值 True。size 这里设置为默认的9,可以定义一个常量表示,不使用魔鬼数字。
Contributor
Author
There was a problem hiding this comment.
基本上是对应的。size 这个确实可以改一下,我给加一个常量。dynamic 这个参数我觉得不用改,一是用户的参数传给了 torch,oneflow backend 拿不到,二是因为 torch compile 这个前端的存在,这里 dynamic 写死为 True 和 设置成用户传的值,两者是等价的。
levi131
reviewed
Mar 6, 2024
| return self.fx_md(*args, **kwargs) | ||
| if self.fx_md.training: | ||
| return self.fx_md(*args, **kwargs) | ||
| with flow.no_grad(): |
Contributor
There was a problem hiding this comment.
训练或者推理模式的区分,with flow.no_grad,理论上不应该在这里的build函数中体现,而是在用户模型表达中。对于issue中提到的报错,可以确认一下是不是真的缺少对应的反向算子,通过补充反向算子解决问题。
Contributor
Author
There was a problem hiding this comment.
这个我问了开发 fused_multi_head_attention_inference 的俊丞,他说这个算子只实现了前向,没实现反向。如果不在build 里面添加,那要修改 test compile 仓库里面的代码?我测试了只用 model.eval() 无法规避 issue中提到的报错
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.
oneflow backend 对接 torch compile ,在关闭和打开动态形状的时候,跑通了 faster rcnn 和 sd 模型。相关 issue: oneflow backend 对接 torch compile ,运行 faster rcnn
主要改动包括: