Forward compatibility of CUDA code

If a software for scientific computation which uses CUDA is written for a previous architecture like Fermi (compute capability >=1.3) will it still work with newer architectures like Keplar, Pascal?

It may. Well written code should.

There can be no guarantees unless you test it. It is possible to write or build CUDA codes in such a way that breaks on newer architectures. But CUDA as a platform has a number of mechanisms to allow forward-compatibility of a code written for an older architecture, when run on a newer architecture.

All historical breakages of CUDA code I have observed personally were caused by:

(1) Invalid interpretations of (a) standard C++ behavior, or (b) guarantees provided by the CUDA programming model, e.g. with regard to warp-synchronous code

(2) Inadvertent or conscious (for performance) exploitation of (a) hardware artifacts and (b) toolchain artifacts

Except for 1(b), these are exactly the same reasons that some code running on CPUs can and do break when moving to newer hardware architectures or newer toolchains.