File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -212,8 +212,9 @@ def __init__(
212
212
def _deferred_initialize (self ):
213
213
if self ._value is not None :
214
214
# If NNX is enabled, it's possible the variable was already
215
- # initialized by a concrete call. In this case,
216
- # _deferred_initialize becomes a no-op for this variable.
215
+ # initialized by a concrete call.
216
+ if config .is_nnx_enabled ():
217
+ return
217
218
raise ValueError (f"Variable { self .path } is already initialized." )
218
219
219
220
if in_stateless_scope ():
Original file line number Diff line number Diff line change @@ -112,11 +112,9 @@ def _setup_nnx_op_mapping(self):
112
112
# Create a mapping from operation id to operation instance
113
113
self ._nnx_op_mapping = {}
114
114
115
- # Store operations as direct attributes for NNX traversal
116
- for i , operation in enumerate (self ._operations ):
117
- # Store operation as direct attribute with unique name
118
- attr_name = f"_op_{ i } _{ operation .name } "
119
- setattr (self , attr_name , operation )
115
+ # Assign the list of operations to a single attribute for NNX traversal
116
+ self .nnx_operations = self ._operations [:]
117
+ for operation in self ._operations :
120
118
# Map the operation id to this operation instance
121
119
self ._nnx_op_mapping [id (operation )] = operation
122
120
You can’t perform that action at this time.
0 commit comments