Repository navigation
jax backend and repo reorganize - #6
Merged
Merged
Conversation
…, move notebook Symmetric directory structure for multi-backend support (torch/ and jax/). Renames PyTorch modules into nanoasr/torch/ subpackage, prefixes test files with test_torch_*, and moves the training notebook into notebooks/. Made-with: Cursor
- Add nanoasr/jax/ subpackage: Conformer in Flax NNX, optax training loop, librosa mel, soundfile data loading — zero torch dependency - Update all internal imports for torch/ subpackage move - Add shared clean_text to vocab.py, remove duplication - Add pyproject.toml [jax] optional deps and fix entry points - Add train_jax.ipynb Colab TPU notebook - Add test_jax_model.py (13 tests) Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Colab pre-installs Flax 0.11.x which lacks nnx.List. Upgrade the floor to 0.12 in pyproject.toml and force-upgrade in the notebook install cell so the Conformer model builds correctly. Made-with: Cursor
Made-with: Cursor
The prior fix only added wrt to optimizer.update(); the constructor requires it too in Flax 0.11+. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nnx.split(model) returns state that includes Rngs. In JAX's typed-PRNG regime, those leaves cannot be converted to numpy via np.array() and raise TypeError. Extract key_data on save and wrap_key_data on load so the full state round-trips. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- train() gains a max_steps arg that breaks the loop early; lets a CPU
smoke run exercise the real entry point in seconds instead of minutes.
- tests/test_jax_smoke.py calls train() on dev-clean with depth=2,
batch_size=2, max_steps=3 and asserts a checkpoint is written.
Run locally with:
JAX_PLATFORMS=cpu pytest tests/test_jax_smoke.py -s
This run caught the PRNG-key checkpoint bug fixed in the previous commit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Each unique (mel_T, target_S) pair triggered a fresh XLA compile of the Conformer train_step, and each compile peaks 15-20 GB of host RAM during lowering. Two back-to-back batches with different shapes reliably pushed Colab TPU hosts past 48 GB and OOM-killed the kernel. compute_dataset_maxes() derives a single (max_mel_T, max_target_S) per dataset (99th percentile of audio length, exact max of encoded target length). make_loader now accepts pad_to= and max_audio_samples= so every batch has identical shape; train_step compiles once for the whole run. Outlier clips longer than the 99th percentile are dropped to keep the pad ceiling reasonable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Without drop_last, the last batch of each epoch has fewer items than batch_size, which is a second shape distinct from every full batch. That's enough to trigger a second JIT compile of train_step, blowing past host RAM on Colab even after the mel_T / target_S padding fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.