13 comments

  • simonw4 hours ago
    It looks to me like this won&#x27;t speed up llama.cpp for everyone, just for users running it in this particular kind of Virtualization.framework VM.<p>The fix here works around a problem where the VM was causing llama.cpp to select the wrong kernels.
    • frabonacci4 hours ago
      &gt; this won&#x27;t speed up llama.cpp for everyone, just for users running it in this particular kind of Virtualization.framework VM.<p>correct. these figures apply to llama.cpp inside the macOS guest configuration we tested. Lume is the VM frontend we used, while Apple&#x27;s Virtualization.framework provides the virtual GPU. bare-metal llama.cpp is unaffected.<p>&gt; The fix here works around a problem where the VM was causing llama.cpp to select the wrong kernels.<p>mostly, with one nuance: llama.cpp is selecting the correct kernels for the capability answers it receives. the stock guest reports an older Apple GPU family and a 32 KB threadgroup memory limit, so llama.cpp chooses slower kernels. Our process-scoped layer reports the tested Apple 9 and 64 KB values while allowing llama.cpp to select newer paths that the paravirtual GPU successfully execute<p>the layer itself though works at the Metal API boundary, independently of llama.cpp. other Metal compute and graphics apps now may select newer paths from the same capability answers, although this is still preliminary and each app needs separate testing. for example, MLX-LM stayed flat in our tests<p>historically related limitations have been coming up across Apple Silicon VM frontends for a while e.g. Tart tracked MPS&#x2F;GPU support back in 2023: - <a href="https:&#x2F;&#x2F;github.com&#x2F;openai&#x2F;tart&#x2F;issues&#x2F;501" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;openai&#x2F;tart&#x2F;issues&#x2F;501</a> - <a href="https:&#x2F;&#x2F;github.com&#x2F;openai&#x2F;tart&#x2F;issues&#x2F;1032" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;openai&#x2F;tart&#x2F;issues&#x2F;1032</a><p>UTM also has related cases where apps detect the Apple paravirtual Metal device but falls back to software rendering: <a href="https:&#x2F;&#x2F;github.com&#x2F;utmapp&#x2F;UTM&#x2F;issues&#x2F;7671" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;utmapp&#x2F;UTM&#x2F;issues&#x2F;7671</a>
      • sitkack3 hours ago
        why do use ai to write your posts ?
        • Aldo_MX2 hours ago
          Why do you expect an AI engineer to manually write prose?
          • b11250 minutes ago
            <i>Don&#x27;t post generated text or AI-edited text. HN is for conversation between humans.</i><p>Because it is not allowed here, that&#x27;s why. See the guidelines.
          • throwaway173axp1 hour ago
            Why do you think an AI engineer would go through the trouble lower casing everything except for proper nouns and abbreviations?
            • frabonacci1 hour ago
              the better question is why a throwaway account is doing capitalization forensics
    • octocop2 hours ago
      a win is still a win
  • engzaanin4 hours ago
    That makes sense. The title initially sounded like a general llama.cpp speedup on Apple Silicon, but if the improvement comes from fixing kernel selection inside Virtualization.framework VMs, that distinction is pretty important.
    • frabonacci58 minutes ago
      agreed on the title. added more context below on the exact scope and why this is really a VM capability-reporting issue: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49260087">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=49260087</a>
  • aeriose3 hours ago
    What I don&#x27;t get, which this article doesn&#x27;t talk about, why would Apple’s Virtualization.framework expose a lesser Metal profile instead of reporting all capabilities supported by the host GPU?
    • hugmynutus2 hours ago
      Because nobody knows.<p>Apple doesn&#x27;t let you &quot;pass&quot; the GPU through to a VM like most other ARM&#x2F;x86_64 processors (forwarding interrupts and PCIe memory regions). There are symbols defined to do this within the kernel (if you dump the binary) but they aren&#x27;t used in retail macos.<p>Instead you end up creating a paravirtual device that emulates the GPU acting like a &#x27;normal PCI device&#x27; which you give to clients. This is usually reserved (by other hardware vendors) for when you&#x27;re doing multi-tenat time sharing of higher end GPUs (like Nvidia enterprise cards can do).<p>These paravirtualized GPUs then just have &#x27;less features&#x27; and Apple (being Apple) states no reason why.
    • chorizo2 hours ago
      All M-series chips support Metal 4. Wonder if we can fix this with a simple override somewhere.
    • b11244 minutes ago
      QEMU&#x2F;kvm does this as a default, because keeping a more generic CPU &#x2F; etc makes moving VMs between machines with different hardware possible. If you try to move a VM it won&#x27;t work, of course, if the new machine doesn&#x27;t support what the old did.<p>Not sure of this is why Apple does it. With KVM, you tend to pick a baseline that all your machines support.
    • bestham3 hours ago
      Because it cannot be safely virtualised?
  • thehamkercat5 hours ago
    &gt; 11.08× faster and generated tokens 16.36× faster than the same workload in the same stock VM.<p>So this was the comparison, for me the title was a bit confusing
    • frabonacci4 hours ago
      yeah fair point. it&#x27;s always tricky to get the whole idea across within HN&#x27;s title limit. tldr: we ran the same workload in the same Lume macOS VM on the same Apple Silicon host, first with stock Metal capability reporting and then with our process-scoped dynamic library. The 11.08x figure is prompt processing, while 16.36x is token generation. the mechanism technically extends to graphics workloads too but these figures are specifically from llama.cpp
  • azinman25 hours ago
    I don’t understand what Apple 1-9 are. At first I thought it was M series chips but there is no M9 (yet)
    • niklasbuschmann4 hours ago
      <a href="https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;metal&#x2F;mtlgpufamily" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;metal&#x2F;mtlgpufamily</a>
      • wtallis4 hours ago
        So those generation numbers aren&#x27;t really anchored to Apple&#x27;s hardware designs. It&#x27;s just counting from when Apple introduced the Metal API, and the first several generations were when the GPU cores Apple was using were still nominally PowerVR designs.
        • frabonacci2 hours ago
          yeah the naming is confusing. Apple family 9 isnt M9, it&#x27;s a Metal GPU feature family. Apple maps family 7 to M1, family 8 to M2, family 9 to M3&#x2F;M4, and family 10 to M5
  • luciana1u3 hours ago
    my whole setup is buy more RAM, run it on CPU, and tell myself the GPU is just a personality trait I&#x27;m working on.
    • cyanydeez3 hours ago
      I&#x27;m hoping AMD wins when the RAM bubble bursts and their integrated AMD 395+ platform can keep getting faster and higher bandwidth.
      • bearjaws1 hour ago
        Forget the 395+, I want the MI350P (or similar) long term.<p>PCIe card is the way forward IMO, AI keeps changing so you don&#x27;t want static hardware.
        • petu1 hour ago
          How PCIe card is better?<p>&quot;Static hardware&quot; is still fully featured computer with lots of RAM, could be easily reused for other purposes.
      • speed_spread1 hour ago
        The unified memory architecture is interesting for toying with medium size models but will never offer as much bandwidth as a dedicated GDDR memory bank. Conversely, GDDR can&#x27;t be used for general CPU purposes because access latency is just too high. Unless someones also comes up with dynamically programmable memory banks, something I&#x27;m not sure would even be possible.
  • shay_ker4 hours ago
    I recall there was another YC startup that was working on Mac-specific ML optimizations for local inference (and perhaps fine-tuning).<p>I wonder if their work is related?
  • gigatexal3 hours ago
    All this work to get the Mac to be a platform useful for AI is being done despite Apple&#x27;s efforts. They&#x27;re famously pissed at Nvidia since the Nvidia + Intel Macs due to heat and other issues. But then the OS is a bit closed off and they move slow and are more focused on milking iOS and the App Store and services for money BUT the PA-Semi purchase and Apple Silicon and everything following it has made the hardware just so amazing and useful that despite all that people build for it.<p>I love the platform. I&#x27;m happy to see people building on it.<p>AND! if we ever get an M7 chip with the rumored 1.5TB of available ram all this work will not have been in vain. You think the ai acceleration is nice in the M5 wait till M7 and M8.
    • frabonacci1 hour ago
      apple silicon is what made us start Lume in the first place last year. the hardware is so good (M1 is now 6 years old!) that people keep pushing through the gaps in the platform. just yesterday we ran a fully offline computer-use agent with Cua Driver and Muse Glimmer, all locally on Apple Silicon, an now the same kind of agent can run isolated inside a macOS VM and use Apple’s GPU path too
  • dxsecarch4 hours ago
    [dead]
  • CurbStomper1 hour ago
    [dead]
  • purplemoonx4 hours ago
    [flagged]
    • kevin424 hours ago
      What hardware do you run? I have a first-gen mac studio, and I just run cmake and build with no special options. Same thing with llama-server, I just specify the model and use the built-in web UI.<p>For reference, I get ~26 tok&#x2F;sec with the new Muse 30B model.
      • dofm4 hours ago
        An M1 Max MBP manages roughly 10 tok&#x2F;sec without the Dflash speculative draft support so that tracks; the M1 Max apparently has trouble actually saturating its memory bandwidth.
    • drittich4 hours ago
      There are certainly challenges. When setting up a new model, I get AI to walk me through the commands using llama-benchmark that determine the best parameters for my particular configuration and needs. Once you&#x27;ve got that it&#x27;s pretty easy to port those parameters to llama-server. It takes me about an hour to run through this process. It would be great if there was a registry of hardware, models, configuration parameters, and resulting tokens per second. Maybe one day we&#x27;ll get there.
      • kevin424 hours ago
        What kind of parameters do you end up changing, and how much difference does it make. Perhaps I am missing something and get more tok&#x2F;sec, but I usually just do a git pull, then rebuild the latest whenever I get a new model.<p>In the past, I had to play with chat templates for some models to work with agents for tool calling. But I&#x27;ve never had to do anything other than specify the model, and tweaking the context size in some cases.
      • purplemoonx4 hours ago
        &gt; It takes me about an hour to run through this process<p>Yeah not doing that
    • unglaublich4 hours ago
      I think people generally throw Claude or Codex at the configuration challenge, so they don&#x27;t know either.
      • purplemoonx4 hours ago
        Maybe the llama.cpp dev loved webpack as a child, or just loves making the most simple thing complicated as hell for no reason lol
    • NamlchakKhandro4 hours ago
      No
  • myshapeprotocol4 hours ago
    [flagged]
  • woadwarrior014 hours ago
    The Claudish in the blogpost makes it really hard to ready. Also, TinyLlama 1.1B lol.