ftuneai 0.2.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.
Files changed (45) hide show
  1. ftuneai-0.2.0/.devcontainer/devcontainer.json +33 -0
  2. ftuneai-0.2.0/.github/workflows/ci.yml +55 -0
  3. ftuneai-0.2.0/.github/workflows/publish.yml +31 -0
  4. ftuneai-0.2.0/.gitignore +33 -0
  5. ftuneai-0.2.0/.streamlit/config.toml +12 -0
  6. ftuneai-0.2.0/CONTRIBUTING.md +76 -0
  7. ftuneai-0.2.0/LICENSE +21 -0
  8. ftuneai-0.2.0/PKG-INFO +616 -0
  9. ftuneai-0.2.0/README.md +569 -0
  10. ftuneai-0.2.0/examples/basic_memory.py +69 -0
  11. ftuneai-0.2.0/examples/full_estimate.py +97 -0
  12. ftuneai-0.2.0/examples/validate.py +85 -0
  13. ftuneai-0.2.0/pyproject.toml +78 -0
  14. ftuneai-0.2.0/requirements.txt +5 -0
  15. ftuneai-0.2.0/src/ftune/__init__.py +72 -0
  16. ftuneai-0.2.0/src/ftune/__main__.py +5 -0
  17. ftuneai-0.2.0/src/ftune/app.py +445 -0
  18. ftuneai-0.2.0/src/ftune/calibration.py +253 -0
  19. ftuneai-0.2.0/src/ftune/cli/__init__.py +1 -0
  20. ftuneai-0.2.0/src/ftune/cli/app.py +335 -0
  21. ftuneai-0.2.0/src/ftune/cli/display.py +152 -0
  22. ftuneai-0.2.0/src/ftune/core/__init__.py +1 -0
  23. ftuneai-0.2.0/src/ftune/core/cost.py +339 -0
  24. ftuneai-0.2.0/src/ftune/core/memory.py +352 -0
  25. ftuneai-0.2.0/src/ftune/core/models.py +205 -0
  26. ftuneai-0.2.0/src/ftune/core/time.py +241 -0
  27. ftuneai-0.2.0/src/ftune/data/gpus.yaml +103 -0
  28. ftuneai-0.2.0/src/ftune/data/models.yaml +173 -0
  29. ftuneai-0.2.0/src/ftune/data/pricing.yaml +225 -0
  30. ftuneai-0.2.0/src/ftune/estimator.py +306 -0
  31. ftuneai-0.2.0/src/ftune/hub.py +226 -0
  32. ftuneai-0.2.0/src/ftune/loader.py +157 -0
  33. ftuneai-0.2.0/src/ftune/optimizer.py +260 -0
  34. ftuneai-0.2.0/src/ftune/utils/__init__.py +1 -0
  35. ftuneai-0.2.0/src/ftune/utils/formatting.py +38 -0
  36. ftuneai-0.2.0/src/ftune/validation.py +382 -0
  37. ftuneai-0.2.0/streamlit_app.py +17 -0
  38. ftuneai-0.2.0/tests/__init__.py +0 -0
  39. ftuneai-0.2.0/tests/conftest.py +51 -0
  40. ftuneai-0.2.0/tests/test_cost.py +275 -0
  41. ftuneai-0.2.0/tests/test_hub.py +210 -0
  42. ftuneai-0.2.0/tests/test_memory.py +720 -0
  43. ftuneai-0.2.0/tests/test_optimizer.py +145 -0
  44. ftuneai-0.2.0/tests/test_time.py +222 -0
  45. ftuneai-0.2.0/tests/test_validation.py +119 -0
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "Python 3",
3
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
4
+ "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",
5
+ "customizations": {
6
+ "codespaces": {
7
+ "openFiles": [
8
+ "README.md",
9
+ "streamlit_app.py"
10
+ ]
11
+ },
12
+ "vscode": {
13
+ "settings": {},
14
+ "extensions": [
15
+ "ms-python.python",
16
+ "ms-python.vscode-pylance"
17
+ ]
18
+ }
19
+ },
20
+ "updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'",
21
+ "postAttachCommand": {
22
+ "server": "streamlit run streamlit_app.py --server.enableCORS false --server.enableXsrfProtection false"
23
+ },
24
+ "portsAttributes": {
25
+ "8501": {
26
+ "label": "Application",
27
+ "onAutoForward": "openPreview"
28
+ }
29
+ },
30
+ "forwardPorts": [
31
+ 8501
32
+ ]
33
+ }
@@ -0,0 +1,55 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install pyyaml pytest pytest-cov
28
+
29
+ - name: Run tests
30
+ run: |
31
+ PYTHONPATH=src pytest tests/ -v --tb=short
32
+
33
+ - name: Run examples (smoke test)
34
+ run: |
35
+ PYTHONPATH=src python examples/basic_memory.py
36
+ PYTHONPATH=src python examples/validate.py
37
+
38
+ type-check:
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+
43
+ - name: Set up Python 3.12
44
+ uses: actions/setup-python@v5
45
+ with:
46
+ python-version: "3.12"
47
+
48
+ - name: Install dependencies
49
+ run: |
50
+ python -m pip install --upgrade pip
51
+ pip install pyyaml mypy types-PyYAML
52
+
53
+ - name: Run mypy
54
+ run: |
55
+ PYTHONPATH=src mypy src/ftune/ --ignore-missing-imports
@@ -0,0 +1,31 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.12"
21
+
22
+ - name: Install build tools
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ pip install build
26
+
27
+ - name: Build package
28
+ run: python -m build
29
+
30
+ - name: Publish to PyPI
31
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,33 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ *.egg
9
+
10
+ # Virtual environments
11
+ .venv/
12
+ venv/
13
+ env/
14
+
15
+ # IDE / tools
16
+ .vscode/
17
+ .idea/
18
+ .claude/
19
+ *.swp
20
+ *.swo
21
+
22
+ # Testing
23
+ .pytest_cache/
24
+ .coverage
25
+ htmlcov/
26
+
27
+ # Generated
28
+ docs/
29
+
30
+ # OS
31
+ .DS_Store
32
+ Thumbs.db
33
+ *.docx
@@ -0,0 +1,12 @@
1
+ [theme]
2
+ primaryColor = "#6C63FF"
3
+ backgroundColor = "#0E1117"
4
+ secondaryBackgroundColor = "#1A1A2E"
5
+ textColor = "#FAFAFA"
6
+ font = "sans serif"
7
+
8
+ [server]
9
+ headless = true
10
+
11
+ [browser]
12
+ gatherUsageStats = false
@@ -0,0 +1,76 @@
1
+ # Contributing to ftune
2
+
3
+ Thanks for your interest in contributing! Here's how you can help.
4
+
5
+ ## 🏆 Highest-Impact Contributions
6
+
7
+ ### 1. Validate Estimates (Most Wanted!)
8
+ Run ftune against your actual training runs and share the results. This helps everyone calibrate expectations.
9
+
10
+ ```python
11
+ from ftune import Estimator
12
+ from ftune.validation import Validator, ActualMetrics
13
+
14
+ est = Estimator(model="your-model", method="qlora", quantization="4bit", ...)
15
+ actual = ActualMetrics(
16
+ peak_memory_gb=..., # from nvidia-smi
17
+ training_time_hours=..., # wall-clock
18
+ gpu_name="...",
19
+ dataset_size=...,
20
+ epochs=...,
21
+ )
22
+ result = Validator.compare(est, actual)
23
+ print(Validator.format_report(result))
24
+ ```
25
+
26
+ Open an issue or PR with your validation report!
27
+
28
+ ### 2. Update Pricing Data
29
+ Cloud GPU pricing changes frequently. Help keep `src/ftune/data/pricing.yaml` current.
30
+
31
+ ### 3. Add Models
32
+ Add new model specs to `src/ftune/data/models.yaml`. Include: parameters, hidden_size, num_layers, num_attention_heads, num_kv_heads, intermediate_size, vocab_size, max_seq_length.
33
+
34
+ ### 4. Add GPUs
35
+ Add new GPU specs to `src/ftune/data/gpus.yaml`. Include: vram_gb, fp16_tflops, bf16_tflops, fp32_tflops, memory_bandwidth_gbps.
36
+
37
+ ## Development Setup
38
+
39
+ ```bash
40
+ git clone https://github.com/ritikmahy5/ftune.git
41
+ cd ftune
42
+
43
+ # Install dev dependencies
44
+ pip install -e ".[dev]"
45
+
46
+ # Run tests
47
+ PYTHONPATH=src pytest tests/ -v
48
+
49
+ # Run the CLI (needs extras)
50
+ pip install typer rich
51
+ PYTHONPATH=src python -m ftune estimate --model meta-llama/Llama-3.1-8B --method qlora
52
+
53
+ # Run the web UI
54
+ pip install streamlit pandas altair
55
+ PYTHONPATH=src streamlit run src/ftune/app.py
56
+ ```
57
+
58
+ ## Code Style
59
+
60
+ - Type hints on all functions
61
+ - Docstrings on all public methods
62
+ - Keep zero ML dependencies in core (no torch/transformers)
63
+ - Run `ruff check src/` before submitting
64
+
65
+ ## Pull Request Process
66
+
67
+ 1. Fork the repo and create a feature branch
68
+ 2. Add tests for any new functionality
69
+ 3. Ensure all tests pass: `PYTHONPATH=src pytest tests/ -v`
70
+ 4. Submit a PR with a clear description
71
+
72
+ ## Reporting Issues
73
+
74
+ - For inaccurate estimates: include your model, config, actual metrics, and ftune output
75
+ - For bugs: include Python version, OS, and full traceback
76
+ - For feature requests: describe the use case and expected behavior
ftuneai-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ftune contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.