Numba¶
numba
¶
Optional bounded NumPy CPU lowering with explicit, reusable packed inputs.
Importing this module does not import Numba. Compilation is eager and never falls back to Python. Generated functions have one homogeneous float signature; normal compiler evaluators and other array namespaces remain independent.
BufferLayout(name, shape, offset)
dataclass
¶
A named C-order slice in a homogeneous flat input array.
size
property
¶
Number of scalar entries, including one for scalar buffers.
CompilationSeconds(generation, optional_import, native_compilation)
dataclass
¶
Wall times for source generation, optional import and eager compilation.
NumbaRhs(model, dtype, state_names, state_layout, parameter_layout, source, compilation_seconds, kernel)
dataclass
¶
One eagerly compiled, homogeneous, NumPy CPU RHS signature.
kernel(t, y, p) accepts C-contiguous one-dimensional NumPy arrays in the
layouts below. The signature also accepts read-only arrays. It checks lengths,
does not mutate inputs and returns a fresh flat array. Call evaluate for
strict Python-side time/dtype/layout validation, or use kernel from a
Numba consumer after validating the same contract. Each call allocates its
result and expression temporaries. No process-global or on-disk cache is used.
pack_state and pack_parameters explicitly copy once into owned,
read-only arrays. Reuse packed parameters while values stay fixed. No input
arrays or training data are retained by this artifact.
evaluate(t, y, parameters)
¶
Validate packed inputs and execute the single compiled signature.
Returns:
| Type | Description |
|---|---|
_Array
|
Fresh flat NumPy derivative array in |
Raises:
| Type | Description |
|---|---|
TypeError
|
Inputs are foreign, differently typed or noncontiguous. |
Source code in src/op_system/numba.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
pack_parameters(values)
¶
Copy scalar and shaped parameters into one reusable read-only array.
Returns:
| Type | Description |
|---|---|
_Array
|
Owned read-only NumPy parameter array; empty for parameter-free models. |
Source code in src/op_system/numba.py
191 192 193 194 195 196 197 | |
pack_state(values)
¶
Copy structured state buffers into the declared C-order flat layout.
Returns:
| Type | Description |
|---|---|
_Array
|
Owned read-only NumPy state array. |
Source code in src/op_system/numba.py
183 184 185 186 187 188 189 | |
compile_numba(compiled, *, dtype='float64')
¶
Eagerly lower a bounded scalar/fully vectorized model to NumPy CPU code.
Arithmetic, static indexing, elementwise abs/exp/log/sqrt/sin/cos/tanh, maximum/minimum/where, transposes and single-axis sums are supported. No fastmath, dynamic evaluator closure, automatic accelerator selection or fallback is used. State/parameter scalar counts are capped at one million each and generated source at 100000 characters. Runtime input values are not captured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compiled
|
CompiledRhs
|
Natural-coordinate compiler artifact with retained source IR. |
required |
dtype
|
Literal['float32', 'float64']
|
One homogeneous native floating precision. |
'float64'
|
Returns:
| Type | Description |
|---|---|
NumbaRhs
|
Artifact with one eagerly compiled signature, source and explicit layouts. |
Raises:
| Type | Description |
|---|---|
ImportError
|
Install |
ValueError
|
Precision/size bounds differ or Numba JIT is disabled. |
NotImplementedError
|
The model needs an unsupported operation or layout. |
Source code in src/op_system/numba.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | |