Skip to content

Fix requires grad #56

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion torch_dag/core/unstructured_to_structured.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def build_dag_by_tracing(self) -> dag_module.DagModule:
for node in graph.nodes:
num_predecessors = len(node._input_nodes)
if num_predecessors == 0 and node.target in model.state_dict(): # free parameter node
module = structured_modules.ParameterModule(param=torch.nn.Parameter(model.state_dict()[node.target]))
module = structured_modules.ParameterModule(param=torch.nn.Parameter(model.get_parameter(node.target), requires_grad = model.get_parameter(node.target).requires_grad))
vertex = dag.add_vertex(
name=node.name,
module=module,
Expand Down Expand Up @@ -395,6 +395,9 @@ def convert_node(self, node: torch.fx.node.Node, modules_dict, state_dict):
elif node.target == torch.square:
return structured_modules.PowerModule(pow=2)

elif node.target == torch.add:
return structured_modules.AddModule()

elif node.target == torch.addcmul:
return structured_modules.AddcmulModule()

Expand Down