Torch Loop¶
torch_loop
¶
Explicit, bounded CPU Torch compilation for sequential solver loops.
Importing this module does not import Torch. Constructing an adapter opts into native Inductor compilation; ordinary solver calls retain their eager defaults.
torch_compile_loop_adapter(*, max_steps=128, max_elements=65536)
¶
Construct an explicitly registered, bounded sequential CPU adapter.
Supports Tensor/None trees in tuples, lists and dictionaries, homogeneous CPU float32/64, positive static input lengths and first-order autograd. The sequential loop is statically captured with fullgraph Inductor; graph breaks, disabled compilation and unsupported inputs raise. Checkpointing and GPU execution are not part of this adapter's qualified contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_steps
|
int
|
Largest positive scan length accepted by this adapter. |
128
|
max_elements
|
int
|
Bound on input, carry and stacked output tensor elements. |
65536
|
Returns:
| Type | Description |
|---|---|
LoopAdapter
|
An unregistered adapter; register it for |
Raises:
| Type | Description |
|---|---|
ValueError
|
If bounds or Torch version are unsupported. |
ImportError
|
If the optional Torch dependency is absent. |
Source code in src/op_engine/torch_loop.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |