Comments (7)
@AS-researcher6 merged to master. should be correct now. pls verify
from lightning.
All good. Thanks for the fixes!
Working on a SLURM cluster myself so may submit pull requests for expanded Trainer functionality and bring up more things in the future.
from lightning.
@AS-researcher6 good find, i see the bug. the division is done once the step is applied, but the division should be on line 926.
Current order:
- clip
- step
- zero_grad
- divide accumulated loss by nb accumulated batches
Correct order:
- divide accumulated loss by nb accumulated batches
- clip
- step
- zero_grad
Submitting the change.
Mind sanity checking PR #88
from lightning.
Gladly! Not sure if you're done fixing things but I don't see the commit where the loss is divided by self.accumulate_grad_batches before the loss.backward(). Otherwise the original version where self.batch_loss_value += loss.item() is good as long as the self.batch_loss_value is not averaged after.
from lightning.
look at the PR #88
line 928
from lightning.
Sorry, I don't think it's quite right yet. Accounting for multiple batches needs to happen in the actual loss itself before backpropagation. Otherwise, its like N accumulated additions of loss.backward() rather than N accumulated additions of (1/N * loss).backward()
After line 898 and before loss.backward() on the 903 if statement, there needs to be a line that's loss = loss / self.accumulate_grad_batches. Line 922 should still be self.batch_loss_value += loss.item(). Line 928 can be removed entirely, since the averaging has already been accounted for.
from lightning.
@AS-researcher6 i see. updated. Was following the wrong approach before.
How about now?
from lightning.
Related Issues (20)
- Modules with `nn.Parameter` not Converted by Lightning Mixed Precision HOT 2
- No module named 'flash.core' and mentionning packages versions HOT 7
- Expose client argument in `MLFlowLogger` HOT 3
- How to use BackboneFinetuning callback?
- Tensor Disappear.
- Mixing the order of `--config` and `fit` in LightningCLI can cause confusion HOT 7
- Support TorchEval HOT 2
- Extending Argument Linking for more complicate relationship HOT 2
- Training stuck when running on Slurm with multiprocessing HOT 1
- PyTorch Lightning FSDP takes more memory than PyTorch FSDP HOT 5
- Incompatible LightningModule.to_onnx type-hint HOT 1
- LightningCLI, WandbLogger and save_hyperparameters() inconsistencies
- `log_dir` contains both forward and backward slashes as path separator when using remote file location as `default_root_dir` on windows
- ValueError: dictionary update sequence element #0 has length 1; 2 is required
- Expected all tensors to be on the same device... using quantized model with deepspeed zero3
- Huggingface model quantization has odd behavior with BitsandbyesPrecisionPlugin HOT 3
- `TensorBoardLogger` fails with remote FS (azure)
- Pydantic AttributeError when using LightningDataModule
- Loading from a checkpoint does not work properly in distributed training
- Optimizer step based validation trigger HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightning.