Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Marginals run with Stata 19.5 on AMD Ryzen 7 seem way too slow vis Stata 18.5 and Apple's M2

    I just got a new HP desktop (AMD Ryzen 7 8700G) and was trying to get marginals predictions for a complex interaction terms for a mixed effects multinomial logit model. (I have 32 GB of RAM but I don't think that is a constraint here) My new machine is running StataNow/SE 19.5 for Windows (11) (64-bit x86-64) Revision 5-21-25.

    The commands are:
    . meologit Y period##i.group#i.party male bachelor married o65 b3.hhi_infl24_r [iw=rake_comb] || survey:, vce(robust)

    then
    .margins i.period#i.group#i.party3, expression(predict (outcome (4)) + predict(outcome (5))) vce(unconditional) saving(me_margins_period_prox_party)

    NB (if it matters): The data is about 8000 survey responses over 9 different surveys grouped into 4 periods. Y is a 5-item agree/disagree scale; the interaction terms are unique valueses of group (=3), party (=3), and period (=4). Male, bachelor (degree), and married are all 0/1 and b3.hhi... is income in 6 categories. The weights are probability weights with a mean of ~1 in each survey.


    BENCHMARK: My benchmark is a basic Macbook Air laptop with an Apple M2 (2022 vintage) chip (8 GB RAM) running StataNow 18.5 for Mac Apple Silicon Revision 2-26-25 (I'm running Sequoia 15.5)


    Both machines estimate the basic parameters and errors qucikly... almost certainly in less than 10 seconds, and output identical estimates. Margins results are also identical... EXCEPT

    The Macbook air with an M2 completed the task in a little under 2 hours (~1 hr 52 min). The desktop took almost 5 hours (~4 hours 50 minutes)

    I realize that interactions and asking for unconditional errors are requiring extra time... but I think the AMD Ryzen 7 should be killing the M2.

    So ... I ran this again on a simpler version of the above model. (I cut the number of surveys from 9 to 6, and the number of periods from 4 to 3... lowering to about 5000) Same model structure in the first command, but I asked margins to provide the pairwise comparison differences , that is. .

    margins i.tperiod#i.proximity#i.party3, expression(predict (outcome (4)) + predict(outcome (5))) vce(unconditional) pwcompare saving(xxx)

    This went much faster.... but the performance difference was similarly bad: Stata 18.5 on the M2 did it in just under 30 minutes; Stata 19.5 on the AMD chip took a little more than twice as long: a little over an hour.


    Any thoughts on what is going on here? Is this really AMD, not Stata?

    I realize that there may be some ways to chunk this, but I seriously did not think I was asking this new chip and newer version of Stata for an all day exercise.

    I know I can get MP, but SE is all my university provides. And I'm not even sure what difference it would make here to spend 40% more a year for MP.

    The LLMs instinctively(??) blame Stata... Claude4, for example, thinks the AMD chip should be crushing the M2.

    Thanks for any guidance.

    Lyle


    PS If it matters I did set up Stata with the following commands (on both machines) to better insure this was a like with like comparison.

    set mem 16g (though the mac only has 8)
    clear matrix
    clear mata
    set maxvar 32000
    set segmentsize 32m
    set checksum off

  • #2
    a complex interactin between stata memory allocation, windows/mac RAM, and swapfiles (therefor SSD and interface speed) might be at play here?
    i've tried to manage this so Stata nevere asks for more RAM than the OS call allocate without swap. but data and mata size is obvioulsy dependedn ton your model, not the OS (?)
    the official docs are here:
    https://www.stata.com/manuals18/u6.pdf

    Comment


    • #3
      Very concerning results. Potentially, you can run some more benchmarks to see whether this problem applies to all commands or only certain computational problems. Some options for benchmarking can be found here:

      https://www.statalist.org/forums/for...s-and-versions
      https://github.com/fbittmann/benchmark

      Best wishes

      (Stata 18.0 MP)

      Comment


      • #4
        If possible, I would try running both versions of Stata on each machine. If Stata 18.5 and 19.5 on the same machine resulted in 19.5 being much slower, it might suggest that 19.5 has some problem that 18.5 didn't have.

        Conversely, if 18.5 and 19.5 run equally fast on the new machine (but slower than on the Mac) it may indicate some sort of problem on the new machine.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          This is a very relevant discussion. Evidences below suggest Stata performs better in Intel than AMD chips:

          https://www.statalist.org/forums/forum/general-stata-discussion/general/1475468-benchmarking-stata-to-test-speed-across-computers-and-versions?p=1725912#post1725912

          https://www.statalist.org/forums/for...m2#post1777916

          and a possible explanation relates to Math Kernel Library (MKL) https://www.stata.com/stata17/math-kernel-library-mkl/, which, while runs on AMD, is better optimized for Intel CPUs.


          It would be nice to hear from users that have both architecture ( not my case ) or are willing to provide us some AMD benchmarks, based this thread code

          https://www.statalist.org/forums/forum/general-stata-discussion/general/1475468-benchmarking-stata-to-test-speed-across-computers-and-versions







          Comment


          • #6
            If you have licences for both 18.5 and 19.5, you should be able to install both on 2 machines. That would make it easier to determine whether the problem is with the machine/ processor or some sort of problem with version 19.5.

            Luis, most of your links keep on leading me to the top of this same thread. Is that what you intended or did you mean to link to other threads?
            Last edited by Richard Williams; 26 May 2025, 07:51.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

            EMAIL: [email protected]
            WWW: https://www3.nd.edu/~rwilliam

            Comment


            • #7
              Richard, hope this time I posted them correctly ( we are not allowed to test the posted links in the edit preview mode )

              the evidences come from:
              https://www.statalist.org/forums/forum/general-stata-discussion/general/1475468-benchmarking-stata-to-test-speed-across-computers-and-versions?p=1725912#post1725912

              https://www.statalist.org/forums/forum/general-stata-discussion/general/1777916-marginals-run-with-stata-19-5-on-amd-ryzen-7-seem-way-too-slow-vis-stata-18-5-and-apple-s-m2#post1777916
              and George Ford benchmark code:
              https://www.statalist.org/forums/for...20#post1477020
              Last edited by Luis Pecht; 26 May 2025, 09:18.

              Comment


              • #8
                I get the same error as Richard Williams, there are some added text after the end of the links in #7

                See if this works:

                https://www.statalist.org/forums/forum/general-stata-discussion/general/1475468-benchmarking-stata-to-test-speed-across-computers-and-versions


                https://www.statalist.org/forums/for...and-apple-s-m2

                Comment


                • #10
                  Your second link is directing us to the current thread: "...marginals-run-with-stata-19-5-on-amd-ryzen-7-seem-way-too-slow-vis-stata-18-5-and-apple-s-m2..."

                  What is the heading of the thread you are trying to link to?


                  Comment


                  • #11
                    Andre, the second link directs to this one, we are.

                    "...marginals-run-with-stata-19-5-on-amd-ryzen-7-seem-way-too-slow-vis-stata-18-5-and-apple-s-m2..." is the second report about AMD chips underperformance.

                    sorry for the confusion.
                    Last edited by Luis Pecht; 26 May 2025, 13:04.

                    Comment

                    Working...
                    X