You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source-fabric/api/wrappers.rst
+5-3
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ Using methods other than forward for computation
91
91
************************************************
92
92
93
93
PyTorch's ``nn.Modules`` have a special contract you need to follow when using them for training: Your forward computation has to be defined in the **forward** method and you should call this forward method directly.
94
-
But sometimes your model may need to define different flavors of `forward`, like in this example below where the regular forward is used for training, but the `generate` method does something slightly different for inference:
94
+
But sometimes your model may need to define different flavors of forward, like in this example below where the regular forward is used for training, but the `generate` method does something slightly different for inference:
95
95
96
96
.. code-block:: python
97
97
@@ -130,8 +130,8 @@ If you were to run this model in Fabric with multiple devices (DDP or FSDP), you
130
130
# ERROR: Calling another method that calls forward indirectly
131
131
output = model.generate()
132
132
133
-
Fabric produces an error here informing the user about incorrect usage because this is normally not allowed in PyTorch and could potentially lead to silent correctness bugs.
134
-
If you want to use such methods, you need to mark them explicitly with `.mark_forward_method()` so that Fabric can do some rerouting behind the scenes for you to do the right thing:
133
+
Fabric produces an error there informing the user about incorrect usage because this is normally not allowed in PyTorch and could potentially lead to silent correctness bugs.
134
+
If you want to use such methods, you need to mark them explicitly with ``.mark_forward_method()`` so that Fabric can do some rerouting behind the scenes for you to do the right thing:
135
135
136
136
.. code-block:: python
137
137
@@ -140,3 +140,5 @@ If you want to use such methods, you need to mark them explicitly with `.mark_fo
140
140
141
141
# OK: Fabric will do some rerouting behind the scenes now
0 commit comments