examples: the optimizer's momentum quantization template is never freed
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c
- Domain
- documentation
Research direction
Review the listed example files, including examples/kws_tcresnet8/train_c.c as the reference pattern, and check the CreateOptim calls for inline quantizationInitFloat() templates. Keep each template in a local and free it after optimizer creation; run the examples' existing checks if available. Done when all affected examples and the fine-tune example free their templates after creation.
Written by the indexing model from the issue text.
Description
Problem
sgdMCreateOptim / adamWCreateOptim take a momentum quantization template that stays caller-owned (SgdApi.h): the optimizer clones it with getQLike per state during creation and never references it again. Most examples pass quantizationInitFloat() inline, so the template is never freed:
- examples/ecg_anomaly_ae/train_c.c
- examples/kws_mfcc/train_c.c
- examples/kws_raw/train_c.c, examples/kws_raw/trace_c.c
- examples/mixed_width_mlp/train_c.c
- examples/mnist_cnn/train_c.c
- examples/mnist_mlp/train_c.c
- the fine-tune example (
train_c_finetune.c) also never frees its template
(grep for CreateOptim( followed by quantizationInitFloat(); the list may miss multi-line calls.)
Effect
One quantization_t plus its config per optimizer, held until process exit. No effect on training. It makes ODT_MEM_PROFILE heap numbers a few bytes high, and the examples teach a pattern that leaks when an optimizer is created repeatedly (e.g. per person in a fine-tuning loop).
Fix
Keep the template in a local, free it right after the create call (as examples/kws_tcresnet8/train_c.c does). Optionally: document in SgdApi.h / AdamWApi.h that the template may be freed as soon as the create call returns.
- Dominant language
- C
- Stars
- 2
- Forks
- 3
- Avg merge
- 13h 6m
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from es-ude/OnDeviceTraining
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
es-ude/OnDeviceTraining#547 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
es-ude/OnDeviceTraining#536 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
es-ude/OnDeviceTraining#478 ·
Maintainers usually reply within 1 day
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
es-ude/OnDeviceTraining#459 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
es-ude/OnDeviceTraining#258 ·
Maintainers usually reply within 1 day
All issues in es-ude/OnDeviceTraining
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 5 days
-
New firmware
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
MControlSuite/msi-ec#905 ·
-
riscv
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
intel/isa-l_crypto#181 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100