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/src/poplar.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,21 @@ You can slice a tensor with the usual Julia notation `tensor[index1:index2]`, th
49
49
50
50
[`similar`](@ref) can be used to add to `graph` a tensor with the same shape and optionally element type as `tensor`, while [`copyto!`](@ref) can be used to copy elements of a CPU host array into an IPU tensor.
51
51
52
+
## Using `IPUToolkit.jl` without an IPU
53
+
54
+
While this package requires a physical IPU to use all the available features, you can still experiment with the IPU programming model even if you do not have access to a hardware IPU.
55
+
The Poplar SDK provides a feature called IPU Model, which is a software emulation of the behaviour of the IPU hardware.
56
+
While the IPU model comes with [some limitations](https://docs.graphcore.ai/projects/poplar-user-guide/en/latest/poplar_programs.html#programming-with-poplar), it can be useful for testing or debugging.
57
+
58
+
To use the IPU model in `IPUToolkit.jl`, define the device of your IPU program with `Poplar.IPUModelCreateDevice` (which calls [`IPUModel::createDevice`](https://docs.graphcore.ai/projects/poplar-api/en/3.4.0/poplar/profiling/IPUModel.html#_CPPv4NK6poplar8IPUModel12createDeviceE11OptionFlagsbj) under the hood):
Try to attach to `n` IPU devices, returns a vector of the pointers to the devices
213
213
successfully attached to. You can release them with `Poplar.DeviceDetach` (note that this
@@ -222,8 +222,8 @@ attach. It can have different types:
222
222
* if of type `AbstractVector`, try to attach to `n` devices from that list of
223
223
IDs.
224
224
225
-
See [`Poplar.get_ipu_device`](@ref) for requesting exactly one IPU device.
226
-
To release all devices previously attached with `Poplar.get_ipu_devices`or [`Poplar.get_ipu_device`](@ref) use [`Poplar.detach_devices`](@ref).
225
+
See [`Poplar.get_ipu_device`](@ref) for requesting exactly one IPU device, and [`Poplar.get_ipu_model`](@ref) for requesting an IPU Model.
226
+
To release all devices previously attached with `Poplar.get_ipu_devices`, [`Poplar.get_ipu_device`](@ref), or [`Poplar.get_ipu_model`](@ref) use [`Poplar.detach_devices`](@ref).
Similar to [`Poplar.get_ipu_devices`](@ref), but request exactly one IPU device. If it can attach
267
267
to a device, return that pointer only (not in a vector, like `get_ipu_devices`), otherwise
268
-
return `nothing`. You can release the device with `Poplar.DeviceDetach(device)`.
269
-
To release all devices previously attached with `Poplar.get_ipu_device` or [`Poplar.get_ipu_devices`](@ref) use [`Poplar.detach_devices`](@ref).
268
+
return `nothing`.
269
+
270
+
See [`Poplar.get_ipu_model`](@ref) for requesting an IPU Model.
271
+
272
+
You can release the device with `Poplar.DeviceDetach(device)`.
273
+
To release all devices previously attached with `Poplar.get_ipu_device`, [`Poplar.get_ipu_devices`](@ref), or [`Poplar.get_ipu_model`](@ref) use [`Poplar.detach_devices`](@ref).
270
274
271
275
The optional argument `hint` suggests to which device IDs to try and
272
276
attach. It can have different types:
@@ -283,10 +287,33 @@ function get_ipu_device(hint::Union{AbstractVector{<:Integer},Integer}=0)
Attach to an [IPU Model](https://docs.graphcore.ai/projects/poplar-user-guide/en/latest/poplar_programs.html#programming-with-poplar), and return the attached device.
294
+
This uses [`IPUModel::createDevice`](https://docs.graphcore.ai/projects/poplar-api/en/3.4.0/poplar/profiling/IPUModel.html#_CPPv4NK6poplar8IPUModel12createDeviceE11OptionFlagsbj) under the hood.
295
+
296
+
The optional positional argument `ipu_version::String`, `ipu2` by default`, represents the version of the IPU to emulate.
297
+
Valid values for `ipu_version` are `ipu1` and `ipu2` (for Mk1 and Mk2 IPU architectures respectively).
298
+
299
+
See [`Poplar.get_ipu_device`](@ref) and [`Poplar.get_ipu_devices`](@ref) for requesting one or mode hardware IPUs.
300
+
301
+
You can release the device with `Poplar.DeviceDetach(device)`.
302
+
To release all devices previously attached with `Poplar.get_ipu_model`, [`Poplar.get_ipu_device`](@ref) or [`Poplar.get_ipu_devices`](@ref) use [`Poplar.detach_devices`](@ref).
303
+
"""
304
+
functionget_ipu_model(ipu_version::String="ipu2")
305
+
lock(ATTACHED_DEVICES_LOCK) do
306
+
model = Poplar.IPUModel(ipu_version)
307
+
device = Poplar.IPUModelCreateDevice(model)
308
+
push!(ATTACHED_DEVICES, device)
309
+
device
310
+
end
311
+
end
312
+
286
313
"""
287
314
Poplar.detach_devices() -> Nothing
288
315
289
-
Detach all devices previously attached in the current Julia session with [`Poplar.get_ipu_devices`](@ref)or [`Poplar.get_ipu_device`](@ref).
316
+
Detach all devices previously attached in the current Julia session with [`Poplar.get_ipu_devices`](@ref), [`Poplar.get_ipu_device`](@ref), or [`Poplar.get_ipu_model`](@ref).
0 commit comments