Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
cd3d80f
Initialize branch
Radonirinaunimi Nov 16, 2020
9f1fd7c
Assign new version
Radonirinaunimi Nov 16, 2020
1154963
Fetch both prior and enhanced (if it exists) sets
Radonirinaunimi Nov 16, 2020
c382c14
Minimize the compression of any given sets w.r.t. prior
Radonirinaunimi Nov 16, 2020
c59a13c
Fixed test accordingly
Radonirinaunimi Nov 16, 2020
65b737b
Tag new version
Radonirinaunimi Nov 17, 2020
75e27a6
Fix slight ambiguity in the computation of the mutation matrix
Radonirinaunimi Nov 17, 2020
14d8493
Update Miniconda
Radonirinaunimi Nov 17, 2020
94072d4
Initialize Random Number Generator
Radonirinaunimi Nov 17, 2020
cdefb71
Initialize primary index to be random
Radonirinaunimi Nov 17, 2020
a19cb81
Use RDG to compute random trials
Radonirinaunimi Nov 17, 2020
54f887f
Turn off enhancement
Radonirinaunimi Nov 17, 2020
53adca0
Fix conflicts when fixing the ambiguities
Radonirinaunimi Nov 17, 2020
2055f19
Initialize branch
Radonirinaunimi Nov 16, 2020
586f0ad
Init. Random Number Generator (RDG)
Radonirinaunimi Nov 17, 2020
d7f06b8
Propagate RDG into the compressor class
Radonirinaunimi Nov 17, 2020
c08bd9b
Fixed test accordingly
Radonirinaunimi Nov 16, 2020
e9de10e
Resolve conflicts
Radonirinaunimi Nov 17, 2020
7931ded
Fix random sampling to take into account all the members from the enh…
Radonirinaunimi Nov 17, 2020
9ef2cab
Fix version
Radonirinaunimi Nov 17, 2020
4152178
Add some study plots for wiki
Radonirinaunimi Nov 18, 2020
e0b2360
Change ugly plot
Radonirinaunimi Nov 18, 2020
ec5e48e
Silent mode
Radonirinaunimi Nov 18, 2020
eea5855
Hold commit
Radonirinaunimi Nov 20, 2020
7f135fd
Add various functions for adiabatic minimization
Radonirinaunimi Dec 10, 2020
94a28f4
Set initial index to be the result of the prior when compressing from…
Radonirinaunimi Dec 10, 2020
68b1c30
Reflect change for adiabatic minimization
Radonirinaunimi Dec 10, 2020
ad6dfaf
Take account compression from enhanced
Radonirinaunimi Dec 10, 2020
1bc3d39
Fix exception
Radonirinaunimi Dec 11, 2020
fb91366
Change name when compressing from enhanced and init restriction on es…
Radonirinaunimi Dec 11, 2020
a3ba74f
Propagate adiabatic change
Radonirinaunimi Dec 11, 2020
bced995
Impose restrictions
Radonirinaunimi Dec 14, 2020
7c0129e
Hold commit
Radonirinaunimi Dec 18, 2020
4734e6a
Hold commit 2
Radonirinaunimi Dec 19, 2020
d98cc06
Formaize a looser adiabatic Minimization
Radonirinaunimi Dec 29, 2020
a1921a6
Script to compare standard & enhanced compressor using FIDs
Radonirinaunimi Dec 29, 2020
44aef23
Script to plot correlations
Radonirinaunimi Dec 29, 2020
c14125a
Improve some parts & add new tests
Radonirinaunimi Dec 30, 2020
191a900
Add KL test on distributions along x
Radonirinaunimi Dec 31, 2020
e2ad5bf
Remove filter
Radonirinaunimi Jan 5, 2021
f8ef422
Clean up a bit
Radonirinaunimi Jan 5, 2021
56a5038
Add log output
Radonirinaunimi Jan 5, 2021
c6f7cda
Fix slight typo within numba env
Radonirinaunimi Jan 5, 2021
1a8c2db
Add ganpdfs runcard
Radonirinaunimi Jan 5, 2021
09f0c58
Script to compare FIDs
Radonirinaunimi Jan 11, 2021
f783351
Fixing a few ambiguities ins definitions
Radonirinaunimi Jan 11, 2021
0c3bbbc
clean up
Radonirinaunimi Jan 11, 2021
950b23d
Fix minor bugs in defining size
Radonirinaunimi Jan 14, 2021
3093c2a
Add rich as a required dependency
Radonirinaunimi Jan 14, 2021
0578011
Replace log output with rich
Radonirinaunimi Jan 14, 2021
fd77a8a
Update log output handler
Radonirinaunimi Jan 14, 2021
a358989
Change splash
Radonirinaunimi Jan 15, 2021
f35b81e
Remove unneeded folder and fix some ambiguities
Radonirinaunimi Jan 19, 2021
25382ce
Add warning for CMA as it does not support adiabatic minimization
Radonirinaunimi Jan 19, 2021
a961013
Change instructions in readme.
Radonirinaunimi Jan 20, 2021
1bdc48f
Fix tests
Radonirinaunimi Jan 20, 2021
c67b84c
Trigger tests & Upload coverages
Radonirinaunimi Jan 20, 2021
0820f9f
Merge branch 'GansCompressor' of github.com:N3PDF/pycompressor into G…
Radonirinaunimi Jan 20, 2021
5cda861
Fall back to pytest only, not pytest-cov
Radonirinaunimi Jan 20, 2021
63f54e6
Try again with new tokens
Radonirinaunimi Jan 20, 2021
d1dfaf5
Reverting stupid mistakes and add dependencies
Radonirinaunimi Jan 20, 2021
b8c96df
Remove white space
Radonirinaunimi Jan 23, 2021
423be46
Move tools scripts that installs when installing the package
Radonirinaunimi Jan 23, 2021
1173c93
Reconstruct the way the scripts are installed
Radonirinaunimi Jan 23, 2021
4b846fa
Update ganpdfs run card according to updates
Radonirinaunimi Jan 23, 2021
4232447
Update information on running using scripts
Radonirinaunimi Jan 23, 2021
c784e87
Adding missing parameter from gans
Radonirinaunimi Jan 24, 2021
96ac095
Set default runcard
Radonirinaunimi Jan 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,files,footer"
behavior: default
require_changes: no

14 changes: 11 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test the modules
# Test modules

name: pytest

Expand All @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Setup Conda
uses: goanpeca/setup-miniconda@v1
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
auto-update-conda: true
Expand Down Expand Up @@ -48,4 +48,12 @@ jobs:
shell: bash --login {0}
run: |
pip install .[tests]
pytest
pytest -v tests/ --cov=./src/pycompressor --cov-report=xml
- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.PYCOMP_COV }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
84 changes: 14 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,119 +2,63 @@
[![documentation](https://github.com/N3PDF/pycompressor/workflows/docs/badge.svg)](https://n3pdf.github.io/pycompressor/)

### pycompressor
----------------

Fast python implementation of PDF set **compressor** (https://arxiv.org/abs/1504.06469). A detailed
documentation will be (slowly) added to https://n3pdf.github.io/pycompressor/. For benchmarks,
have a look at this [folder](https://github.com/N3PDF/pycompressor/tree/GANsInterface/doc/source/img-src).

Fast and efficient python implementation of PDF set **compressor** (https://arxiv.org/abs/1504.06469).

#### New features

Additional new features have been added to the following python package. The two main features
are:
Additional new features have been added to the following python package. The two main features are:
- **Covariance Matrix Adaptation-Evlotion strategy (CMA-ES):** in addition to the Genetic
Algorithm (GA), there is now the possibility to choose as a minimizer the CMA. The choice
of minimizer can be defined in the `runcard.yml` file.
```yaml
minimizer : genetic # Or "cma"
```
- **Generative Adversarial Strategy (GANs):** this is a standalone python [package](https://github.com/N3PDF/ganpdfs/tree/master)
that can enhance the statistics of the prior PDF replicas before compression by generating
synthetic replicas. For more details, refer to the [documentation](https://n3pdf.github.io/ganpdfs/)
(still has to be done). In a similar way, in order to trigger the enhancement, one just has to set
the value of `enhance` in the runcard to be `True`. Setting this value to `False` will just run the
regular compression. The GANs also requires extra-parameters (as shown in the example
standard compression. The GANs also requires extra-parameters (as shown in the example
[runcard.yml](https://github.com/N3PDF/pycompressor/blob/master/runcard.yml)) that defines
the structure of the networks.
```yaml
enhance : True
```
Below is shown a caricatural picture of the pycompressor workflow.
<p align="center">
<img alt="diagram" src="https://github.com/N3PDF/pycompressor/blob/GANsInterface/doc/source/img-src/diagram.png" width=800>
</p>


#### Installation

To install pyCompressor, just type:
To install `pyCompressor`, just type:
```bash
python setup.py install
```
or if you are a developer:
```bash
python setup.py develop
```
The package can aslo be installed via the Python Package Index (PyPI) by running
```bash
pip install pycompressor --upgrade
```

#### How to use

The input parameters that define the compression is contained in a YAML file. To run
the `pycompressor` code, just type the following:
```bash
pycompressor runcard.yml
```
If `enhance` is turned `True`, the code will generate a folder that has the following
structure,
```bash
<PDF_NAME>_enhanced
├── checkpoint
│   ├── checkpoint
│   ├── ckpt-1.data-00000-of-00001
│   └── ckpt-1.index
│   └── ...
├── compress_<PDF_NAME>_enhanced_<NB_COMPRESSED_REPLICAS>_output.dat
├── filter.yml
├── input-runcard.json
├── iterations
│   └── pdf_generated_at_<ITERATION>.png
├── losses_info.json
└── nnfit
├── <PDF_NAME>_enhanced.info
├── replica_<REPLICA_INDEX>
│   ├── <PDF_NAME>_enhanced.dat
│   └── <PDF_NAME>.exportgrid
└── ...
pycomp runcard.yml
```
where:
- `checkpoint`: store the evolution of the GANs training. In case a long runnning training
is interupted, the last checkpoint can be restored and the training can re-start from there.
- `nnfit`: contains (i) the output grids (`exportgrid`) from the GANs-generated replicas.
This is in the same format as the N3FIT-grid in order to take advantage of the [evolven3fit](https://github.com/NNPDF/nnpdf/blob/master/n3fit/evolven3fit/evolven3fit.cc) to evolve the grids; (ii) the `.dat` files that contain the evolved
LHAPDF-like grid from `evolven3fit`. Then, the [postgans](https://github.com/N3PDF/ganpdfs/tree/GANsInterface/src/pycompressor/postgans.py)
module creates a symbolic link between the `.dat` files and the files that are put in
the LHAPDF data directory. The compressor then uses that PDF to be the prior.
- `compress_<PDF_NAME>_enhanced_<NB_COMPRESSED_REPLICAS>_output.dat`: contains the index of
replicas that are retained from the compressor.

If on the other hand `enhance` is set to `False`, the above steps will be skipped and chooses
the input PDF as the prior. This will then generate a `compress_<PDF_NAME>_<NB_COMPRESSED_REPLICAS>_output.dat`
file that is located in the same parent directory as above.
A detailed instruction on how to set the different parameters in the runcard can be found here.

#### Generating compressed PDF set & post-analysis

The code will create a folder named after the prior PDF sets. To generate the
compressed PDF grid, run the following command:
```bash
./tools/compressed_grid.py <PDF_NAME>(_enhanced)/compressed_<PDF_NAME>(_enhanced)_<NB_COMPRESSED>_output.dat
get-grid <PDF_NAME>/compressed_<PDF_NAME>_<NB_COMPRESSED>_output.dat
```
This will generate a folder `<PDF_NAME>(_enhanced)/compressed_<PDF_NAME>(_enhanced)_<NB_COMPRESSED>`
containing the compressed PDF replicas.
This will generate a folder `<PDF_NAME>/compressed_<PDF_NAME>_<NB_COMPRESSED>`
containing the compressed PDF replicas. Note that if the compression is done from an enhanced set,
the output folder will be append by `_enhanced`.

Finally, in order to generate ERF plots, enter in the `erfs_output` directory and run the following:
```bash
../tools/pycompressor_validate.py --random erf_randomized.dat --reduced erf_reduced.dat
validate --random erf_randomized.dat --reduced erf_reduced.dat
```
This script can also plot the ERF validation from the old compressor code by adding the flag
`--format ccomp`.

#### Bottlenecks
#### Warning

The following bottleneck(s) would be solved once everything is put in place.
- For the time being, the `filter.yml` that is required by `evolven3fit` has to be manually
put in place in the main directory. A systematic way of dealing with this will be put
in place once we know where everything goes.
This package cannot be installed with python 3.9 yet due to the numba dependency. This will be resolved
soon according to [#6579](https://github.com/numba/numba/pull/6579).
181 changes: 0 additions & 181 deletions filter.yml

This file was deleted.

Loading