Skip to content

Commit 92cdef5

Browse files
committed
update
1 parent 6a0823b commit 92cdef5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/source-fabric/api/wrappers.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Using methods other than forward for computation
9191
************************************************
9292

9393
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:
9595

9696
.. code-block:: python
9797
@@ -130,8 +130,8 @@ If you were to run this model in Fabric with multiple devices (DDP or FSDP), you
130130
# ERROR: Calling another method that calls forward indirectly
131131
output = model.generate()
132132
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:
135135

136136
.. code-block:: python
137137
@@ -140,3 +140,5 @@ If you want to use such methods, you need to mark them explicitly with `.mark_fo
140140
141141
# OK: Fabric will do some rerouting behind the scenes now
142142
output = model.generate()
143+
144+
|

0 commit comments

Comments
 (0)