Best Practices - krishanth7/EveryO GitHub Wiki
Write Clearly · Compute Correctly · Validate Thoroughly · Improve Continuously
A practical engineering handbook for building, training, testing, optimizing, and maintaining neural computing applications with EveryO.
Home · Framework Architecture · API Reference · Contributing
Project: EveryO
Maintainer: @krishanth7
Document Type: Engineering recommendations
Important
Scope and Authority
This guide provides recommended engineering practices. It does not replace the repository's official contribution, security, governance, or project policies.
EveryO is an experimental neural computing framework, not a production-scale training runtime. Implemented features should not be assumed to have been validated on every platform, hardware configuration, or workload.
- Overview
- Core Engineering Principles
- Environment Management
- Project Organization
- Tensor Design
- Shape and Dtype Management
- Automatic Differentiation
- Gradient Verification
- Neural Network Architecture
- Parameter Initialization
- Activation Functions
- Loss Functions
- Optimizer Selection
- Training Loop Design
- Data Pipeline Engineering
- Numerical Stability
- Regularization and Generalization
- Model Evaluation
- Reproducibility
- Model Serialization
- CUDA Engineering
- Mixed Precision
- Distributed Training
- ONNX Interoperability
- Performance Optimization
- Testing and Quality Assurance
- Security and Privacy
- Documentation Standards
- Code Review Practices
- Engineering Checklist
- Common Anti-Patterns
- Official References
EveryO is designed to make neural computing understandable through readable implementations of tensor operations, automatic differentiation, neural network modules, optimizers, and training utilities.
The framework is built primarily on NumPy, with optional CUDA acceleration and interoperability features.
EveryO development should prioritize:
- Mathematical correctness.
- Readability.
- Reproducibility.
- Explicit tensor shapes.
- Predictable behavior.
- Reliable testing.
- Responsible resource usage.
- Clear documentation.
DEFINE PROBLEM
|
v
PREPARE DATA
|
v
VALIDATE INPUTS
|
v
BUILD MODEL
|
v
VERIFY FORWARD
|
v
VERIFY GRADIENTS
|
v
TRAIN
|
v
EVALUATE
|
v
SAVE CHECKPOINT
|
v
VERIFY RESTORE
|
v
REPORT RESULTS
Do not optimize an operation until its expected mathematical behavior is established.
Use clear and maintainable code over unnecessary abstraction.
Explicitly verify:
- Tensor dimensions.
- Numerical dtypes.
- Device placement.
- Target formats.
- Gradient behavior.
Keep data processing, model definition, training, and evaluation logically separated.
Every significant defect should have a minimal reproducible example.
Do not claim:
- Perfect accuracy.
- Universal hardware compatibility.
- Guaranteed performance improvements.
- Production readiness without evidence.
git clone https://github.com/krishanth7/EveryO.git
cd EveryO
python -m venv .venvLinux/macOS:
source .venv/bin/activateWindows PowerShell:
.\.venv\Scripts\Activate.ps1python -m pip install -e .python -m pip install -e ".[dev]"python --version
everyo doctorFor reproducible experiments, record the installed dependency versions.
python -m pip freeze > requirements-lock.txtThis creates a snapshot of the current environment; it is not a substitute for a fully validated cross-platform lockfile.
A recommended application structure is:
my-everyo-project/
|
+-- configs/
| +-- experiment.yaml
|
+-- data/
| +-- README.md
|
+-- models/
| +-- network.py
|
+-- training/
| +-- train.py
| +-- evaluate.py
|
+-- tests/
| +-- test_model.py
| +-- test_gradients.py
|
+-- checkpoints/
|
+-- reports/
|
+-- requirements-lock.txt
+-- README.md
This structure is an application-level recommendation, not a required EveryO layout.
Keep experiment settings separate from model implementation.
Use configurable data and output directories.
Store model checkpoints and results under identifiable experiment names.
Record the Git commit associated with each important experiment.
import everyo as eo
x = eo.tensor(
[1.0, 2.0, 3.0],
requires_grad=True,
)A tensor may contain:
- Numerical data.
- Shape information.
- Dtype.
- Device information.
- Gradient-tracking state.
Repeatedly converting between tensor representations and NumPy arrays can add overhead and may interrupt differentiation.
Prefer:
y = x * x
loss = y.sum()
loss.backward()over unnecessarily complex nested expressions.
During debugging, inspect intermediate tensor shapes and values before continuing.
import everyo as eo
x = eo.tensor([
[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0],
])
print(x.shape)Expected shape:
(2, 3)
For:
[ A_{m \times n}B_{n \times p} ]
the result has shape:
[ C_{m \times p} ]
The inner dimensions must match.
Broadcasting should be intentional.
For example:
A: (32, 16)
B: (16,)
Result: (32, 16)
Float32 is commonly suitable for neural network training.
Float64 may be useful for numerical verification.
Float16 requires additional care because of reduced precision and range.
EveryO's convolutional layers use NHWC image layout:
N = Batch
H = Height
W = Width
C = Channels
Do not assume NCHW input compatibility without an explicit conversion.
import everyo as eo
x = eo.tensor([3.0], requires_grad=True)
y = x * x
y.backward()
print(x.grad)Expected gradient:
[6.]
x
|
+-------+
| |
v v
Multiply
|
v
y
|
v
Backward
|
v
Gradient
Do not replace differentiable tensor operations with arbitrary NumPy calculations when gradients must propagate through them.
Clear stored gradients appropriately between independent optimization steps.
When gradients are unnecessary, use EveryO's documented no_grad() context.
import everyo as eo
with eo.no_grad():
output = model(input_tensor)Here, model and input_tensor represent objects already created by the application.
Every new differentiable operation should be checked against a numerical reference.
[ g_{\text{numeric}} = \frac{f(x+h)-f(x-h)}{2h} ]
[ E_{\text{abs}} = |g_{\text{analytic}}-g_{\text{numeric}}| ]
[ E_{\text{rel}} = \frac{ |g_{\text{analytic}}-g_{\text{numeric}}| }{ \max(\epsilon,|g_{\text{analytic}}|,|g_{\text{numeric}}|) } ]
- Test scalar inputs.
- Test vector inputs.
- Test matrix inputs.
- Test broadcasting.
- Test reductions.
- Test non-square shapes.
- Test numerical edge cases.
- Document tolerances.
Finite-difference comparisons near discontinuities or kinks may be misleading.
For example, ReLU is not differentiable at zero in the classical sense.
import everyo as eo
model = eo.Sequential(
eo.Linear(4, 16),
eo.ReLU(),
eo.Linear(16, 2),
)x = eo.tensor([
[1.0, 2.0, 3.0, 4.0],
])
output = model(x)
print(output.shape)Expected shape:
(1, 2)
Recommended progression:
- Linear model.
- Small multilayer network.
- Additional regularization.
- More complex architecture.
- Optional acceleration.
Document the purpose of each layer and the expected input/output shapes.
Poor initialization can contribute to:
- Vanishing gradients.
- Exploding gradients.
- Slow convergence.
- Numerical instability.
| Strategy | Typical Application |
|---|---|
| Xavier/Glorot | Certain symmetric activations |
| He/Kaiming | ReLU-like activations |
| Small random values | Selected experimental settings |
| Zero biases | Common starting choice |
These are general machine learning strategies. Use the initialization mechanisms actually supported by the relevant EveryO module.
Inspect parameter statistics before training when diagnosing convergence problems.
[ ReLU(x)=\max(0,x) ]
Often used in hidden layers.
[ \sigma(x)=\frac{1}{1+e^{-x}} ]
Often used where a bounded output is needed.
[ \tanh(x) ]
Maps inputs to values between -1 and 1.
[ softmax(x_i)= \frac{e^{x_i}}{\sum_j e^{x_j}} ]
Produces normalized probabilities.
Choose activations according to:
- Model architecture.
- Loss function.
- Gradient behavior.
- Numerical stability.
Avoid applying softmax before a cross-entropy implementation that expects raw logits.
| Task | Common Choice |
|---|---|
| Regression | MSE |
| Absolute-error regression | MAE |
| Multiclass classification | Cross-entropy |
| Binary classification | BCE or BCE with logits |
Model outputs and targets must follow the selected loss function's contract.
Do not add an activation that duplicates normalization already performed internally by a loss function.
Large or non-finite losses may indicate:
- Incorrect labels.
- Invalid input values.
- Excessive learning rate.
- Numerical instability.
EveryO implements optimization algorithms including SGD and Adam.
A basic update is:
\theta_t-\eta\nabla L(\theta_t) ]
Adam uses adaptive first- and second-moment estimates.
import everyo as eo
optimizer = eo.Adam(
model.parameters(),
lr=0.001,
)- Start with a documented baseline.
- Tune one hyperparameter at a time.
- Record learning rates.
- Monitor gradient magnitude.
- Compare convergence across repeated runs.
An excessively large learning rate may cause divergence.
An excessively small learning rate may make progress difficult to observe.
LOAD BATCH
|
v
FORWARD PASS
|
v
COMPUTE LOSS
|
v
CLEAR GRADIENTS
|
v
BACKWARD PASS
|
v
OPTIMIZER STEP
|
v
RECORD METRICS
EveryO provides a Trainer abstraction for supported training workflows.
Example:
import everyo as eo
trainer = eo.Trainer(
model,
eo.Adam(model.parameters(), lr=0.001),
eo.CrossEntropyLoss(),
metrics=["accuracy"],
)
history = trainer.fit(
train_loader,
epochs=10,
validation_loader=validation_loader,
)The loaders must be configured with data compatible with the model and loss.
- Validate data before training.
- Record training and validation metrics.
- Use appropriate batch sizes.
- Monitor for non-finite losses.
- Evaluate with gradients disabled when appropriate.
- Save checkpoints at meaningful stages.
Check:
- Missing values.
- Non-finite values.
- Incorrect labels.
- Inconsistent feature dimensions.
- Unexpected data types.
Do not fit preprocessing transformations on test data.
Typical datasets include:
- Training.
- Validation.
- Testing.
Document normalization and feature engineering steps.
When shuffling or batching data, ensure features and targets remain paired.
Floating-point arithmetic is approximate.
For example:
[ (a+b)+c ]
may not produce exactly the same floating-point result as:
[ a+(b+c) ]
Prefer numerically stable implementations for:
- Softmax.
- Logarithms.
- Division.
- Normalization.
- Exponential operations.
Investigate:
- NaN.
- Positive infinity.
- Negative infinity.
Use higher precision when necessary for numerical testing.
Increasing tolerances to make tests pass can conceal real defects.
Dropout can help reduce overfitting in suitable architectures.
Stop training when a monitored validation metric no longer improves according to the selected criterion.
Avoid unnecessarily large models for small datasets.
Compare training and validation behavior.
| Observation | Possible Interpretation |
|---|---|
| High training and validation loss | Underfitting or optimization issue |
| Low training loss, high validation loss | Possible overfitting |
| Both losses decreasing | Training progress |
| Loss becomes non-finite | Numerical or optimization problem |
These interpretations are diagnostic clues, not definitive diagnoses.
| Task | Common Metrics |
|---|---|
| Classification | Accuracy, precision, recall |
| Regression | MAE, MSE |
| Probabilistic prediction | Calibration and log loss |
| Sequence modeling | Task-specific metrics |
Metric availability should be verified against EveryO's documented API.
Avoid repeatedly tuning against the final test set.
For stochastic experiments, consider multiple random seeds.
Include:
- Dataset.
- Preprocessing.
- Model configuration.
- Optimizer.
- Learning rate.
- Number of epochs.
- Random seed.
- Hardware.
Use controlled seeds where supported.
python -m pip freeze > requirements-lock.txtgit rev-parse HEADRecommended record:
experiment:
name: baseline-classifier
framework: everyo
framework_version: "0.2.0"
training:
epochs: 10
batch_size: 32
learning_rate: 0.001
evaluation:
metric: accuracy
environment:
device: cpuThis YAML is a suggested record format, not a required EveryO configuration schema.
Different hardware, dependency versions, and floating-point execution orders may produce small numerical differences.
import everyo as eo
eo.save(model, "model.evo")restored_model = eo.load("model.evo")Compare predictions from the original and restored models on the same input.
Record:
- Framework version.
- Model architecture.
- Training configuration.
- Dataset information.
- Evaluation results.
EveryO's .evo format uses a pickle-free archive design.
Nevertheless, untrusted archives can still be malformed or resource-intensive.
Follow the documented module registration process when serializing supported custom module types.
EveryO should remain usable without NVIDIA hardware.
import everyo as eo
print(eo.cuda.is_available())
print(eo.cuda.unavailable_reason())For small operations, transfer overhead may exceed computation time.
The documented GPU-resident tensor path supports selected operations and is intended for inference.
Do not assume GPU-resident operations automatically participate in EveryO's autograd graph.
A successful native build does not prove GPU runtime correctness.
Compare equivalent workloads and record device specifications.
Float16 reduces storage requirements but has a smaller numerical range than float32.
Small gradients may underflow.
EveryO provides mixed-precision utilities including GradScaler.
Use a float32 baseline to evaluate numerical differences.
Mixed precision is not guaranteed to improve performance on CPU.
Verify model behavior before adding distributed execution.
Confirm that distributed gradients and parameter updates behave as expected.
Record:
- World size.
- Process ranks.
- Communication configuration.
- Hardware.
- Network assumptions.
EveryO's documented TCP process-group implementation assumes a trusted network and does not provide transport encryption.
Do not treat same-host multi-process tests as proof of reliable multi-machine operation.
python -m pip install -e ".[onnx]"import everyo as eo
model = eo.Sequential(
eo.Linear(4, 8),
eo.ReLU(),
eo.Linear(8, 2),
)
model.eval()
eo.export_onnx(
model,
"model.onnx",
input_shape=(1, 4),
)Execute the ONNX model using ONNX Runtime and compare results with EveryO.
A traced graph captures an executed path.
Sequence lengths, shapes, and control flow may not generalize beyond the traced example.
Record:
- Export method.
- Input shape.
- Supported operations.
- ONNX version.
- Runtime version.
- Numerical differences.
Avoid optimization based solely on assumptions.
Potential bottlenecks include:
- Matrix multiplication.
- Convolution.
- Python loops.
- Data preprocessing.
- Memory allocation.
- Host-device transfers.
Example:
python benchmarks/benchmark_matmul.py --sizes 128 512 1024 2048Framework version:
Python version:
NumPy version:
CPU:
GPU:
RAM:
Operating system:
Input shape:
Dtype:
Warm-up iterations:
Measured iterations:
Median latency:
Peak memory:
Do not compare implementations using different shapes, precision, or hardware and present the result as a direct speed comparison.
Every optimization should be accompanied by relevant regression tests.
python -m pytest -qpython -m pytest --cov=everyoruff check .ruff format --check .Include:
- Forward correctness.
- Backward correctness.
- Shape handling.
- Dtype behavior.
- Error handling.
- Edge cases.
Clearly distinguish:
- Tests passed.
- Tests failed.
- Tests skipped.
Every reproducible defect should ideally receive a test that detects recurrence.
Never commit:
- API keys.
- Passwords.
- Private tokens.
- Authentication credentials.
Check untrusted files and external data before processing.
Evaluate dependency updates for compatibility and known vulnerabilities.
CUDA and C++ extensions require additional memory-safety review.
Use:
GitHub Private Vulnerability Reporting
EveryO should not be treated as a certified system for high-risk medical, financial, or safety-critical decisions.
Documentation should explain:
- Purpose.
- Requirements.
- Inputs.
- Outputs.
- Limitations.
- Examples.
Avoid invented APIs or unsupported parameters.
For neural network examples, include expected tensor dimensions.
State precision, tolerance, and expected behavior where relevant.
Code changes affecting public behavior should be accompanied by documentation changes.
Verify that the implementation satisfies its intended behavior.
Check gradients, precision, and edge cases.
Consider supported Python versions and optional dependencies.
Identify new input, network, or native-code risks.
Prefer understandable code with focused responsibilities.
Ensure examples and explanations reflect actual implementation.
Pull request acceptance remains subject to maintainer review.
- Define the problem.
- Confirm required functionality exists.
- Review relevant documentation.
- Identify compatibility constraints.
- Create a reproducible baseline.
- Validate tensor shapes.
- Use appropriate dtypes.
- Preserve gradient tracking.
- Test numerical behavior.
- Avoid unnecessary complexity.
- Document important assumptions.
- Validate input data.
- Confirm target formats.
- Test the forward pass.
- Check loss behavior.
- Verify gradients.
- Record hyperparameters.
- Evaluate on held-out data.
- Record software versions.
- Record hardware.
- Verify saved models.
- Report limitations.
- Avoid unsupported performance claims.
- Run relevant tests.
- Run linting.
- Run formatting checks.
- Update documentation.
- Review security implications.
- Explain the change clearly.
| Anti-Pattern | Why It Is Problematic | Recommended Alternative |
|---|---|---|
| Ignoring tensor shapes | Causes runtime failures | Validate shapes explicitly |
| Using arbitrary learning rates | Can cause divergence | Start with a baseline and tune |
| Skipping gradient tests | Conceals mathematical defects | Use finite differences |
| Training without validation | Obscures generalization | Use held-out validation data |
| Repeated CPU/GPU transfers | Adds overhead | Measure and minimize transfers |
| Assuming CUDA is faster | May produce misleading expectations | Benchmark on real hardware |
| Exporting without validation | Can conceal ONNX differences | Compare runtime outputs |
| Loading unknown archives blindly | Introduces security risks | Validate and restrict inputs |
| Ignoring test skips | Overstates coverage | Report skips explicitly |
| Claiming perfect accuracy | Misrepresents uncertainty | Report measured results |
| Large unreviewed changes | Increases maintenance risk | Submit focused changes |
| Missing experiment metadata | Reduces reproducibility | Record versions and configuration |
| Resource | Link |
|---|---|
| EveryO Repository | GitHub |
| README | README.md |
| Architecture | Architecture Documentation |
| API Reference | API Documentation |
| Automatic Differentiation | Autograd Documentation |
| CUDA | CUDA Documentation |
| Scaling | Scaling Documentation |
| Testing | GitHub Actions |
| Contributing | CONTRIBUTING.md |
| Security | SECURITY.md |
| Support | SUPPORT.md |
| Governance | GOVERNANCE.md |
| NumPy | numpy.org |
| Python | python.org |
| ONNX | onnx.ai |
Next Recommended Page: Benchmarking Guide →
Home · API Reference · Testing and Quality Assurance
EveryO — Open Machine Learning. Built for Developers.
Project Maintainer: @krishanth7
Open Source · MIT Licensed · Community Driven
© 2026 EveryO Contributors