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