Skip to content

Commit 4ee3a19

Browse files
author
Pranav A
committed
Pull request #10: 2026/pranav a
Merge in TINYML-ALGO/tinyml-agent-skills from 2026/pranav_a to main * commit 'be83fc6267a898cc6eeab38ffe0c0a344528ab97': minor fixes removed assets, included autoMP quant
2 parents 1af575a + be83fc6 commit 4ee3a19

25 files changed

Lines changed: 159 additions & 8255 deletions

skills/tinyml-agentic-skill/SKILL.md

Lines changed: 52 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,10 @@ python3 $SCRIPTS_DIR/runner.py get_data_proc_feat_ext_recommendations \
295295
**IMPORTANT - NEVER SKIP THIS CHECK**
296296
Before returning the fetched recommendations to the user, go through the dataset analysis in `$WORK_DIR/.tmp_dataset_stats.json` completely. Based on these statistics ensure the recommended presets/transforms are suited for the dataset.
297297
For example:
298-
If for a classification task, the `min_sample_or_seq_length` is 70, then having a frame size of 128 or 256 would be too high and would cause that sample file to be skipped, thus causing data loss. That would be unacceptable.
299-
Similarly, having feature extraction presets which use a window of 128 or 256 would also be a wrong choice, for the same reason.
300-
In this case, you must therefore suggest presets or transforms having frame/window size <=70.
298+
If for a classification task, the `min_sample_or_seq_length` is 70, then having a frame_size > 70 in the preset or data transform would be too high and would cause that sample file to be skipped, thus causing data loss. **This would be unacceptable.**
299+
You must therefore suggest presets or transforms having frame/window size <=`min_sample_or_seq_length`. #NAME min_sample_or_seq_length could be causing confusion for agent
301300

302-
Also, understand what each recommended transform does - go through `references/FE_and_Data_Processing_Transforms/FE_transforms.md` and `references/Data_processing_transforms.md`. For presets, go through `assets/timeseries_data_proc_feat_ext_consts.md`.
301+
Also, understand what each recommended transform does - go through `references/FE_and_Data_Processing_Transforms/FE_transforms.md` and `references/Data_processing_transforms.md`. For presets, consult `$TINYML_BASE_PATH/tinyml-modelmaker/tinyml_modelmaker/ai_modules/timeseries/constants.py` (source of truth for feature extraction and data processing presets).
303302
Try understanding whether your recommendations actually will be useful for the dataset you are working with and if so, why. **Give CLEAR point-by-point reasoning to the user regarding why your recommended transforms or presets are valid and useful.**
304303

305304
Show user the complete, structured output of `get_data_proc_feat_ext_recommendations` - summarize the same as well while showing it to the user.
@@ -340,16 +339,43 @@ python3 $SCRIPTS_DIR/runner.py select_model_for_task \
340339
"{\"task_type\": \"$TASK_TYPE\", \"target_device\": \"$TARGET_DEVICE\", \"target_module\": \"$TARGET_MODULE\", \"variables\": $VARIABLES, \"dataset_size_bucket\": \"<from Part A>\", \"modelzoo_path\": \"$TINYML_BASE_PATH/tinyml-modelzoo/examples\"}"
341340
```
342341

343-
Show `ranked_matches` to user: model name, param count, complexity tier, score. Ask which model they want to use.
342+
**Part C — fetch & display all available models:**
343+
344+
Fetch all available models filtered by `$TASK_TYPE` and number of input variables (`$VARIABLES`):
345+
```bash
346+
python3 $SCRIPTS_DIR/runner.py list_available_models \
347+
"{\"task_type\": \"$TASK_TYPE\", \"variables\": $VARIABLES, \"modelzoo_path\": \"$TINYML_BASE_PATH/tinyml-modelzoo/tinyml_modelzoo/models/\", \"model_descriptions_path\": \"$TINYML_BASE_PATH/tinyml-modelzoo/tinyml_modelzoo/model_descriptions/\"}"
348+
```
349+
350+
Display results as a **TABLE** with columns:
351+
| Model Name | Param Count | Complexity | Merits | Demerits | Ideal Use Case |
352+
353+
For each model, include:
354+
- **Merits:** Speed, accuracy, memory efficiency, special capabilities (e.g., "Fast inference on NPU", "Best accuracy")
355+
- **Demerits:** Trade-offs (e.g., "Lower accuracy than larger models", "Requires quantization")
356+
- **Ideal Use Case:** When/where to use (e.g., "Tight memory constraints", "Real-time inference requirement")
357+
358+
**Part D — provide your recommendation:**
359+
360+
Based on dataset size, ranked scores, and device constraints, give **CLEAR, POINT-BY-POINT recommendation** format:
361+
362+
"I recommend **[MODEL_NAME]** because:
363+
- Point 1: [reason specific to this dataset size]
364+
- Point 2: [reason specific to this device]
365+
- Point 3: [reason specific to performance needs]
366+
367+
**Alternatives:**
368+
- [ALT_MODEL] if you prioritize [property]
369+
- [ALT_MODEL2] if you need [property]"
370+
371+
Inform user: "You can accept this recommendation or select any model from the table above."
344372

345373
Store user's choice as `MODEL_NAME`.
346374

347375
---
348376

349377
## Step 8: Generate training section
350-
351-
> **MANDATORY: Parts C and D (quantization and NAS) are NOT optional. You MUST ask the user about both — every single time — before generating the training section YAML. Do not skip or defer these questions. The user cannot make informed decisions without being asked.**
352-
378+
**DO NOT SKIP ANY OF THE BELOW PARTS. ENSURE STEP 8 IS FULLY DONE, EVERY PART, EVERY SINGLE TIME**
353379
### Part A — get recommendations
354380

355381
```bash
@@ -370,6 +396,7 @@ Ask:
370396
- Custom learning rate?
371397

372398
Inform the user that all are optional, user can press `Enter` to use system defaults (taken from the corresponding modules' `params.py`).
399+
373400
**HIGHLY IMPORTANT**
374401
For number of GPUs, if user does not specify or does not know, run the following simple python script:
375402
```python
@@ -379,9 +406,9 @@ print(torch.cuda.device_count())
379406
```
380407
Use the result from the above script to set `NUM_GPUS`.
381408

382-
### Part C — **MANDATORY**: ask user about quantization
409+
### Part C — ask user about quantization
383410

384-
**Do not skip this.** Present all three modes clearly, state the recommendation from `quantization.recommended_mode`, and ask the user to choose:
411+
Present all three modes clearly, state the recommendation, and ask the user to choose:
385412

386413
```
387414
Quantization reduces model size and enables hardware acceleration.
@@ -393,83 +420,31 @@ Modes:
393420
394421
The recommendation for YOUR device ($TARGET_DEVICE): mode <quantization.recommended_mode>
395422
Reason: <quantization.reason>
396-
```
397-
398-
Ask in sequence — get a confirmed answer for each before moving on:
399-
1. "Which quantization mode do you want? (0 / 1 / 2)" → store as `QUANTIZATION_MODE`
400-
2. If `QUANTIZATION_MODE > 0`: "QAT (better accuracy, longer training) or PTQ (faster, less accurate)?" → store as `QUANTIZATION_METHOD`
401-
3. If `QUANTIZATION_MODE > 0`: "Bit width for weights? (8 / 4 / 2 — default 8)" → store as `WEIGHT_BITS`
402-
4. If `QUANTIZATION_MODE > 0`: "Bit width for activations? (8 / 4 / 2 — default 8)" → store as `ACTIVATION_BITS`
403-
404-
> Quantization mode will also determine the compilation preset in Step 10 — setting it correctly here matters for end-to-end correctness.
405-
406-
### Part D — **MANDATORY**: ask user about NAS
407-
408-
**Do not skip this.**
409-
410-
**NAS (Neural Architecture Search)** automatically finds an optimal model architecture for your task and device constraints. It replaces the fixed model from ModelZoo with a search process that discovers the best architecture from your data.
411-
412-
When to use NAS:
413-
✓ You don't know what the right model for your use-case looks like
414-
✓ You do not want the previously recommended model from TinyML-ModelZoo
415-
✓ You have GPU access (NAS is impractical without a GPU)
416423
417-
When NOT to use NAS:
418-
✗ No GPU available (each search epoch takes several minutes on CPU)
419-
✗ Tight time constraints
420-
✗ Standard models already work well
421-
422-
Model size presets (controls search space):
423-
s — Small, 3 layers. Fast search (~10-20 min). Good starting point.
424-
m — Medium, 10 layers. Moderate search time. Recommended default.
425-
l — Large, 12 layers. Longer search.
426-
xl — Extra-large, 20 layers. Use when l is insufficient.
427-
xxl — Largest search space. Slowest.
428-
429-
Optimization modes:
430-
Memory — minimize parameter count (flash/RAM footprint on MCU)
431-
Compute — minimize MACs/FLOPs (inference latency)
432-
433-
Present the above to the user, then ask the following **in this exact format**:
434-
1. "Do you want to use NAS? [This will result in rejection of chosen model from ModelZoo]"
435-
2. If yes: "Which model size preset?" (default: 'm')
436-
3. If yes: "Optimization mode — Memory or Compute?" (steer based on device constraints)
437-
4. If yes: "How many NAS search epochs?" (default: 10; more = better but slower)
424+
When you select mode 1 or 2, Automatic Mixed Precision (AMP) is enabled by default:
425+
<autoquant_explanation>
426+
```
438427

439-
Store user responses in `NAS_ENABLED`, `NAS_MODEL_SIZE`, `NAS_OPT_MODE`, `NAS_EPOCHS`.
428+
Ask:
429+
- "Which quantization mode do you want? (0 / 1 / 2)" → store as `QUANTIZATION_MODE`
440430

441-
### Part E — generate YAML
431+
That's it. No need to ask about PTQ/QAT or bit widths — AMP handles per-layer precision automatically.
442432

443-
Minimal (no quantization, no NAS):
444-
```bash
445-
python3 $SCRIPTS_DIR/runner.py generate_training_section_yaml \
446-
"{\"enable\": true, \"model_name\": \"$MODEL_NAME\"}" \
447-
--save-yaml $WORK_DIR/training.yaml
448-
```
449-
450-
With quantization (typical NPU case):
451-
```bash
452-
python3 $SCRIPTS_DIR/runner.py generate_training_section_yaml \
453-
"{\"enable\": true, \"model_name\": \"$MODEL_NAME\", \"quantization\": 2, \"quantization_method\": \"QAT\", \"quantization_weight_bitwidth\": 8, \"quantization_activation_bitwidth\": 8}" \
454-
--save-yaml $WORK_DIR/training.yaml
455-
```
433+
> Quantization mode will also determine the compilation preset in Step 10 — setting it correctly here matters for end-to-end correctness.
456434
457-
With NAS (preset mode):
458-
```bash
459-
python3 $SCRIPTS_DIR/runner.py generate_training_section_yaml \
460-
"{\"enable\": true, \"model_name\": \"$MODEL_NAME\", \"num_gpus\": $NUM_GPUS, \"nas_enabled\": true, \"nas_epochs\": $NAS_EPOCHS, \"nas_optimization_mode\": \"$NAS_OPT_MODE\", \"nas_model_size\": \"$NAS_MODEL_SIZE\"}" \
461-
--save-yaml $WORK_DIR/training.yaml
462-
```
435+
### Part D — generate YAML
463436

464-
With both quantization + NAS:
437+
Since AMP is default and handles bit widths automatically, just specify the quantization mode:
465438
```bash
466439
python3 $SCRIPTS_DIR/runner.py generate_training_section_yaml \
467-
"{\"enable\": true, \"model_name\": \"$MODEL_NAME\", \"num_gpus\": $NUM_GPUS, \"quantization\": $QUANTIZATION_MODE, \"quantization_method\": \"$QUANTIZATION_METHOD\", \"quantization_weight_bitwidth\": $WEIGHT_BITS, \"quantization_activation_bitwidth\": $ACTIVATION_BITS, \"nas_enabled\": true, \"nas_epochs\": $NAS_EPOCHS, \"nas_optimization_mode\": \"$NAS_OPT_MODE\", \"nas_model_size\": \"$NAS_MODEL_SIZE\"}" \
440+
"{\"enable\": true, \"model_name\": \"$MODEL_NAME\", \"quantization\": $QUANTIZATION_MODE}" \
468441
--save-yaml $WORK_DIR/training.yaml
469442
```
470443

471444
Show user the generated YAML so they can confirm the training config before proceeding.
472445

446+
**Note:** If user explicitly wants to disable AMP and use uniform quantization instead, they can set `quantization_method` and bit widths manually, but this is not recommended and rarely needed.
447+
473448
---
474449

475450
## Step 9: Generate testing section
@@ -576,7 +551,7 @@ Then proceed to implement the changes (either the ones you recommended or the on
576551
DO THIS UNTIL TRAINING HAPPENS CLEANLY WITHOUT ISSUE.
577552

578553
**COMMON ISSUES TO LOOK OUT FOR:**
579-
1. Feature Extraction preset failed due to size issues. Dataset's class samples may have too few entries for presets. If no presets can fit it, then think of using raw feature extraction transforms. You can find all transforms in `/home/tushxr16/tinyml-tensorlab-skills/assets/timeseries_data_proc_feat_ext_consts.md`. See if any of them or any combination of them could be of use for your usecase and accordingly select them.
554+
1. Feature Extraction preset failed due to size issues. Dataset's class samples may have too few entries for presets. If no presets can fit it, then think of using raw feature extraction transforms. Consult `$TINYML_BASE_PATH/tinyml-modelmaker/tinyml_modelmaker/ai_modules/timeseries/constants.py` for all available transforms and presets. See if any of them or any combination of them could be of use for your usecase and accordingly select them.
580555

581556
2. Due to the above issue, many times files having less number of samples (less than what the presets may expect) may be skipped. As a result the metrics you get may be skewed and show very high values. Do not get confused and report this to the user as the final metrics. Stop the training, go back to the config, and refer point 1 to fix the issue. Once fixed, then train again.
582557

@@ -609,7 +584,7 @@ Device: $TARGET_DEVICE
609584

610585
**User MUST verify this fits on their device before deployment.**
611586

612-
Get device specs from `assets/deployment_sdk_reference.md` or:
587+
Get device specs from `references/deployment_sdk_reference.md` or:
613588
- C2000 devices: check device datasheet (typically 256KB–1MB FLASH, 32KB–128KB SRAM)
614589
- MSPM0 devices: check SDK documentation
615590
- AM26x: check MCU+ SDK docs
@@ -765,6 +740,7 @@ Connect device via USB/JTAG, then:
765740
python3 $SCRIPTS_DIR/runner.py flash_ccs_project \
766741
"{\"ccs_project_path\": \"$CCS_PROJECT_PATH\", \"ccs_install_path\": \"$CCS_INSTALL_PATH\"}"
767742
```
743+
768744
If fails: flash manually in CCS (**Run → Flash Project**).
769745

770746
**After flashing:** In CCS Debug perspective, set breakpoint after inference, check `test_result == 1` in Watch window (1 = pass, 0 = fail).

skills/tinyml-agentic-skill/assets/model_descriptions/_base.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)