Skip to content

Non-profile galaxies run on CPU only #114

@craigwarner-ufastro

Description

@craigwarner-ufastro

There are times when profile galaxy is False and it is run on CPU. This happens 925 times in the sub-brick compared to 2010 where the GPU code is called. Weirder still, if I return [] in these examples (thinking I could remove them for speed testing purposes), we now have 2584 times the GPU code is called.

        if not (tr.isParamFrozen('images') and
                (len(tr.catalog) == 1) and
                isinstance(tr.catalog[0], ProfileGalaxy)):
            fname = "bad_nonprofile.pickle"
            if not os.access(fname, os.F_OK):
              f = open(fname,'wb')
              import pickle
              pickle.dump(tr, f)
              f.close() 
            if self._gpumode >= 10:
                print ("Skipping non-profile galaxy")
                return []
            print ("Running CPU version, frozen = ", tr.isParamFrozen('images'), "len = ", len(tr.catalog), " profile = ", isinstance(tr.catalog[0], ProfileGalaxy))
            #p = self.ps
            #self.ps = None
            t = time.time()
            R = super().getSingleImageUpdateDirections(tr, **kwargs)
            tt[0] += time.time()-t
            tct[0] += 1
            #self.ps = p
            return R

Line 208 in factored_optimizer.py. If I use a _gpumode > 10 then I return [] rather than calling R = super().getSingleImageUpdateDirections(tr, **kwargs). I do not understand why returning [] rather than calling the CPU code results in the GPU code being called 574 additional times.

Additionally, in line 131 of factored_optimizer.py, in getLinearUpdateDirection we have a block

        if image_thawed:
            tct[6] += 1
            cat_frozen = tr.isParamFrozen('catalog')
            if not cat_frozen:
                tr.freezeParam('catalog')
            x_imgs = super().getLinearUpdateDirection(tr, **kwargs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions