@@ -12,6 +12,8 @@ import MLX
1212/// mutation surface so the wrapped module cannot be modified through this
1313/// reference.
1414///
15+ /// This also sets ``Module/training`` to `false`.
16+ ///
1517/// Note: only parameters that can be be mutated, e.g. are wrapped with `@ParameterInfo`,
1618/// will actually be updated to the `MaterializedArray` type. All others will
1719/// be evaluated and are materialized, even if they do not have the type
@@ -42,17 +44,20 @@ import MLX
4244///
4345/// ## What is sealed
4446///
45- /// The following `Module` operations are marked `@available(*, unavailable)`
46- /// on `MaterializedModule` and will trap if called:
47- ///
48- /// - `update(parameters:...)` and `update(modules:...)`
49- /// - `updateModule(key:_:)`
50- /// - `apply(filter:map:)`
51- /// - `freeze(...)` / `unfreeze(...)`
52- /// - `train(_:)`
47+ /// `MaterializedModule` is not a `Module` and does not provide access to the
48+ /// wrapped `Module`. No access to bare `MLXArray` is provided, though
49+ /// for purposes of introspection the ``parameters()`` can give
50+ /// `MaterializedArray`. There are also properties like ``parameterNBytes``
51+ /// and ``parameterCount`` for callers that just need size information.
5352///
5453/// ## Calling the wrapped module
5554///
55+ /// `MaterializedModule`is not a `Module` subclass and cannot conform
56+ /// to protocols that have `Module` requirements. Users may want to split their
57+ /// protocols into requirements for performing inference (which
58+ /// `MaterializedModule` is meant for) and for doing training where `Module`
59+ /// is required and this type is not appropriate (immutable).
60+ ///
5661/// `MaterializedModule` does not itself know how to invoke `base`; that is
5762/// added per-layer-shape via an extension that constrains `LayerType`.
5863/// For example, every ``UnaryLayer`` already supports being called with a
@@ -137,6 +142,8 @@ open class MaterializedModule<LayerType: Module>: IndentedDescription, @unchecke
137142
138143 public init ( _ base: consuming LayerType ) {
139144 self . _base = base
145+
146+ self . _base. train ( false )
140147 self . _base. materialize ( )
141148
142149 // seal the consumed base so that any retained reference held by a
0 commit comments