|
86 | 86 | } |
87 | 87 | }, |
88 | 88 | "source": [ |
89 | | - "## Run ORE \"Classic\", Bump Sensitivities, Single-Threaded" |
| 89 | + "## Run ORE, Bump & Reval Sensitivities, Single-Threaded" |
90 | 90 | ] |
91 | 91 | }, |
92 | 92 | { |
|
130 | 130 | "#utilities.writeList(ore.getReportNames())" |
131 | 131 | ] |
132 | 132 | }, |
133 | | - { |
134 | | - "cell_type": "markdown", |
135 | | - "metadata": {}, |
136 | | - "source": [ |
137 | | - "## Run Again with ComputationGraph Enabled" |
138 | | - ] |
139 | | - }, |
140 | | - { |
141 | | - "cell_type": "code", |
142 | | - "execution_count": null, |
143 | | - "metadata": {}, |
144 | | - "outputs": [], |
145 | | - "source": [ |
146 | | - "params_cg = Parameters()\n", |
147 | | - "params_cg.fromFile(\"Input/ore_cg.xml\")\n", |
148 | | - "ore_cg = OREApp(params_cg)\n", |
149 | | - "ore_cg.run()\n", |
150 | | - "utilities.checkErrorsAndRunTime(ore_cg)\n", |
151 | | - "#utilities.writeList(ore_bump.getReportNames())" |
152 | | - ] |
153 | | - }, |
154 | | - { |
155 | | - "cell_type": "code", |
156 | | - "execution_count": null, |
157 | | - "metadata": {}, |
158 | | - "outputs": [], |
159 | | - "source": [ |
160 | | - "# Compare Pricing Stats\n", |
161 | | - "utilities.match_pricingstats_12(ore, ore_cg, \"Speedup\", True)" |
162 | | - ] |
163 | | - }, |
164 | | - { |
165 | | - "cell_type": "code", |
166 | | - "execution_count": null, |
167 | | - "metadata": {}, |
168 | | - "outputs": [], |
169 | | - "source": [ |
170 | | - "# Compare Sensitivities\n", |
171 | | - "# If we set pricing engine's ExternalDeviceCompatibilityMode to false, then get zero deviations from the reference run above\n", |
172 | | - "# if we set ExternalDeviceCompatibilityMode to true, then we see differences below due to different ordering of random variates in both runs\n", |
173 | | - "utilities.match_sensi_reports(ore, ore_cg, \"DeltaBump\", \"DeltaCG\", False)" |
174 | | - ] |
175 | | - }, |
176 | 133 | { |
177 | 134 | "cell_type": "markdown", |
178 | 135 | "metadata": { |
|
195 | 152 | } |
196 | 153 | }, |
197 | 154 | "source": [ |
198 | | - "## Run Again using AAD" |
| 155 | + "## Run ORE using AAD\n", |
| 156 | + "\n", |
| 157 | + "Check the following is set in **pricingengine_ad.xml**\n", |
| 158 | + "- **UseAD** is set to true\n", |
| 159 | + "\n", |
| 160 | + "Check the following is set in **sensitivity.xml**\n", |
| 161 | + "- **ComputeGamma** is set to false: otherwise AD is deactivated, because it does not support gamma and cross gamma calculation so far\n" |
199 | 162 | ] |
200 | 163 | }, |
201 | 164 | { |
|
239 | 202 | "outputs": [], |
240 | 203 | "source": [ |
241 | 204 | "# Compare Pricing Stats\n", |
242 | | - "utilities.match_pricingstats_12(ore, ore_ad, \"Speedup\", False)" |
| 205 | + "utilities.match_pricingstats_12(ore, ore_ad, \"Speedup\", True)" |
243 | 206 | ] |
244 | 207 | }, |
245 | 208 | { |
|
271 | 234 | "cell_type": "markdown", |
272 | 235 | "metadata": {}, |
273 | 236 | "source": [ |
274 | | - "## Discussion\n", |
275 | | - "Impact of:\n", |
| 237 | + "### Discussion\n", |
276 | 238 | "- Shift Scheme (EQ Spot)\n", |
277 | 239 | "- Shift Size (Vega)\n", |
278 | 240 | "- Lowering the BarrierLevel in EquityBarrierOption\n", |
279 | 241 | "- Lowering the KnockOutLevel in EquityAccumulator\n", |
280 | 242 | "- Lowering the KnockOutProfitAmount in FxTARF, introducing varying range strikes or leverages\n", |
| 243 | + "- Todo: Add CAM" |
| 244 | + ] |
| 245 | + }, |
| 246 | + { |
| 247 | + "cell_type": "markdown", |
| 248 | + "metadata": {}, |
| 249 | + "source": [ |
| 250 | + "# Sensitivities: CPU vs GPU" |
| 251 | + ] |
| 252 | + }, |
| 253 | + { |
| 254 | + "cell_type": "markdown", |
| 255 | + "metadata": {}, |
| 256 | + "source": [ |
| 257 | + "## Run with ComputationGraph Enabled\n", |
| 258 | + "\n", |
| 259 | + "Check the following is set in **pricingengine_cg.xml**.\n", |
| 260 | + "- **UseCG** is set to true\n", |
| 261 | + "- **ExternalDeviceCompatibilityMode** is set to true\n", |
| 262 | + "\n", |
| 263 | + "The latter ensures that we use the same ordering of random variables here and in the subsequent runs using external devices." |
| 264 | + ] |
| 265 | + }, |
| 266 | + { |
| 267 | + "cell_type": "code", |
| 268 | + "execution_count": null, |
| 269 | + "metadata": {}, |
| 270 | + "outputs": [], |
| 271 | + "source": [ |
| 272 | + "params_cg = Parameters()\n", |
| 273 | + "params_cg.fromFile(\"Input/ore_cg.xml\")\n", |
| 274 | + "ore_cg = OREApp(params_cg)\n", |
| 275 | + "ore_cg.run()\n", |
| 276 | + "utilities.checkErrorsAndRunTime(ore_cg)\n", |
| 277 | + "#utilities.writeList(ore_bump.getReportNames())" |
| 278 | + ] |
| 279 | + }, |
| 280 | + { |
| 281 | + "cell_type": "code", |
| 282 | + "execution_count": null, |
| 283 | + "metadata": {}, |
| 284 | + "outputs": [], |
| 285 | + "source": [ |
| 286 | + "# Compare Pricing Stats\n", |
| 287 | + "utilities.match_pricingstats_12(ore, ore_cg, \"Speedup\", False)" |
| 288 | + ] |
| 289 | + }, |
| 290 | + { |
| 291 | + "cell_type": "markdown", |
| 292 | + "metadata": {}, |
| 293 | + "source": [ |
| 294 | + "### Compare Sensitivities\n", |
281 | 295 | "\n", |
282 | | - "Todo:\n", |
283 | | - "- Add CAM" |
| 296 | + "If we set pricing engine's ExternalDeviceCompatibilityMode to false here, then we should see zero deviations from the reference run above\n", |
| 297 | + "\n", |
| 298 | + "If we set ExternalDeviceCompatibilityMode to true though, then we see differences below due to different ordering of random variates in both runs,\n", |
| 299 | + "However, this means we use the same ordering in the CG run as in the GPU run below.\n", |
| 300 | + "\n", |
| 301 | + "So if you want to check the former, the set ExternalDeviceCompatibilityMode=false first, rerun ore_cg and confirm perfect match of sensitivities." |
| 302 | + ] |
| 303 | + }, |
| 304 | + { |
| 305 | + "cell_type": "code", |
| 306 | + "execution_count": null, |
| 307 | + "metadata": {}, |
| 308 | + "outputs": [], |
| 309 | + "source": [ |
| 310 | + "# Compare Sensitivities: This run vs reference \n", |
| 311 | + "utilities.match_sensi_reports(ore, ore_cg, \"DeltaBump\", \"DeltaCG\", False)" |
284 | 312 | ] |
285 | 313 | }, |
286 | 314 | { |
287 | 315 | "cell_type": "markdown", |
288 | 316 | "metadata": {}, |
289 | 317 | "source": [ |
290 | | - "# Run again using the external GPU device\n", |
| 318 | + "## Run again using the external GPU device\n", |
291 | 319 | "\n", |
292 | 320 | "Note that this functionality is work in progress.\n", |
293 | 321 | "\n", |
294 | | - "Using an external device requires another few changes in pricingengine.xml's EngineParameters section:\n", |
| 322 | + "Using an external device requires another few changes in **pricingengine_gpu.xml**'s EngineParameters section:\n", |
295 | 323 | "- set **UseCG** to true\n", |
296 | 324 | "- set **UseExternalComputeDevice** to true\n", |
297 | | - "- set **ExternalComputeDevice** to the device name (**OpenCL/Apple/Apple M2 Max** on my machine, a **38 core GPU** device)\n", |
| 325 | + "- set **ExternalComputeDevice** to the device name, you can choose **BasicCpu/Default/Default** or (on my machine) **OpenCL/Apple/Apple M2 Max**\n", |
298 | 326 | "\n", |
299 | 327 | "Determine your available compute devices by running the QuantExt test suite with **quantext-test-suite --log_level=message --run_test=\"*/ComputeEnvironmentTest/testEnvironmentInit\"**\n", |
300 | 328 | "\n", |
301 | | - "You should also see the device name **BasicCpu/Default/Default** which is the CPU and can be used for testing." |
| 329 | + "**BasicCpu/Default/Default** refers to the CPU itself but treats it as an external device. This is useful for sanity checking the implementation - it should yield a perfect match in the sensitivity comparison below, but only moderate change in performance since we do not paralellize.\n", |
| 330 | + "\n", |
| 331 | + "**OpenCL/Apple/Apple M2 Max** is a **38 core GPU** device that should yield a noticeable performance improvement thanks to distributing the calculations across the GPU cores." |
302 | 332 | ] |
303 | 333 | }, |
304 | 334 | { |
|
0 commit comments