Diagnostics¶
tinax.diagnostics sends bounded summaries through injected JAX callbacks and keeps profiler scopes open until result arrays and staged effects complete. Callback execution remains an observational, asynchronous effect.
from tinax.diagnostics import profile_call
result = profile_call("profiles/step-10", train_step, state, batch)
observe_nonfinite
¶
observe_nonfinite(
values: Array,
*,
callback: Callable[[Any, Any], None],
max_indices: int,
) -> Array
Report a count and bounded row-major flat indices while returning values unchanged.
When non-finite values are present, schedules callback with the total count
and up to max_indices row-major flat indices. The callback is an
observational, asynchronous effect; values is always returned unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Array
|
JAX array to scan for non-finite elements. |
required |
callback
|
Callable[[Any, Any], None]
|
Host callable invoked as |
required |
max_indices
|
int
|
Maximum number of flat indices to report. Must be non-negative;
unused slots are filled with |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The input |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
profile_call
¶
profile_call(
log_dir: str | PathLike[str],
function: Callable[P, R],
/,
*args: P.args,
**kwargs: P.kwargs,
) -> R
Profile one call and keep the trace open until result arrays and staged effects complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_dir
|
str | PathLike[str]
|
Directory the profiler trace is written to. |
required |
function
|
Callable[P, R]
|
Callable to profile. Invoked once as |
required |
*args
|
P.args
|
Positional arguments forwarded to |
()
|
**kwargs
|
P.kwargs
|
Keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
R
|
The value returned by |
R
|
staged effects have completed inside the trace. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |