Git Product home page Git Product logo

Comments (9)

cyrilchim avatar cyrilchim commented on May 6, 2024

Thanks for reaching out, Dmitri!

I think the point was to demonstrate GPU speed up rather than direct comparison to QL. We would very much welcome a contribution for a better CPU benchmark!

from tf-quant-finance.

DmitriGoloubentsev avatar DmitriGoloubentsev commented on May 6, 2024

Sounds good! I'll come back to you later on CPU benchmark for this.

Also, you do not include graph optimization time into reporting.
// # Second run (excludes graph optimization time)

I know, it's not dependent on number of paths, but it's still part of total pricing time. And for QL CPU execution it's 0.

Shouldn't you report this separately?

from tf-quant-finance.

DmitriGoloubentsev avatar DmitriGoloubentsev commented on May 6, 2024

On second thought, if you simulate 100 time steps and only apply 1 exp() at the end, you don't really do much of calculations per path.

So your problem is basically reduced to RNG algo competition.

You should somehow increase complexity in your SDE. Perhaps, use the Heston local vol model to make this benchmark more relevant to real world. With flat vols, flat rates and a simple normal process, I don't know how relevant this benchmark is for practitioners.

from tf-quant-finance.

DmitriGoloubentsev avatar DmitriGoloubentsev commented on May 6, 2024

What random generator is used if "PSEUDO_ANTITHETIC" is set?
For QL you don't use antithetic. I suspect antithetic reduces number of required random numbers by 2... Am I correct in this?

from tf-quant-finance.

SergK13GH avatar SergK13GH commented on May 6, 2024

There is an additional question about memory consumption, especially when run with XLA optimization.
I hit with error message when run the example just with num_timesteps= 5000 without XLA:
2022-11-17 14:50:46.371456: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 4000000000 exceeds 10% of free system memory.
Memory available 16G + 22G Swap.
And there is a kernel crash with XLA run with these parameters.
(ResourceExhaustedError: Out of memory while trying to allocate 72003200088 bytes. [Op:__inference_price_eu_options_1037])
Are there settings which controls limit for the memory allocation?

from tf-quant-finance.

cyrilchim avatar cyrilchim commented on May 6, 2024

To answer @DmitriGoloubentsev question, yes, antithetic sampling uses fewer samples indeed. I think we could measure time it takes to simulate random numbers and then subtract that from runtime. I think at the time of writing that colab I was mainly motivated by GPU speed up and not comparing CPU performance. The colab can be extended to sample from Heston model as well. (just need to update GenericItoProcess drift and volatility definitions).

As for graph compilation time, normally you would deploy a TensorFlow graph to avoid any compilation time overhead.

@SergK13GH , The samples are precomputed for vectorization purpose. You could switch to tff.math.random.RandomType.PSEUDO and set precompute_normal_draws=False in the sampler. We try to vecotrize computations where possible to ensure good GPU performance. One could ,of course, rewrite the whole thing using while loops but then you'd lose benefits of vectorization. As for memory controlling measures, I think you'd need to control it on your side.

from tf-quant-finance.

DmitriGoloubentsev avatar DmitriGoloubentsev commented on May 6, 2024

As for graph compilation time, normally you would deploy a TensorFlow graph to avoid any compilation time overhead.

Sorry, can you please elaborate on what "deploy a TensorFlow graph" means?

Do you assume you can compile graph once and use it for all valuations in the future?

from tf-quant-finance.

cyrilchim avatar cyrilchim commented on May 6, 2024

Yes, you could build a graph in Python and save its' proto definition that you then can deploy using TensorFlow serving.
See, e.g., here. You'd need to wrap your function in a tf.Module like here

from tf-quant-finance.

DmitriGoloubentsev avatar DmitriGoloubentsev commented on May 6, 2024

I can see how it may work for simple case (flat model parameters and the same number of time steps).

But am I right that in real problems you need to recompile graph everyday for all models and all trades?
I.e. as trades age, model parameter interpolations change, trades cash flows are paid, simulation time points move (they are usually defined w.r.t. current time), you need to redefine valuation graph and hence recompile it.

I think you can only reuse valuation graph on the same trading day and it's still a good idea to report how much time and memory needed for this step.

Simulating normal process using Euler scheme for 1000 time step is a very basic problem. What happens when you have 1000 IR swaps to price for xVA? Your graph is going to be huge and compilation time significant regardless if you use GPU or CPU.

from tf-quant-finance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.