Skip to content

Commit 995288c

Browse files
committed
feat(utils): add dataset combinators, audio/tabular loaders, memory estimator, graph viz, sharded saves, and docs
1 parent 3961096 commit 995288c

27 files changed

Lines changed: 2969 additions & 76 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 0.1.0 - 2026-11-23
44

55
### Added
6+
- **Workflow, tree-mapping, parameterization, data, profiling and vision utilities:** nested container transformations (`ox.treemap`: `tree_flatten`, `tree_unflatten`, `tree_map`, `tree_map_only`, `tree_all`, `tree_any`, `broadcast_tree_prefix`, `flatten_nested`, `assert_same_structure`, `pack_sequence_as`, `map_structure`, custom node registration); neural parameterizations, fusion and pruning (`ox.nn.utils`: `weight_norm`, `spectral_norm`, `bind_reparam` / `unbind_reparam` / `cache_reparam`, `fuse_conv_batchnorm`, `fuse_linear_batchnorm`, `ln_structured_prune`, `mask_prune`, `identity_prune`, `fast_init`, `apply_with_weights`, `total_norm`, `freeze_module_types`, `freeze_by_prefix`); functional `Dataset` combinators (`.map()`, `.filter()`, `.cache()`, `.repeat()`, `.take()`, `.skip()`, `.window()`), `IterableDataset` streaming in `DataLoader`, `padded_collate`, `to_tensors`, `stratified_split`, `BalancedClassSampler`, `LengthBucketSampler`, `InfiniteDataLoader` / `cycle_batches`, and `padding_side` on `pad_sequence` / `unpad_sequence`; multimodal & structured loaders (`image_folder_dataset`, `text_folder_dataset`, `audio_folder_dataset`, `csv_dataset`, `jsonl_dataset`, `sliding_window_dataset`, `split_dataset`, pure-Python `read_wav_tensor` / `save_wav_tensor`, `VocabularyIndex` / `build_vocabulary`, `one_hot_encode`, `axis_normalize`, `pad_sequences`, `compute_class_weight`, `compute_sample_weight`, `pack_batch` / `unpack_batch`); checkpointing & config registry (`save_sharded` / `load_sharded`, `CheckpointVault`, `ShadowWeightEMA`, `fetch_artifact` / `verify_checksum`, `SerializationScope`, `register_serializable`, `serialize_config` / `deserialize_config`); profiling, graph rendering & numerical assertions (`FlopProfiler` / `count_flops`, `MemoryFootprint` / `estimate_memory_footprint`, `MicroTimer` / `TimingReport` / `TimingComparison`, `collect_runtime_info`, `HookHandle` / `ephemeral_hook`, `model_to_dot`, `model_to_mermaid`, `chrome_trace_handler`, `ProgressBar`, `SummaryWriter` histograms/images/hparams/graphs, `gradgradcheck`, `assert_finite`, `assert_shapes`); and `ox.vision.utils` (`image_grid`, `save_image`, `draw_bounding_boxes`, `draw_segmentation_masks`, `draw_keypoints`).
67
- `oxideon.tensor_utils`: 71 PyTorch-named tensor utilities, all exported at the top level and covered by `tests/test_tensor_utils.py`
78
(compared against NumPy and PyTorch): `ravel`, `movedim` / `moveaxis`, `swapaxes` / `swapdims`, `tensor_split`, `hsplit` / `vsplit` /
89
`dsplit`, `broadcast_shapes` / `broadcast_to` / `broadcast_tensors`, `combinations`, `msort`, `lerp`, `float_power`, `addcmul`, `addcdiv`,

‎docs/INFERENCE_AND_LLM.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ attn_out = ox.flash_attention_forward(
146146
causal=True, # Autoregressive lower-triangular causal mask
147147
)
148148

149-
# 2. PyTorch-style Module interface
149+
# 2. Module interface
150150
tiled_attn = ox.TiledAttention(
151151
embed_dim=512,
152152
num_heads=8,

‎docs/PYTHON_API.md‎

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**Package:** `oxideon`
44
**Version:** `0.1.0`
55
**Python Compatibility:** Python $\ge 3.9$ (`abi3`)
6-
**Public Symbols:** 2,339 public symbols (4,835 typed signatures)
6+
**Public Symbols:** 2,996 public symbols (5,946 typed signatures)
77

88
---
99

@@ -30,7 +30,8 @@
3030
20. [Frontier Optimizers, Loss Functions & Synthetic Data (`ox.optim_ext`, `ox.losses_ext`, `ox.synthetic_data`, `ox.uncertainty_quant`, `ox.interpret`, `ox.func`)](#20-frontier-optimizers-loss-functions--synthetic-data)
3131
21. [Tensor Utilities (`ox.tensor_utils`)](#21-tensor-utilities-oxtensor_utils)
3232
22. [Model & Training Diagnostics (`ox.diagnostics`)](#22-model--training-diagnostics-oxdiagnostics)
33-
23. [More PyTorch Parity (functional, linalg, special, fft, nn, optim, data)](#23-more-pytorch-parity)
33+
23. [Extended Operators & Modules (functional, linalg, special, fft, nn, optim, data)](#23-extended-operators--modules)
34+
24. [Workflow, Tree-Mapping, Parameterization & Vision Utilities (`ox.utils`, `ox.treemap`, `ox.vision.utils`)](#24-workflow-tree-mapping-parameterization--vision-utilities)
3435

3536
---
3637

@@ -679,7 +680,7 @@ Oxideon natively integrates 52 high-level features across 10 flagship systems an
679680

680681
## 21. Tensor Utilities (`ox.tensor_utils`)
681682

682-
PyTorch-named helpers, all also available at the top level (`ox.lerp`, `ox.logsumexp`, ...). Those built from tensor
683+
Core tensor helpers, all also available at the top level (`ox.lerp`, `ox.logsumexp`, ...). Those built from tensor
683684
operations stay differentiable; the ones that go through NumPy (marked *no graph*) return fresh tensors.
684685

685686
- **Shape and layout:** `ravel`, `movedim` / `moveaxis`, `swapaxes` / `swapdims`, `tensor_split`, `hsplit`, `vsplit`, `dsplit`,
@@ -698,18 +699,18 @@ operations stay differentiable; the ones that go through NumPy (marked *no graph
698699

699700
### Tensor methods (`ox.tensor_methods`)
700701

701-
Importing oxideon also attaches 149 PyTorch-style methods to `Tensor` (`ox.tensor_methods.ADDED` lists them):
702+
Importing oxideon also attaches 149 convenience methods to `Tensor` (`ox.tensor_methods.ADDED` lists them):
702703

703704
- **Method forms** of the functions above and of `amax`, `amin`, `outer`, `inner`, `dot`, `vdot`, `mv`, `allclose`, `isclose`, `unique`,
704705
`unique_consecutive`, `diagflat`, `deg2rad`, `rad2deg`, `histogram`, plus `x.where(cond, y)` and `x.trace()`.
705706
- **Comparisons and arithmetic:** `eq`, `ne`, `lt`, `le`, `gt`, `ge` and their long names (`greater_equal`, ...), `equal`, `true_divide`,
706707
`divide(rounding_mode=None | "trunc" | "floor")`, `floor_divide`, `reciprocal`, `multiply`, `subtract(alpha=)`, `absolute`, `dist(p)`,
707708
`new_full`, `reshape_as`, `sum_to_size`, `split_with_sizes`, `is_same_size`, `is_nonzero`, `element_size`.
708709
- **In-place forms** (`x.exp_()`, `x.clamp_min_(0)`, `x.lerp_(y, 0.1)`, `x.addcmul_(a, b, value=)`, the comparison, logical and bitwise
709-
ones, ...). Like PyTorch they keep the shape, refuse a float result in an integer tensor, refuse a tensor that requires grad
710+
ones, ...). They keep the shape, refuse a float result in an integer tensor, refuse a tensor that requires grad
710711
outside `ox.no_grad()`, and refuse non-contiguous views.
711712

712-
`true_divide` / `divide` follow PyTorch and return a float tensor for integer inputs; note that the `/` operator on two integer
713+
`true_divide` / `divide` return a float tensor for integer inputs; note that the `/` operator on two integer
713714
tensors still truncates (`7 / 2 == 3`).
714715

715716
```python
@@ -753,9 +754,9 @@ print(dg.lr_find(model, loss_fn, loader).suggestion)
753754

754755
---
755756

756-
## 23. More PyTorch Parity
757+
## 23. Extended Operators & Modules
757758

758-
Each item behaves like its PyTorch namesake and is checked against it in `tests/test_torch_parity_extra.py`.
759+
Extended operators, factorizations, special functions, layers, optimizers, and samplers across core submodules:
759760

760761
- **`ox.functional`:** `max_pool1d/2d/3d` and `adaptive_max_pool1d/2d/3d` now take `dilation`, `ceil_mode` and `return_indices`
761762
(indices into the flattened spatial input, as `MaxUnpool` expects), plus the `*_with_indices` forms; `lp_pool3d`;
@@ -765,7 +766,7 @@ Each item behaves like its PyTorch namesake and is checked against it in `tests/
765766
- **`ox.linalg`:** `cholesky_ex`, `inv_ex`, `solve_ex`, `lu_factor_ex` (error codes instead of exceptions); `ldl_factor`,
766767
`ldl_factor_ex`, `ldl_solve` (Bunch-Kaufman, LAPACK's compact format); `matrix_sqrth`, `polar`, `matmul`. The
767768
factorizations and solves run in Rust (`oxideon-core/src/lapack.rs`). `lu_factor` returns
768-
PyTorch's 1-based pivots and `lu_solve` expects them, so factors move freely between the two libraries.
769+
1-based pivots and `lu_solve` expects them.
769770
- **`ox.special`:** `hermite_polynomial_he`, `shifted_chebyshev_polynomial_t/u/v/w`, `modified_bessel_i0`, `modified_bessel_i1`.
770771
- **`ox.fft`:** `hfft2`, `hfftn`, `ihfft2`, `ihfftn` (complex values as a trailing (real, imag) dimension, like the rest of `ox.fft`).
771772
- **`ox.nn`:** `MaxPool1d/2d/3d` and `AdaptiveMaxPool1d/2d/3d` with the new options, `LPPool3d`, `LazyConv1d`, `LazyConv3d`,
@@ -774,3 +775,32 @@ Each item behaves like its PyTorch namesake and is checked against it in `tests/
774775
`NLLLoss2d` and `Container`.
775776
- **`ox.optim.SparseAdam`:** lazy Adam for embedding tables (only rows with a non-zero gradient are updated).
776777
- **`ox.data`:** `DistributedSampler` (with `set_epoch`) and `StackDataset`.
778+
779+
---
780+
781+
## 24. Workflow, Tree-Mapping, Parameterization & Vision Utilities
782+
783+
Oxideon provides a comprehensive, zero-external-dependency suite of training, nested-tree, parameterization, data-pipeline, checkpointing, profiling, testing, and computer-vision utilities across `ox.utils`, `ox.nn.utils`, `ox.treemap`, `ox.data`, `ox.serialization`, `ox.testing`, and `ox.vision.utils`.
784+
785+
```python
786+
import oxideon as ox
787+
788+
# Nested container tree transformations
789+
batch = {"inputs": ox.ones([4, 8]), "targets": [ox.zeros([4]), ox.ones([4])]}
790+
scaled = ox.tree_map(lambda t: t * 2.0, batch)
791+
ox.assert_same_structure(batch, scaled)
792+
ox.assert_finite(scaled)
793+
dims = ox.assert_shapes([(scaled["inputs"], ("B", "D")), (scaled["targets"][0], ("B",))])
794+
795+
# Parameterizations and selective layer freezing
796+
layer = ox.weight_norm(ox.nn.Linear(8, 4))
797+
y = layer(scaled["inputs"])
798+
flops = ox.count_flops(layer, scaled["inputs"])
799+
```
800+
801+
- **Nested Container & Tree Mapping (`ox.treemap`, `ox.utils.treemap`)** - `tree_flatten`, `tree_unflatten`, `tree_leaves`, `tree_schema`, `tree_map`, `tree_map_`, `tree_map_only`, `tree_all`, `tree_any`, `tree_all_only`, `tree_any_only`, `broadcast_tree_prefix`, `flatten_nested`, `assert_same_structure`, `pack_sequence_as`, `map_structure`, `is_nested`, `tree_is_leaf`, `register_tree_node`, `unregister_tree_node`, `TreeSchema`, and `LeafSchema`.
802+
- **Parameterizations, Fusion & Pruning (`ox.nn.utils`)** - `weight_norm` / `remove_weight_norm`, `spectral_norm` / `remove_spectral_norm`, `bind_reparam` / `unbind_reparam` / `has_reparam` / `cache_reparam` (`ox.nn.utils.reparam`), `fuse_conv_batchnorm` / `fuse_conv_batchnorm_weights` / `fuse_linear_batchnorm` / `fuse_linear_batchnorm_weights` (`ox.nn.utils.fusion`), `ln_structured_prune` / `mask_prune` / `identity_prune` / `is_pruned` (`ox.nn.utils.prune`), `fast_init`, `apply_with_weights`, `total_norm`, `clip_grad_norm_` (`error_if_nonfinite`), `freeze_module_types`, and `freeze_by_prefix`.
803+
- **Dataset Combinators, Samplers & Folder/Tabular Loaders (`ox.data`, `ox.utils`)** - Functional `Dataset` pipeline methods `.map()`, `.filter()`, `.cache()`, `.repeat()`, `.take()`, `.skip()`, and `.window()` (`MappedDataset`, `FilteredDataset`, `CachedDataset`, `RepeatedDataset`, `TakenDataset`, `SkippedDataset`, `WindowedDataset`); `padded_collate`, `to_tensors`, `stratified_split`, `BalancedClassSampler`, `LengthBucketSampler`, `InfiniteDataLoader`, and `cycle_batches`; directory, sequence, and structured-file builders `image_folder_dataset`, `text_folder_dataset`, `audio_folder_dataset`, `csv_dataset`, `jsonl_dataset`, `sliding_window_dataset`, `split_dataset`, `read_wav_tensor`, `save_wav_tensor`, `VocabularyIndex`, and `build_vocabulary`; `pad_sequences`, `one_hot_encode`, `axis_normalize`, `compute_class_weight`, `compute_sample_weight`, `pack_batch`, and `unpack_batch`; plus `padding_side` support on `pad_sequence`, `unpad_sequence`, and `unpack_sequence` (`ox.nn.utils.rnn`).
804+
- **Checkpointing, Config Registry & EMA (`ox.utils`, `ox.serialization`)** - `save_sharded` and `load_sharded` (multi-file `.safetensors` sharding with `.safetensors.index.json` manifests), `CheckpointVault` (rotating directory checkpoints with `max_to_keep`), `ShadowWeightEMA` (`average_parameters()` evaluation swap), `fetch_artifact` and `verify_checksum` (SHA-256/MD5 verification and path-safe archive extraction), `SerializationScope` / `serialization_scope`, `register_serializable`, `serialize_config`, and `deserialize_config`.
805+
- **Profiling, Memory Footprint, Architecture Graphs, Hooks & Numerical Checks (`ox.utils`, `ox.testing`, `ox.profiler`)** - `FlopProfiler` and `count_flops` (`ox.utils.flops`), `MemoryFootprint` and `estimate_memory_footprint`, `MicroTimer` / `TimingReport` / `TimingComparison` (`ox.utils.timing`), `collect_runtime_info` / `format_runtime_info` (`ox.utils.sysinfo`), `HookHandle` and `ephemeral_hook` (`ox.utils.hooks`), `model_to_dot` and `model_to_mermaid` (`ox.utils.graph_viz`), `chrome_trace_handler`, `ProgressBar`, `SummaryWriter` (`add_scalar`, `add_scalars`, `add_histogram`, `add_image`, `add_images`, `add_hparams`, `add_graph`), `gradcheck`, `gradgradcheck`, `assert_finite`, and `assert_shapes`.
806+
- **Vision Annotation & Image Grids (`ox.vision.utils`)** - `image_grid`, `save_image` (pure-Python PNG encoder writing to paths or binary streams), `draw_bounding_boxes` (with built-in bitmap font labels), `draw_segmentation_masks`, and `draw_keypoints` (with visibility flags and skeleton `connectivity`).

0 commit comments

Comments
 (0)