|
3 | 3 | ========================== |
4 | 4 | How to run a QED fit |
5 | 5 | ========================== |
| 6 | +This tutorial describes how to run a QED fit using the LuxQED approach, as |
| 7 | +described in `arXiv:1607.04266 <https://arxiv.org/abs/1607.04266>`_ and |
| 8 | +`arXiv:1708.01256 <https://arxiv.org/abs/1708.01256>`_. |
6 | 9 |
|
7 | | -It is possible to perform a QED fit adding the key ``fiatlux`` to the runcard. In this way |
8 | | -a photon PDF will be generated using the FiatLux public library that implements the LuxQED |
9 | | -(see :cite:p:`Manohar:2016nzj` and :cite:p:`Manohar:2017eqh`) approach. |
10 | | -The parameters to be added are the following: |
| 10 | +Setting up the runcard |
| 11 | +---------------------- |
| 12 | + |
| 13 | +It is possible to perform a QED fit by adding a ``fiatlux`` block to the |
| 14 | +runcard. The following code snippet shows all the available options to set up |
| 15 | +a QED fit: |
11 | 16 |
|
12 | 17 | .. code-block:: yaml |
13 | 18 |
|
14 | 19 | fiatlux: |
15 | | - luxset: NNPDF40_nnlo_as_01180 |
| 20 | + luxset: NNPDF40_nnlo_as_01180_qcd |
16 | 21 | additional_errors: true |
17 | 22 | luxseed: 1234567890 |
| 23 | + compute_in_setupfit: false |
| 24 | + eps_base: 1e-5 |
| 25 | +
|
| 26 | +The parameters contained in the ``fiatlux`` block are: |
| 27 | + |
| 28 | +* ``luxset`` |
| 29 | + The name of the PDF set used to generate the photon PDF with `FiatLux |
| 30 | + <https://github.com/scarrazza/fiatlux/>`_. The code will use as many |
| 31 | + photon replicas as the number of replicas contained in the ``luxset``. If |
| 32 | + the user tries to generate a replica with ID higher than the maximum ID of |
| 33 | + the ``luxset``, the code will start reusing photon replica from the first |
| 34 | + replica. Being the LuxQED approach an iterated procedure, and that some |
| 35 | + replicas do not pass the ``postfit`` selection criteria, the user should |
| 36 | + make sure that the number of replicas in the ``luxset`` is high enough |
| 37 | + such that in the final iteration there will be a number of replicas higher |
| 38 | + than the final replicas desired. |
| 39 | + |
| 40 | +* ``additional_errors`` |
| 41 | + Boolean flag to switch on and off the additional errors of the LuxQED approach. |
| 42 | + |
| 43 | + .. note:: |
| 44 | + |
| 45 | + The ``additional_errors`` flag should be switched on only in the very last |
| 46 | + iteration of the procedure. |
| 47 | + |
| 48 | +* ``luxseed`` |
| 49 | + The seed used to generate the additional errors of the LuxQED as in ``additional_errors``. |
| 50 | + |
| 51 | +* ``compute_in_setupfit`` |
| 52 | + Boolean flag to trigger the computation of the photon PDF set during |
| 53 | + ``vp-setupfit``. By default, it is set to `false`. This is not required if |
| 54 | + the photon PDF set is already available locally or on the NNPDF server. |
| 55 | + See the :ref:`section below <running-with-photon-sets>` for more details. |
| 56 | + |
| 57 | +* ``eps_base`` |
| 58 | + (optional) The base precision of the FiatLux computation, which controls |
| 59 | + the precision on final integration of double integral. By default, it is |
| 60 | + set to ``1e-5``. This parameter is used only if the photon PDF set is |
| 61 | + generated on the fly, either during ``vp-setupfit`` or ``n3fit``. See |
| 62 | + :ref:`Generating new Photon sets <generating-photon-sets>` for more |
| 63 | + details. |
| 64 | + |
| 65 | +The code uses information contained in both the ``fiatlux`` block and the |
| 66 | +``theoryid`` specified in the runcard to identify the photon PDF set, which will |
| 67 | +be assigned the name ``photon_theoryID_<theoryid>_fit_<luxset>``. This name will |
| 68 | +be used to either look for existing photon PDF sets or to store newly generated |
| 69 | +ones, as explained below. |
| 70 | + |
| 71 | +.. _running-with-photon-sets: |
18 | 72 |
|
19 | | -``luxset`` is the PDF set used to generate the photon PDF with `FiatLux <https://github.com/scarrazza/fiatlux/>`. |
20 | | -The code will generate as many photon replicas as the number of replicas contained in the ``luxset``. Therefore, if the user |
21 | | -tries to generate a replica with ID higher than the maximum ID of the ``luxset``, the code will |
22 | | -raise an error. Moreover, being the LuxQED approach an iterated prcedure, and given that some replicas |
23 | | -do not pass the ``postfit`` selection criteria, the user should make sure that the number of replicas in |
24 | | -the ``luxset`` is high enough such that in the final iteration there will be a number of replicas |
25 | | -higher than the final replicas desired. |
26 | | -``additional_errors`` is a parameter that switches on and off the additional errors of the LuxQED approach, |
27 | | -while ``luxseed`` is the seed used to generate such errors. |
28 | | -This errors should be switched on only in the very last iteration of the procedure. |
| 73 | +Running with Photon PDF sets |
| 74 | +----------------------------- |
29 | 75 |
|
30 | | -Whenever the photon PDF is generated, it will remain constant during the fit and will be considered in the momentum sum rule. |
| 76 | +The generation of a photon PDF set can add significant overhead to the fitting |
| 77 | +procedure. Moreover, the same photon PDF set might be used in different fits. To |
| 78 | +minimize the overhead due to the generation of photon PDF sets and avoid |
| 79 | +redundant computations, the code looks for precomputed photon resources either |
| 80 | +locally or on the NNPDF server. If a desired photon PDF set does not exist in |
| 81 | +either of the two locations, it will be computed on the fly and stored locally. |
| 82 | +If the user is satisfied with the new local photon PDF set, they can upload it to |
| 83 | +the NNPDF server following the instructions in :ref:`this section <generating-photon-sets>`. |
| 84 | +The following sections describe how to use existing photon PDF sets or generate |
| 85 | +new ones. |
| 86 | + |
| 87 | +Using available Photon PDF sets |
| 88 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 89 | +Before running a QED fit, it is strongly advised to prepare the fit using |
| 90 | +``vp-setupfit``, as explained in :ref:`this tutorial <run-n3fit-fit>`. This will |
| 91 | +ensure that all the required resources are available, including the photon PDF. |
| 92 | +The desired photon PDF is specified by the ``luxset`` parameter in the |
| 93 | +``fiatlux`` block and the ``theoryid``, as explained above. The code will first |
| 94 | +look for the photon PDF set in the local directory specified in the |
| 95 | +:ref:`profile file <nnprofile>`. If the set is not found locally, it will try to |
| 96 | +download it from the NNPDF server. If the photon PDF set is not found on the |
| 97 | +server either, and the user has not requested to compute it during |
| 98 | +``vp-setupfit`` through the flag ``compute_in_setupfit``, the photon replica |
| 99 | +will be computed as needed for the replica fitted during the execution of |
| 100 | +``n3fit`` (see :ref:`here <photon_n3fit>` for more details). |
| 101 | + |
| 102 | +The following is an example of running ``vp-setupfit`` using the |
| 103 | +``fiatlux`` block shown above and setting ``compute_in_setupfit: false``: |
| 104 | + |
| 105 | +.. code-block:: bash |
| 106 | +
|
| 107 | + $ vp-setupfit qed_example_runcard.yml |
| 108 | + [INFO]: Could not find a resource (photonQED): Could not find Photon QED set /user/envs/nnpdf/share/NNPDF/photons_qed/photon_theoryID_40000100_fit_NNPDF40_nnlo_as_01180_qed in theory: 40000100. Attempting to download it. |
| 109 | + [INFO]: Downloading https://data.nnpdf.science/photons/photon_theoryID_40000100_fit_NNPDF40_nnlo_as_01180_qed.tar. |
| 110 | + [==================================================] (100%) |
| 111 | + [INFO]: Extracting archive to /opt/homebrew/Caskroom/miniconda/base/envs/nnpdf/share/NNPDF/photons_qed |
| 112 | + [INFO]: Photon QED set found for 40000100 with luxset NNPDF40_nnlo_as_01180_qed. |
| 113 | + [WARNING]: Using q2min from runcard |
| 114 | + [WARNING]: Using w2min from runcard |
| 115 | + Using Keras backend |
| 116 | + [INFO]: All requirements processed and checked successfully. Executing actions. |
| 117 | + ... |
| 118 | +
|
| 119 | +In this case, the desired photon PDF set was already stored and precomputed on |
| 120 | +the server. This is downloaded and extracted in the local |
| 121 | +``photons_qed_path`` specified in the :ref:`profile file <nnprofile>`. |
| 122 | + |
| 123 | +The ``vp-list`` utility tool can be used to list all the available photon PDF |
| 124 | +sets locally and on the NNPDF server. To list the available photon PDF sets, |
| 125 | +just run `vp-list photons` to see which photon PDF sets are available locally |
| 126 | +and which ones can be downloaded from the server. The user can manually download |
| 127 | +a photon PDF set using the ``vp-get`` tool as explained :ref:`here <download>`. |
| 128 | +For example: |
| 129 | + |
| 130 | +.. code-block:: bash |
| 131 | +
|
| 132 | + $ vp-get photonQED 40000100 NNPDF40_nnlo_as_01180_qed |
| 133 | + [INFO]: Could not find a resource (photonQED): Could not find Photon QED set /user/envs/nnpdf/share/NNPDF/photons_qed/photon_theoryID_40000100_fit_NNPDF40_nnlo_as_01180_qed in theory: 40000100. Attempting to download it. |
| 134 | + [INFO]: Downloading https://data.nnpdf.science/photons/photon_theoryID_40000100_fit_NNPDF40_nnlo_as_01180_qed.tar. |
| 135 | + [==================================================] (100%) |
| 136 | + [INFO]: Extracting archive to /user/envs/nnpdf/share/NNPDF/photons_qed |
| 137 | + PosixPath('/user/envs/nnpdf/share/NNPDF/photons_qed/photon_theoryID_40000100_fit_NNPDF40_nnlo_as_01180_qed') |
| 138 | +
|
| 139 | +As in the case of ``vp-setupfit``, this will download and extract the photon PDF |
| 140 | +set in the local ``photons_qed_path`` specified in the :ref:`profile file <nnprofile>`. |
| 141 | +Once the photon PDF set is available locally, the user can proceed to run the |
| 142 | +fit with ``n3fit`` as usual. |
31 | 143 |
|
32 | 144 | .. warning:: |
33 | 145 |
|
34 | | - At the moment it is not possible to run QED fits in parallel, as the FiatLux library cannot run in parallel. |
| 146 | + If ``vp-setupfit`` is not run before ``n3fit``, and the photon PDF set is not |
| 147 | + available locally, the code will **not** attempt to download it from the server, |
| 148 | + but will directly proceed to compute it on the fly. See the :ref:`next section <generating-photon-sets>` for |
| 149 | + more details. |
| 150 | + |
| 151 | +.. _generating-photon-sets: |
| 152 | + |
| 153 | +Generating new Photon PDF sets |
| 154 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 155 | +If the desired photon PDF set is not available locally nor on the NNPDF server, the |
| 156 | +code will generate the required photon PDF set replicas on the fly using `FiatLux <https://github.com/scarrazza/fiatlux/>`_. |
| 157 | +This can be done either during the ``vp-setupfit`` step, which precomputes all photon |
| 158 | +replicas before starting the fit, or during the fitting step with ``n3fit``, which |
| 159 | +generates the photon replica as needed for each replica being fitted. |
| 160 | + |
| 161 | +.. note:: |
| 162 | + |
| 163 | + Generating photon PDF sets on the fly can add significant overhead to the |
| 164 | + fitting procedure. It is therefore strongly advised to precompute the photon |
| 165 | + PDF set using ``vp-setupfit`` before running the fit with ``n3fit``. |
| 166 | + |
| 167 | +In either case, the generated photon PDF set will be stored locally in the |
| 168 | +``photons_qed_path`` specified in the :ref:`profile file <nnprofile>`, so that |
| 169 | +it can be reused in future fits. The folder containing the photon replicas will |
| 170 | +be named as ``photon_theoryID_<theoryid>_fit_<luxset>`` where ``<theoryid>`` and |
| 171 | +``<luxset>`` are the values specified in the runcard. The folder contains a ``npz`` |
| 172 | +file for each photon replica, named as ``replica_<replica_id>.npz``. Each replica |
| 173 | +file contains the photon PDF grid computed with FiatLux at :math:`Q_{\rm init} = 100` GeV, |
| 174 | +prior to the evolution through EKO. |
| 175 | + |
| 176 | +.. important:: |
| 177 | + |
| 178 | + Automatic upload to the NNPDF server through ``vp-upload`` is **not** |
| 179 | + supported at the moment. The user should manually create a ``tar`` archive |
| 180 | + file containing the photon replicas |
| 181 | + |
| 182 | + .. code-block:: bash |
| 183 | +
|
| 184 | + $ cd my_photon_folder |
| 185 | + $ tar -czf my_photon.tgz *.npz |
| 186 | +
|
| 187 | + Once the archive file is created, the user can upload it to the server. Refer |
| 188 | + to the :ref:`profile file <nnprofile>` to find the remote URL where photon PDF |
| 189 | + sets are stored. |
| 190 | + |
| 191 | + |
| 192 | +Using ``vp-setupfit`` (preferred) |
| 193 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 194 | + |
| 195 | + In order to trigger the computation of the photon PDF set during ``vp-setupfit``, |
| 196 | + the user needs to add the flag ``compute_in_setupfit: true`` in the ``fiatlux`` block |
| 197 | + discussed above. The following is an example of running ``vp-setupfit`` with |
| 198 | + this flag enabled: |
| 199 | + |
| 200 | + .. code-block:: bash |
| 201 | +
|
| 202 | + $ vp-setupfit qed_example_runcard.yml |
| 203 | + [INFO]: Could not find a resource (photonQED): Could not find Photon QED set /user/envs/nnpdf/share/NNPDF/photons_qed/photon_theoryID_40000100_fit_NNPDF40_nnlo_as_01180_qcd in theory: 40000100. Attempting to download it. |
| 204 | + [ERROR]: Resource not in the remote repository: Photon QED set for TheoryID 40000100 and luxset NNPDF40_nnlo_as_01180_qcd is not available in the remote server. |
| 205 | + [WARNING]: Photon QED set for theory 40000100 with luxset NNPDF40_nnlo_as_01180_qcd not found. It will be computed in vp-setupfit. |
| 206 | + [INFO]: Forcing photon computation with FiatLux during setupfit. |
| 207 | + [WARNING]: Using q2min from runcard |
| 208 | + [WARNING]: Using w2min from runcard |
| 209 | + Using Keras backend |
| 210 | + [INFO]: All requirements processed and checked successfully. Executing actions. |
| 211 | + ... |
| 212 | +
|
| 213 | + In addition, the user can also specify the optional parameter ``eps_base`` to |
| 214 | + the ``fiatlux`` block to set the base precision of the FiatLux computation, |
| 215 | + which controls the precision on final integration of double integral. By |
| 216 | + default, it is set to ``1e-5``. If the ``compute_in_setupfit`` flag is set to |
| 217 | + ``true`` despite the photon PDF being available locally, the code will |
| 218 | + recompute and overwrite the existing photon PDF set |
| 219 | +
|
| 220 | + .. tip:: |
| 221 | +
|
| 222 | + During ``vp-setupfit``, the code tries to distribute the computation of the |
| 223 | + photon replicas among the available CPU cores as specified in the |
| 224 | + ``maxcores`` key of the runcard. This can significantly speed up the |
| 225 | + computation of the photon PDF set. Make sure to set ``maxcores`` to a value |
| 226 | + compatible with the available hardware. For example, using ``maxcores: 64`` |
| 227 | + will try to compute up to 64 photon replicas in parallel using 64 GB of RAM. |
| 228 | +
|
| 229 | + Once the preparation step is completed, and the photon PDF set is generated and stored |
| 230 | + locally, the user can proceed to run the fit with ``n3fit`` as usual. |
| 231 | +
|
| 232 | +.. _photon_n3fit: |
| 233 | +Using ``n3fit`` (discouraged) |
| 234 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 235 | + If the user prefers to compute the photon PDF set during the fitting step with |
| 236 | + ``n3fit``, no additional flag is needed in the runcard and ``vp-setupfit`` is |
| 237 | + not required beforehand (unless other resources are needed such as the |
| 238 | + :ref:`theory covariance matrix <vptheorycov-index>`). The code will check for |
| 239 | + the presence of the photon PDF set locally before starting the fit for each |
| 240 | + replica. If it is not found, it will proceed to compute the photon replica as |
| 241 | + needed for each replica being fitted. The following is an example of running |
| 242 | + ``n3fit`` where the photon PDF set is computed during the fitting step: |
| 243 | +
|
| 244 | + .. code-block:: bash |
| 245 | +
|
| 246 | + $ n3fit qed_example_runcard.yml 1 |
| 247 | + [INFO]: Creating replica output folder in /user/runcards/qed_example_runcard/nnfit/replica_1 |
| 248 | + [WARNING]: Using q2min from runcard |
| 249 | + [WARNING]: Using w2min from runcard Using Keras backend |
| 250 | + [WARNING]: No Photon QED set found for Theory 40000100 with luxset NNPDF40_nnlo_as_01180_qed. It will be computed using FiatLux. This may impact performance. It is recommended to precompute the photon set before running the fit. Refer to https://docs.nnpdf.science/tutorials/run-qed-fit.html for more details on precomputing photon PDF sets. |
| 251 | + [INFO]: All requirements processed and checked successfully. Executing actions. |
| 252 | +
|
| 253 | + .. warning:: |
| 254 | +
|
| 255 | + Computing the photon PDF set during `n3fit` with multiple replicas or using GPUs |
| 256 | + has not been tested and may lead to unexpected behaviour. It is strongly advised to |
| 257 | + precompute the photon PDF set using ``vp-setupfit`` before running the fit with ``n3fit``. |
0 commit comments