amv-train 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- amv_train-2.1.0/LICENSE +57 -0
- amv_train-2.1.0/NOTICE +17 -0
- amv_train-2.1.0/PKG-INFO +439 -0
- amv_train-2.1.0/README.md +389 -0
- amv_train-2.1.0/amv_train.egg-info/PKG-INFO +439 -0
- amv_train-2.1.0/amv_train.egg-info/SOURCES.txt +125 -0
- amv_train-2.1.0/amv_train.egg-info/dependency_links.txt +1 -0
- amv_train-2.1.0/amv_train.egg-info/entry_points.txt +5 -0
- amv_train-2.1.0/amv_train.egg-info/requires.txt +23 -0
- amv_train-2.1.0/amv_train.egg-info/top_level.txt +1 -0
- amv_train-2.1.0/pyproject.toml +96 -0
- amv_train-2.1.0/setup.cfg +4 -0
- amv_train-2.1.0/termux_train/__init__.py +79 -0
- amv_train-2.1.0/termux_train/__main__.py +7 -0
- amv_train-2.1.0/termux_train/adapter.py +67 -0
- amv_train-2.1.0/termux_train/adapters/__init__.py +15 -0
- amv_train-2.1.0/termux_train/adapters/hub.py +186 -0
- amv_train-2.1.0/termux_train/audio/__init__.py +23 -0
- amv_train-2.1.0/termux_train/audio/audio_lora.py +221 -0
- amv_train-2.1.0/termux_train/audio/trainer.py +311 -0
- amv_train-2.1.0/termux_train/backend/__init__.py +120 -0
- amv_train-2.1.0/termux_train/backend/amuda_backend.py +324 -0
- amv_train-2.1.0/termux_train/backend/base.py +171 -0
- amv_train-2.1.0/termux_train/backend/numpy_backend.py +190 -0
- amv_train-2.1.0/termux_train/backend/python_backend.py +568 -0
- amv_train-2.1.0/termux_train/backend/vulkan_backend.py +309 -0
- amv_train-2.1.0/termux_train/checkpoint/__init__.py +17 -0
- amv_train-2.1.0/termux_train/checkpoint/lora_io.py +168 -0
- amv_train-2.1.0/termux_train/checkpoint/safetensors.py +230 -0
- amv_train-2.1.0/termux_train/cli.py +879 -0
- amv_train-2.1.0/termux_train/cluster.py +332 -0
- amv_train-2.1.0/termux_train/cluster_trainer.py +396 -0
- amv_train-2.1.0/termux_train/control/__init__.py +5 -0
- amv_train-2.1.0/termux_train/control/component.py +280 -0
- amv_train-2.1.0/termux_train/control/status.py +20 -0
- amv_train-2.1.0/termux_train/data/__init__.py +36 -0
- amv_train-2.1.0/termux_train/data/audio_dataset.py +197 -0
- amv_train-2.1.0/termux_train/data/docfold.py +186 -0
- amv_train-2.1.0/termux_train/data/image_dataset.py +153 -0
- amv_train-2.1.0/termux_train/data/mmap_dataset.py +156 -0
- amv_train-2.1.0/termux_train/data/vision_dataset.py +200 -0
- amv_train-2.1.0/termux_train/diffusion/__init__.py +19 -0
- amv_train-2.1.0/termux_train/diffusion/scheduler.py +133 -0
- amv_train-2.1.0/termux_train/diffusion/trainer.py +180 -0
- amv_train-2.1.0/termux_train/diffusion/unet_lora.py +241 -0
- amv_train-2.1.0/termux_train/exceptions.py +39 -0
- amv_train-2.1.0/termux_train/nn/__init__.py +82 -0
- amv_train-2.1.0/termux_train/nn/activations.py +58 -0
- amv_train-2.1.0/termux_train/nn/attention.py +218 -0
- amv_train-2.1.0/termux_train/nn/dora.py +286 -0
- amv_train-2.1.0/termux_train/nn/embedding.py +142 -0
- amv_train-2.1.0/termux_train/nn/layernorm.py +63 -0
- amv_train-2.1.0/termux_train/nn/linear.py +85 -0
- amv_train-2.1.0/termux_train/nn/lora.py +1057 -0
- amv_train-2.1.0/termux_train/nn/loss.py +372 -0
- amv_train-2.1.0/termux_train/nn/module.py +191 -0
- amv_train-2.1.0/termux_train/nn/parameter.py +29 -0
- amv_train-2.1.0/termux_train/nn/quantization.py +96 -0
- amv_train-2.1.0/termux_train/nn/rope.py +210 -0
- amv_train-2.1.0/termux_train/nn/sequential.py +58 -0
- amv_train-2.1.0/termux_train/nn/transformer.py +422 -0
- amv_train-2.1.0/termux_train/nn/utils.py +74 -0
- amv_train-2.1.0/termux_train/optim/__init__.py +19 -0
- amv_train-2.1.0/termux_train/optim/adam.py +199 -0
- amv_train-2.1.0/termux_train/optim/adamw.py +202 -0
- amv_train-2.1.0/termux_train/optim/optimizer.py +264 -0
- amv_train-2.1.0/termux_train/optim/sgd.py +247 -0
- amv_train-2.1.0/termux_train/rl/__init__.py +24 -0
- amv_train-2.1.0/termux_train/rl/dpo.py +98 -0
- amv_train-2.1.0/termux_train/rl/grpo.py +131 -0
- amv_train-2.1.0/termux_train/rl/ppo.py +76 -0
- amv_train-2.1.0/termux_train/rl/reward.py +117 -0
- amv_train-2.1.0/termux_train/runtime/__init__.py +32 -0
- amv_train-2.1.0/termux_train/runtime/benchmarker.py +100 -0
- amv_train-2.1.0/termux_train/runtime/checkpoint.py +592 -0
- amv_train-2.1.0/termux_train/runtime/runner.py +523 -0
- amv_train-2.1.0/termux_train/runtime/trainer.py +346 -0
- amv_train-2.1.0/termux_train/tensor.py +1364 -0
- amv_train-2.1.0/termux_train/tokenization/__init__.py +46 -0
- amv_train-2.1.0/termux_train/tokenization/base.py +321 -0
- amv_train-2.1.0/termux_train/tokenization/byte.py +178 -0
- amv_train-2.1.0/termux_train/tokenization/char.py +93 -0
- amv_train-2.1.0/termux_train/tokenization/word.py +115 -0
- amv_train-2.1.0/termux_train/utils/__init__.py +16 -0
- amv_train-2.1.0/termux_train/utils/gradcheck.py +99 -0
- amv_train-2.1.0/termux_train/utils/termux_env.py +138 -0
- amv_train-2.1.0/termux_train/vision/__init__.py +24 -0
- amv_train-2.1.0/termux_train/vision/trainer.py +191 -0
- amv_train-2.1.0/termux_train/vision/vlm_lora.py +284 -0
- amv_train-2.1.0/tests/test_adapters_hub.py +72 -0
- amv_train-2.1.0/tests/test_advanced_production_features.py +121 -0
- amv_train-2.1.0/tests/test_audio_pipeline.py +187 -0
- amv_train-2.1.0/tests/test_audit_deep_hardening.py +242 -0
- amv_train-2.1.0/tests/test_audit_hardening.py +159 -0
- amv_train-2.1.0/tests/test_audit_production_fixes.py +118 -0
- amv_train-2.1.0/tests/test_audit_scorecard.py +230 -0
- amv_train-2.1.0/tests/test_audit_verification.py +274 -0
- amv_train-2.1.0/tests/test_autograd.py +425 -0
- amv_train-2.1.0/tests/test_autograd_correctness.py +284 -0
- amv_train-2.1.0/tests/test_autograd_lifecycle.py +98 -0
- amv_train-2.1.0/tests/test_backend.py +191 -0
- amv_train-2.1.0/tests/test_cluster_virtual_ram_pooling.py +168 -0
- amv_train-2.1.0/tests/test_diffusion_pipeline.py +162 -0
- amv_train-2.1.0/tests/test_docfold.py +63 -0
- amv_train-2.1.0/tests/test_dora.py +125 -0
- amv_train-2.1.0/tests/test_dtype.py +101 -0
- amv_train-2.1.0/tests/test_embedding.py +135 -0
- amv_train-2.1.0/tests/test_functional_hardening.py +117 -0
- amv_train-2.1.0/tests/test_gpu_slicing.py +176 -0
- amv_train-2.1.0/tests/test_gradcheck.py +113 -0
- amv_train-2.1.0/tests/test_lora.py +1423 -0
- amv_train-2.1.0/tests/test_lora_adapter_io.py +179 -0
- amv_train-2.1.0/tests/test_lora_checkpoint.py +597 -0
- amv_train-2.1.0/tests/test_lora_training.py +695 -0
- amv_train-2.1.0/tests/test_nn.py +253 -0
- amv_train-2.1.0/tests/test_optim.py +606 -0
- amv_train-2.1.0/tests/test_package_identity.py +21 -0
- amv_train-2.1.0/tests/test_rl.py +107 -0
- amv_train-2.1.0/tests/test_runtime.py +298 -0
- amv_train-2.1.0/tests/test_tensor.py +138 -0
- amv_train-2.1.0/tests/test_tokenization.py +496 -0
- amv_train-2.1.0/tests/test_train_cluster.py +189 -0
- amv_train-2.1.0/tests/test_train_rpc.py +91 -0
- amv_train-2.1.0/tests/test_training.py +182 -0
- amv_train-2.1.0/tests/test_transformer.py +120 -0
- amv_train-2.1.0/tests/test_transformer_math.py +205 -0
- amv_train-2.1.0/tests/test_vision_pipeline.py +157 -0
amv_train-2.1.0/LICENSE
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
40
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
41
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
42
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
43
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
44
|
+
Work and such Derivative Works in Source or Object form.
|
|
45
|
+
|
|
46
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
47
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
48
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
49
|
+
patent license to make, have made, use, offer to sell, sell, import,
|
|
50
|
+
and otherwise transfer the Work.
|
|
51
|
+
|
|
52
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
53
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
54
|
+
modifications, and in Source or Object form, provided that You
|
|
55
|
+
meet the conditions of this License.
|
|
56
|
+
|
|
57
|
+
END OF TERMS AND CONDITIONS
|
amv_train-2.1.0/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
termux-train
|
|
2
|
+
Copyright 2026 termux-train contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the termux-train project
|
|
5
|
+
(https://github.com/uno-km/termux-train) and AMEVA Open-Source Foundation.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
amv_train-2.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amv-train
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: On-device deep learning & LoRA training framework utilizing device resources for Android Termux
|
|
5
|
+
Author-email: AMEVA Team <zhfldk014745@naver.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/uno-km/amv-train
|
|
8
|
+
Project-URL: Documentation, https://github.com/uno-km/amv-train#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/uno-km/amv-train
|
|
10
|
+
Project-URL: Issues, https://github.com/uno-km/amv-train/issues
|
|
11
|
+
Keywords: termux,android,autograd,deep-learning,on-device-training,lora,transformer,safetensors,quantization
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
23
|
+
Classifier: Operating System :: Android
|
|
24
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
25
|
+
Classifier: Operating System :: MacOS
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
License-File: NOTICE
|
|
31
|
+
Requires-Dist: ameva-component-sdk<2.0,>=0.1.0
|
|
32
|
+
Provides-Extra: accelerated
|
|
33
|
+
Requires-Dist: numpy>=1.20.0; extra == "accelerated"
|
|
34
|
+
Provides-Extra: vulkan
|
|
35
|
+
Requires-Dist: ameva-runtime>=2.0.0; extra == "vulkan"
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: pytest>=7.0.0; extra == "test"
|
|
38
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
|
|
39
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: numpy>=1.20.0; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
43
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
44
|
+
Provides-Extra: all
|
|
45
|
+
Requires-Dist: numpy>=1.20.0; extra == "all"
|
|
46
|
+
Requires-Dist: ameva-runtime>=2.0.0; extra == "all"
|
|
47
|
+
Requires-Dist: pytest>=7.0.0; extra == "all"
|
|
48
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "all"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# AMV-Train (v2.0.0)
|
|
52
|
+
|
|
53
|
+
> **마이그레이션 안내**: 이 패키지는 `termux-train`에서 `amv-train`로 이름이 바뀌었습니다. 기존 `termux-train` 배포본(PyPI/npm)은 호환을 위해 당분간 유지되나 deprecated 상태이며 더 이상 갱신되지 않습니다. `pip install amv-train` / `npm install amv-train`로 전환하십시오.
|
|
54
|
+
>
|
|
55
|
+
> Android **Termux 환경** 또는 **안드로이드 Linux 커널(루팅 없이 Linux 환경이 구동되는 모든 디바이스)** 에서 동작합니다 — Termux 전용이 아닙니다.
|
|
56
|
+
|
|
57
|
+
[](https://pypi.org/project/amv-train/)
|
|
58
|
+
[](https://pypi.org/project/amv-train/)
|
|
59
|
+
[](https://www.npmjs.com/package/amv-train)
|
|
60
|
+
[](https://www.npmjs.com/package/amv-train)
|
|
61
|
+
[](https://github.com/uno-km/amv-train)
|
|
62
|
+
|
|
63
|
+
> **Unified Multimodal On-Device Deep Learning & LoRA Training Framework for Android Termux with 6-Modality Adapters (LLM, Diffusion, VLM, STT, TTS, BitNet), GPU Slicing, and 44GB Disaggregated Cluster Virtual RAM Pooling**
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## What's New in v2.1.0 — Vulkan Backend Line-Break Syntax Patch & DAG Autograd Hardening
|
|
68
|
+
|
|
69
|
+
- Fixed CRLF line-break syntax error in Vulkan compute shader backend.
|
|
70
|
+
- Hardened SafeTensors zero-copy memory mapping and LoRA gradient accumulation.
|
|
71
|
+
- Standardized Apache-2.0 SPDX license headers and published npm package v2.1.0.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Executive Summary & Architecture Overview
|
|
76
|
+
|
|
77
|
+
**Termux-Train v2.0.0** is an industrial-grade, zero-dependency deep learning framework engineered specifically for constrained ARM64 Bionic environments (Android Termux, mobile Linux, embedded edge devices). By combining a C-vectorized Directed Acyclic Graph (DAG) Autograd runtime with mobile hardware acceleration (Vulkan Compute, OpenCL, ARM64 NEON), Termux-Train enables full backward gradient propagation, parameter-efficient fine-tuning (LoRA / DoRA), and reinforcement learning directly on mobile devices.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
+---------------------------------------------------------------------------------------------------+
|
|
81
|
+
| TERMUX-TRAIN v2.0.0 |
|
|
82
|
+
| Unified Multimodal On-Device Deep Learning Engine |
|
|
83
|
+
+---------------------------------------------------------------------------------------------------+
|
|
84
|
+
|
|
|
85
|
+
+-----------------------------------------+-----------------------------------------+
|
|
86
|
+
| |
|
|
87
|
+
v v
|
|
88
|
+
+-------------------------------+ +-------------------------------+
|
|
89
|
+
| 6-Modality Adapters | | Memory & Scaling Subsys |
|
|
90
|
+
| - LLM / DoRA / TinyLM | | - Single-Device GPU Slicing |
|
|
91
|
+
| - Image Diffusion LoRA | | * Vocab Slicing |
|
|
92
|
+
| - Vision Multimodal (VLM) | | * Chunked Layer Dispatch |
|
|
93
|
+
| - Whisper STT Acoustic LoRA | | * Layer Streaming |
|
|
94
|
+
| - Speech TTS Style LoRA | | - 44GB Cluster Virtual RAM |
|
|
95
|
+
| - BitNet 1.58-bit Ternary | | - 300MB Guard-Band Memory |
|
|
96
|
+
+-------------------------------+ +-------------------------------+
|
|
97
|
+
| |
|
|
98
|
+
+-----------------------------------------+-----------------------------------------+
|
|
99
|
+
|
|
|
100
|
+
v
|
|
101
|
+
+---------------------------------------------------------------------------------------------------+
|
|
102
|
+
| Target-Aware Runtime Export & Compatibility |
|
|
103
|
+
| ComfyUI / Diffusers | llama.cpp / GGUF | termux-vision | termux-stt | BitNet |
|
|
104
|
+
+---------------------------------------------------------------------------------------------------+
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Core Architectural Pillars
|
|
108
|
+
|
|
109
|
+
1. **Zero External Heavy Dependencies**: Executes autonomously without PyTorch, LibTorch, CMake, or heavy BLAS runtimes. Pure Python DAG autograd paired with optional C-accelerator ABI (`libtermux_train_accel.so`) or Vulkan compute shaders.
|
|
110
|
+
2. **6-Modality Target-Aware Adapters**: Generates standard SafeTensors weights and companion `_config.json` manifests natively recognized by major desktop and mobile inference runtimes without conversion tooling.
|
|
111
|
+
3. **Single-Device GPU Slicing**: Bypasses mobile Unified Memory Architecture (UMA) spikes and watchdog timeouts on ARM Mali and Qualcomm Adreno GPUs through granular vocabulary chunking and layer streaming.
|
|
112
|
+
4. **44GB Disaggregated Cluster Virtual RAM Pooling**: Binds physical memory across heterogeneous mobile nodes (e.g., Galaxy S25, S21, S20, A53, A35) into an aggregated pipeline training session protected by a 300MB memory Guard-Band against the Android Low Memory Killer (LMK).
|
|
113
|
+
5. **100% Dual-Engine Parity**: Complete feature and interface symmetry across Python CLI (`amv-train`), Node.js Global CLI (`amv-train`), Python Library (`import termux_train`), and Node.js SDK (`import { ... } from 'amv-train'`).
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Installation
|
|
118
|
+
|
|
119
|
+
### 1. Via Python Package Index (PyPI)
|
|
120
|
+
```bash
|
|
121
|
+
pip install amv-train
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 2. Via Node Package Manager (npm)
|
|
125
|
+
```bash
|
|
126
|
+
npm install -g amv-train
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 3. Standalone Bootstrap Script (Termux One-Liner)
|
|
130
|
+
```bash
|
|
131
|
+
pkg update && pkg install -y python nodejs clang
|
|
132
|
+
bash <(curl -sSL https://raw.githubusercontent.com/uno-km/amv-train/main/install.sh)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 6-Modality Training Pipelines & CLI Reference
|
|
138
|
+
|
|
139
|
+
### 1. Image Diffusion LoRA Training (`diffusion-train`)
|
|
140
|
+
Trains latent diffusion cross-attention LoRA layers. Integrates a deterministic DDPM noise scheduler, sinusoidal timestep MLP, and SHA-256 disk-based VAE latent caching to eliminate redundant image decoding across epochs. Outputs ComfyUI- and Diffusers-compatible SafeTensors adapters.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
amv-train diffusion-train \
|
|
144
|
+
--image-dir ./training_images \
|
|
145
|
+
--prompt "high quality product photograph, 4k" \
|
|
146
|
+
--output ./adapter_diffusion.safetensors \
|
|
147
|
+
--resolution 512 \
|
|
148
|
+
--epochs 5 \
|
|
149
|
+
--batch-size 1 \
|
|
150
|
+
--lr 0.0001 \
|
|
151
|
+
--rank 8 \
|
|
152
|
+
--alpha 16.0 \
|
|
153
|
+
--backend vulkan
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 2. Vision Multimodal VLM LoRA Training (`vision-train`)
|
|
157
|
+
Trains multimodal projection adapters and visual cross-attention layers. Operates on image-text pairs formatted in LLaVA or Qwen2-VL visual question answering schemas. Directly bridges into the `termux-vision` mobile inference runtime.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
amv-train vision-train \
|
|
161
|
+
--data ./vlm_dataset.jsonl \
|
|
162
|
+
--output ./adapter_vision.safetensors \
|
|
163
|
+
--epochs 3 \
|
|
164
|
+
--batch-size 2 \
|
|
165
|
+
--lr 0.0002 \
|
|
166
|
+
--rank 8 \
|
|
167
|
+
--alpha 16.0 \
|
|
168
|
+
--backend vulkan
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 3. Speech-to-Text Whisper LoRA Training (`stt-train`)
|
|
172
|
+
Performs acoustic adaptation on Whisper encoder-decoder attention blocks. Features automated Mel filterbank spectrogram extraction and persistent caching. Natively consumable by `termux-stt`.
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
amv-train stt-train \
|
|
176
|
+
--data ./speech_corpus.jsonl \
|
|
177
|
+
--output ./adapter_stt.safetensors \
|
|
178
|
+
--epochs 4 \
|
|
179
|
+
--batch-size 4 \
|
|
180
|
+
--lr 0.0005 \
|
|
181
|
+
--rank 4 \
|
|
182
|
+
--backend vulkan
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 4. Text-to-Speech Style Adaptation LoRA Training (`tts-train`)
|
|
186
|
+
Fine-tunes speaker embedding and acoustic style parameters for neural speech synthesis. Generates low-rank voice profile adapters directly compatible with `termux-tts`.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
amv-train tts-train \
|
|
190
|
+
--data ./voice_samples.jsonl \
|
|
191
|
+
--output ./adapter_tts.safetensors \
|
|
192
|
+
--epochs 5 \
|
|
193
|
+
--batch-size 2 \
|
|
194
|
+
--lr 0.0003 \
|
|
195
|
+
--rank 4 \
|
|
196
|
+
--backend cpu
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 5. Large Language Model PEFT (`train` / `peft`)
|
|
200
|
+
Trains LoRA / DoRA weight matrices over multi-head attention and feed-forward projections with RoPE positional encodings. Supports single-device GPU slicing flags to eliminate out-of-memory crashes on mobile GPUs. Exports standard GGUF PEFT adapters for `llama.cpp`.
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
amv-train train \
|
|
204
|
+
--model tiny-transformer \
|
|
205
|
+
--data ./training_corpus.txt \
|
|
206
|
+
--output ./adapter_llm.safetensors \
|
|
207
|
+
--epochs 3 \
|
|
208
|
+
--lr 0.0002 \
|
|
209
|
+
--lora-rank 8 \
|
|
210
|
+
--lora-alpha 16.0 \
|
|
211
|
+
--vocab-slice 4096 \
|
|
212
|
+
--chunk-layers 2 \
|
|
213
|
+
--stream-layers \
|
|
214
|
+
--backend vulkan
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 6. BitNet 1.58-bit Ternary Quantization-Aware Training
|
|
218
|
+
Applies dynamic activation scaling and ternary weight quantization $\{-1, 0, +1\}$ during forward and backward passes. Directly exports quantized kernels compatible with `bitnet.cpp` and `termux-bitnet`.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
amv-train train \
|
|
222
|
+
--model bitnet \
|
|
223
|
+
--quantize-bits 1.58 \
|
|
224
|
+
--data ./corpus.txt \
|
|
225
|
+
--output ./bitnet_adapter.safetensors \
|
|
226
|
+
--backend opencl
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Complete Parameter Reference Matrix
|
|
232
|
+
|
|
233
|
+
| Parameter Flag | Type | Default | Applicable Subcommands | Engineering Semantics & Usage Description |
|
|
234
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
235
|
+
| `--image-dir` | String | *Required* | `diffusion-train` | Absolute or relative path to directory containing source training images (`.png`, `.jpg`). |
|
|
236
|
+
| `--prompt` | String | `""` | `diffusion-train` | Conditioning text prompt applied across image diffusion training instances. |
|
|
237
|
+
| `--resolution` | Integer | `512` | `diffusion-train` | Input image dimension for latent VAE spatial encoding ($H=W$). |
|
|
238
|
+
| `--data` | String | *Required* | `vision-train`, `stt-train`, `tts-train`, `train`, `rl` | Path to dataset file (`.jsonl`, `.txt`, `.csv`). |
|
|
239
|
+
| `--output` | String | *Required* | All training subcommands | Destination filepath for exported `.safetensors` adapter file. |
|
|
240
|
+
| `--epochs` | Integer | `3` | All training subcommands | Total complete passes over the dataset. |
|
|
241
|
+
| `--batch-size` | Integer | `1` | All training subcommands | Micro-batch size per training step. |
|
|
242
|
+
| `--lr` | Float | `0.0001` | All training subcommands | Optimization learning rate for AdamW / SGD gradient update. |
|
|
243
|
+
| `--rank` / `--lora-rank` | Integer | `8` | All training subcommands | Inner rank dimension $r$ for LoRA projection matrices $A \in \mathbb{R}^{r \times d_{in}}$ and $B \in \mathbb{R}^{d_{out} \times r}$. |
|
|
244
|
+
| `--alpha` / `--lora-alpha`| Float | `16.0` | All training subcommands | Scaling hyperparameter $\alpha$ for LoRA weight contribution ($\Delta W = \frac{\alpha}{r} BA$). |
|
|
245
|
+
| `--backend` | String | `auto` | All subcommands | Compute acceleration backend: `auto`, `vulkan`, `opencl`, `cpu`. |
|
|
246
|
+
| `--vocab-slice` | Integer | `0` (off) | `train`, `peft` | Granular vocabulary partition size to prevent GPU out-of-memory spikes during softmax cross-entropy. |
|
|
247
|
+
| `--chunk-layers` | Integer | `0` (off) | `train`, `peft` | Number of sequential transformer layers evaluated per GPU dispatch to prevent OS watchdog timeout resets. |
|
|
248
|
+
| `--stream-layers` | Boolean | `false` | `train`, `peft` | Dynamically streams inactive layer weights between system RAM and GPU buffer memory. |
|
|
249
|
+
| `--virtual-ram-pool` | String | `""` | `train`, `diffusion-train`, `peft` | Cluster connection endpoint (`host:port`) binding local training session to aggregated virtual RAM pool. |
|
|
250
|
+
| `--guard-band` | Integer | `300` | `cluster-worker`, `train` | Reserved unallocated system RAM buffer (in MB) preventing Android Low Memory Killer (LMK) aborts. |
|
|
251
|
+
| `--method` | String | `grpo` | `rl` | Reinforcement learning optimization algorithm: `grpo`, `dpo`, `ppo`. |
|
|
252
|
+
| `--group-size` | Integer | `4` | `rl` | Generation group candidate size for Group Relative Policy Optimization (GRPO). |
|
|
253
|
+
| `--beta` | Float | `0.1` | `rl` | KL divergence regularization coefficient for DPO and GRPO reference policy stabilization. |
|
|
254
|
+
| `--host` | String | `0.0.0.0` | `cluster-worker`, `cluster-probe`| Network host address for disaggregated virtual RAM clustering daemon. |
|
|
255
|
+
| `--port` | Integer | `50052` | `cluster-worker`, `cluster-probe`| Network TCP port for cluster worker coordination. |
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Single-Device GPU Slicing Architecture
|
|
260
|
+
|
|
261
|
+
On mobile platforms, the GPU and CPU share a Unified Memory Architecture (UMA). Large batch matrix multiplications during autograd activation accumulation trigger sudden memory surges that prompt the Android system to issue SIGKILL signals. Furthermore, ARM Mali GPU driver stacks enforce a hardware watchdog timeout: any single compute command buffer executing longer than 2.0 seconds is terminated with `VK_ERROR_DEVICE_LOST`.
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
MOBILE UNIFIED RAM (LPDDR5)
|
|
265
|
+
+-------------------------------------------------------------------------+
|
|
266
|
+
| OS Kernel / Termux Base | Active Layer Buffer | Guard-Band Buffer (300MB)|
|
|
267
|
+
+-------------------------------------------------------------------------+
|
|
268
|
+
^
|
|
269
|
+
| Layer Streaming Swap
|
|
270
|
+
v
|
|
271
|
+
VULKAN / OPENCL GPU ENGINE
|
|
272
|
+
+-------------------------------------------------------------------------+
|
|
273
|
+
| [Vocab Chunk 1] -> [Vocab Chunk 2] | [Layer N] -> [Layer N+1] (Chunked) |
|
|
274
|
+
+-------------------------------------------------------------------------+
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
To neutralize these constraints:
|
|
278
|
+
- **Vocab Slicing (`--vocab-slice 4096`)**: Partitions vocabulary projection matrices into slices of 4,096 tokens, performing sequential cross-entropy reductions with minimal temporary tensor overhead.
|
|
279
|
+
- **Chunked Layer Dispatch (`--chunk-layers 2`)**: Segments multi-layer transformer forward-backward passes into 2-layer dispatches, returning control to the Vulkan queue to reset watchdog timers.
|
|
280
|
+
- **Layer Streaming (`--stream-layers`)**: Maintains only active weight layers inside device GPU memory buffers, paging inactive weights into host RAM.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 44GB Disaggregated Cluster Virtual RAM Pooling (Powered by AMEVA Cluster)
|
|
285
|
+
|
|
286
|
+
> [!IMPORTANT]
|
|
287
|
+
> **Prerequisite: Official AMEVA Cluster Runtime (`ameva-cluster`) Required**
|
|
288
|
+
> Multi-device distributed memory pooling and cross-device tensor pipeline execution require the official **`ameva-cluster`** control plane. Single-device training (CPU, Vulkan, OpenCL) runs entirely standalone, but distributed cluster pooling features will raise `ClusterLicenseRequiredError` (E403) unless `ameva-cluster` is installed.
|
|
289
|
+
> ```bash
|
|
290
|
+
> pip install ameva-cluster amv-train
|
|
291
|
+
> # or via npm:
|
|
292
|
+
> npm install -g @ameva/cluster amv-train
|
|
293
|
+
> ```
|
|
294
|
+
|
|
295
|
+
When training deep learning models that exceed physical mobile device memory (e.g. 7B+ parameter models, high-resolution diffusion unets, or multimodal projectors), Termux-Train binds heterogeneous smartphone clusters into a unified virtual memory pool. Idle mobile devices contribute unallocated LPDDR RAM via lightweight worker daemons managed by AMEVA Cluster.
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
+-------------------------------------------------------------------------+
|
|
299
|
+
| COORDINATOR / PRIMARY NODE (Galaxy S25 - 12GB) |
|
|
300
|
+
| Directs Training Pipeline & Weight Updates |
|
|
301
|
+
+-------------------------------------------------------------------------+
|
|
302
|
+
| | |
|
|
303
|
+
gRPC/HTTP RPC gRPC/HTTP RPC gRPC/HTTP RPC
|
|
304
|
+
(MasterTunnel) (MasterTunnel) (MasterTunnel)
|
|
305
|
+
v v v
|
|
306
|
+
+--------------------+ +--------------------+ +--------------------+
|
|
307
|
+
| WORKER 1 (S21) | | WORKER 2 (S20) | | WORKER 3 (A53/A35) |
|
|
308
|
+
| RAM: 8GB LPDDR5 | | RAM: 12GB LPDDR5 | | RAM: 12GB LPDDR4X |
|
|
309
|
+
| Dedicated: 6.8GB | | Dedicated: 10.5GB | | Dedicated: 9.2GB |
|
|
310
|
+
+--------------------+ +--------------------+ +--------------------+
|
|
311
|
+
\ | /
|
|
312
|
+
+--------------------------+--------------------------+
|
|
313
|
+
|
|
|
314
|
+
v
|
|
315
|
+
TOTAL AGGREGATED VIRTUAL POOL: ~44GB
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Complete Cluster Step-by-Step Operation Manual
|
|
319
|
+
|
|
320
|
+
#### Step 1: Network & Environment Setup
|
|
321
|
+
Ensure all participating smartphones are connected to the same local Wi-Fi network, router, or tethered hotspot. Verify TCP port `50052` is accessible between nodes:
|
|
322
|
+
```bash
|
|
323
|
+
pkg update && pkg install -y python clang netcat-openbsd
|
|
324
|
+
pip install --upgrade ameva-cluster amv-train
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### Step 2: Launching Cluster Workers on Contributor Nodes
|
|
328
|
+
On each memory-contributor smartphone (e.g., Galaxy S21, S20, A53), start the worker daemon. The `--guard-band 300` flag reserves 300MB of unallocated system RAM at all times to prevent the Android Low Memory Killer (LMK) from terminating processes:
|
|
329
|
+
```bash
|
|
330
|
+
# Option A: Directly through ameva-cluster
|
|
331
|
+
ameva-cluster worker --port 50052 --guard-band 300
|
|
332
|
+
|
|
333
|
+
# Option B: Through amv-train CLI bridge
|
|
334
|
+
amv-train cluster-worker --port 50052 --guard-band 300
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
#### Step 3: Probing and Discovering Fleet Nodes
|
|
338
|
+
On your primary coordinator smartphone (e.g., Galaxy S25), run a cluster probe to inspect node reachability, available LPDDR memory headroom, and network round-trip ping times:
|
|
339
|
+
```bash
|
|
340
|
+
amv-train cluster-probe --fleet 192.168.1.101:50052,192.168.1.102:50052,192.168.1.103:50052
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
#### Step 4: Initiating Distributed Virtual RAM Pipeline Training
|
|
344
|
+
Train across the aggregated 44GB virtual RAM pool with zero changes to model architecture:
|
|
345
|
+
```bash
|
|
346
|
+
# Distributed LLM LoRA Training with GPU Slicing
|
|
347
|
+
amv-train train \
|
|
348
|
+
--model tiny-transformer \
|
|
349
|
+
--data ./large_corpus.txt \
|
|
350
|
+
--output ./cluster_adapter.safetensors \
|
|
351
|
+
--virtual-ram-pool 192.168.1.101:50052,192.168.1.102:50052,192.168.1.103:50052 \
|
|
352
|
+
--epochs 5 \
|
|
353
|
+
--vocab-slice 4096 \
|
|
354
|
+
--chunk-layers 2 \
|
|
355
|
+
--backend vulkan
|
|
356
|
+
|
|
357
|
+
# Distributed Image Diffusion LoRA Training
|
|
358
|
+
amv-train diffusion-train \
|
|
359
|
+
--image-dir ./dataset \
|
|
360
|
+
--output ./diff_cluster_adapter.safetensors \
|
|
361
|
+
--virtual-ram-pool 192.168.1.101:50052,192.168.1.102:50052 \
|
|
362
|
+
--epochs 5 \
|
|
363
|
+
--backend vulkan
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
#### Step 5: MasterTunnel Cryptographic Loopback Security
|
|
367
|
+
When passing sensitive weights and intermediate activations across untrusted Wi-Fi subnets, `amv-train` and `ameva-cluster` automatically spawn an authenticated `MasterTunnel` that wraps all inter-device gRPC/HTTP RPC traffic with an ephemeral SHA-256 cryptographic handshake.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Programmatic SDK Usage
|
|
372
|
+
|
|
373
|
+
### Python SDK
|
|
374
|
+
```python
|
|
375
|
+
import termux_train as tt
|
|
376
|
+
|
|
377
|
+
# High-level training interface
|
|
378
|
+
trainer = tt.TermuxTrainer(
|
|
379
|
+
model_type="lora",
|
|
380
|
+
lora_rank=8,
|
|
381
|
+
lora_alpha=16.0,
|
|
382
|
+
backend="vulkan",
|
|
383
|
+
vocab_slice=4096,
|
|
384
|
+
chunk_layers=2
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
metrics = trainer.fit(
|
|
388
|
+
data_path="./corpus.txt",
|
|
389
|
+
epochs=3,
|
|
390
|
+
learning_rate=0.0002,
|
|
391
|
+
output_path="./model_lora.safetensors"
|
|
392
|
+
)
|
|
393
|
+
print(f"Final training loss: {metrics['final_loss']:.4f}")
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Node.js / TypeScript SDK
|
|
397
|
+
```typescript
|
|
398
|
+
import { trainDiffusion, trainVision, trainSTT, TermuxTrainer } from 'amv-train';
|
|
399
|
+
|
|
400
|
+
// Asynchronous image diffusion fine-tuning
|
|
401
|
+
const result = await trainDiffusion({
|
|
402
|
+
imageDir: './training_images',
|
|
403
|
+
output: './adapter_diffusion.safetensors',
|
|
404
|
+
prompt: 'photorealistic macro nature photography',
|
|
405
|
+
resolution: 512,
|
|
406
|
+
epochs: 5,
|
|
407
|
+
backend: 'vulkan'
|
|
408
|
+
});
|
|
409
|
+
console.log(`Diffusion training completed with status: ${result.status}`);
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Target Runtime Compatibility & Adapter Hub
|
|
415
|
+
|
|
416
|
+
All adapters generated by Termux-Train are zero-conversion artifacts accompanied by a standardized `_config.json` sidecar.
|
|
417
|
+
|
|
418
|
+
| Target Runtime | Adapter Format | Companion Sidecar | Validation Status |
|
|
419
|
+
| :--- | :--- | :--- | :--- |
|
|
420
|
+
| **ComfyUI / Diffusers** | `.safetensors` (UNet CrossAttention) | `adapter_diffusion_config.json` | Validated by automated checks |
|
|
421
|
+
| **llama.cpp / GGUF** | `.safetensors` / GGUF LoRA | `adapter_llm_config.json` | Validated by automated checks |
|
|
422
|
+
| **termux-vision** | `.safetensors` (Multimodal Projector) | `adapter_vision_config.json` | Validated by automated checks |
|
|
423
|
+
| **termux-stt** | `.safetensors` (Whisper Attention) | `adapter_stt_config.json` | Validated by automated checks |
|
|
424
|
+
| **termux-tts** | `.safetensors` (Speaker Style) | `adapter_tts_config.json` | Validated by automated checks |
|
|
425
|
+
| **bitnet.cpp** | `.safetensors` (Ternary 1.58-bit) | `bitnet_config.json` | Validated by automated checks |
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## Official Documentation & Foundation Resources
|
|
430
|
+
|
|
431
|
+
- [Official Architecture & API Reference](https://uno-km.vercel.app/lib/train/)
|
|
432
|
+
- [Ecosystem Metrics & Registry Stats](https://uno-km.vercel.app/foundation/metrics)
|
|
433
|
+
- [AMEVA Open-Source Foundation Portal](https://uno-km.vercel.app/foundation/index.html)
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## Open-Source Attribution & License
|
|
438
|
+
|
|
439
|
+
Licensed under the **Apache-2.0 License**. Copyright (c) 2026 Eunho Kim ([@uno-km](https://github.com/uno-km)) and the AMEVA Open-Source Foundation.
|