From Tokenmaxxing to Trusted Throughput — Mingsheng Hong, Ironclad

AI Engineer · 23 min · 191 sentences · from YouTube's caption track

Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.

  1. 00:01[music]
  2. 00:12All right, let's get started.
  3. 00:14Apologies for the delay, but I'm really excited to be here.
  4. 00:18I'm Mingshan, VP of engineering focused on AI at Ironclad.
  5. 00:23And today I'll be telling you about something that's probably on top of many of your mind.
  6. 00:29uh how to control and optimize for your AI token spend.
  7. 00:34Can I get a get a quick show of hands that this is a relevant topic?
  8. 00:40Okay, awesome.
  9. 00:41I appreciate that.
  10. 00:45So, we have all heard a few sensational stories from the media.
  11. 00:50There's an interesting Amazon story where an employee just created kind of a voluntary dashboard and everyone start tracking their own AI token usage.
  12. 01:00I'm not sure there's explicit encouragement from the leadership, but the effect is you know engineers some of the engineers started competing with each other in maximizing their token usage and get to the top of the so-called leaderboard.
  13. 01:14There's a similar story from Meta and then another even more sensational story about some companies spending $500 million on cloud oops within a month.
  14. 01:25So while these may not be happening in your companies today, the threats, the risks are real.
  15. 01:32How do we think about the policies?
  16. 01:35How do we measure the cost?
  17. 01:36And how do we control and optimize for it?
  18. 01:40So one initial learning I want to share is it is really important to have dashboard that track every team every individual's token usage and cost but that should not be positioned as a leaderboard.
  19. 01:54We think of the the usage dashboard more as a smoke detector.
  20. 02:00If there are local pockets of teams or individuals that don't use much AI token that might be a signal worth investigating.
  21. 02:08But beyond that certainly we don't want to create even indirect incentive to maximize the token usage itself.
  22. 02:18So how do we think about it then?
  23. 02:21First I want to make sure that we position this talk for those of you whose teams have already gone through the hump of getting AI adopted.
  24. 02:31If you're still in the initial process of provisioning easy access to your engineers or encouraging the teams and individuals to adopt, then you may not be ready to implement some of the ideas for controlling
  25. 02:47and optimizing for cost.
  26. 02:49But that's okay.
  27. 02:50This could still be a good discussion.
  28. 02:51And frankly, we just got over that hump over the last couple quarters.
  29. 02:56So this is a very topical subject that every engineering leader I believe is navigating.
  30. 03:01So I would love to start that dialogue with you all today to explore the best practices.
  31. 03:07Can I get a quick show of hand for those of you whose teams have gone over the initial adoption phase now you are starting to seriously worry about the cost.
  32. 03:16Okay, I see roughly half of the hands raised.
  33. 03:18Thank you.
  34. 03:19So let's talk about then how we can control and how we can optimize what we call the trusted throughput as a kind of a proxy metric as a way to measure your ROI.
  35. 03:32But before that, just for those of you who are in the process of still increasing adoption, one lesson we learned is to after the kind of the top down leadership push
  36. 03:42is to sit down with the individual teams and uh the individuals who may be resistant or struggling with adoption, understand where they came from.
  37. 03:52For example, there are some legitimate concerns that I heard, you know, people say, "Hey, I used to really take pride and joy in handcrafting the code and now a lot of the joy and the pride
  38. 04:03got taken away and replaced with me reviewing AI slop code, right?
  39. 04:08So that doesn't sound like a very satisfying professional activity and that's where we need to kind of dig down and understand what are still the kind of the high impact
  40. 04:18and uh engineering tasks technical work that we can help our engineers continue to grow themselves in the era of the AI.
  41. 04:28So I wanted to share with you a bit more about what we at ironclad does and there's an interesting connection actually within how we think about optimizing for engineering AI token usage.
  42. 04:40So, ironclad is a legal contracting AI companies AI company.
  43. 04:45We build AI features and native AI products to help lawyers, procurement and other business users move forward new contracts, move them forward faster with controlled risk.
  44. 04:59What that means is building trust is the number one priority with our AI product features and products.
  45. 05:06And for the prior speak uh speaker speaker, she did a wonderful job telling you about the importance of trust and how to build it in their domain.
  46. 05:14In our ironclad product domain, it often means lawyers especially, but other persona as well taking the time to kind of test the water and see if they can trust the AI output.
  47. 05:25For example, they may feed our conversational search a set of contracts they are firmly familiar with and they run a search and see if the output is towards the expectation.
  48. 05:36If so, they may expand on searching for things they don't know about or apply other workflows using AI to solve other things like redlinining the contract um and you know finding anomalies and so on.
  49. 05:49And so similarly using AI and making sure AI is delivering high engineering value also involves a you know a sequence of steps in gaining trust from the internal engineers the leadership as well with as uh with our customers.
  50. 06:05So this is the focus of our talk today and this probably will not come as a surprise here.
  51. 06:14The goal is not to minimizing or not even necessarily to reduce token spend.
  52. 06:21So here we kind of use the word it's not about austerity.
  53. 06:24It's about further improving the ROI of the token spend.
  54. 06:29So how do we do that?
  55. 06:30Here we propose um a concept we call trusted throughput.
  56. 06:35So the trusted throughput comes from having the code reviewed and validated internally and ultimately validated in customer uh in customer deployments.
  57. 06:50So how do we go and how do we think about controlling the cost and uh measuring and in turn optimizing the ROI?
  58. 07:01The first step is I'm pretty confident that all of you your teams who have been adopting AI have been measuring the cost.
  59. 07:08If you're using a single tool like claw code or codeex then you tend to get very rich analytics from the vendor's dashboard already.
  60. 07:16If you're like us who use a combination of these different coding tools then we basically use AI to build simple dashboards and pipelines to extract such vendor data.
  61. 07:27So we can kind of crossorrelate them.
  62. 07:29Then we can break it down, aggregate and then break down by per team, per individual, what is their cost usage across all of these uh tools.
  63. 07:39So that's the first step for measuring cost.
  64. 07:42Now one pitfall I have seen and we wanted to caution everybody is to then jump from measuring cost to start reducing or minimizing the cost, right?
  65. 07:52Cutting cost.
  66. 07:53We think that is premature.
  67. 07:55Instead, the other important side of the equation for ROI is to measure value.
  68. 08:00How much value are we getting from burning the tokens?
  69. 08:03Once we can measure the cost and value side, we understand ROI and then to improve ROI, we want to find and then fix the bottlenecks.
  70. 08:12In the next couple slides, I'm going to introduce two new bottlenecks we identify in this whole new software development life cycle where code generation now becomes abundant thanks to AI.
  71. 08:23But the pressure is now getting pushed down to code review and continuous integration CICD the merging the code.
  72. 08:31So we'll talk about that and finally we'll put together these ideas into a pra pragmatic framework of how we think about optimizing the ROI and thus the leverage in using AI.
  73. 08:45Okay.
  74. 08:45So this is kind of just a slide in building or using the vendor dashboard to measure the cost.
  75. 08:51And again we want to caution that here the main goal for regularly reviewing the dashboard is to see a if there's still adoption gap within individual pockets of teams or the individual engineers
  76. 09:04and b if there are any sudden surprises in kind of the usage burst and if so understand what's been happening if they're legitimate and then also compare teams contextually.
  77. 09:16So this is important.
  78. 09:17We don't control just the AI usage per se because for example a platform infrastructure team the way they use AI and the way they get value may be different from the UI team.
  79. 09:26So we need to take the context into consideration.
  80. 09:30All of such review analysis is to help us extract learnings.
  81. 09:34So there's a self-learning loop that we can then feed back into institutional best practices.
  82. 09:39What we don't want to use the dashboards are to kind of stack rank people, right?
  83. 09:44making it a a leaderboard and somehow reward maximization.
  84. 09:49There's an interesting analogy I want to draw with uh a traditional edge productivity metric called lines of code.
  85. 09:56So I believe all of you will be tracking that metric but it wouldn't be wise to use that metric as the key goal to measure engine velocity because if we want
  86. 10:06productive and high quality engine work one can argue that removing code is even better.
  87. 10:12So, LOC line of code is an important metric but not something we want to directly optimize for.
  88. 10:17Same thing for the token usage and spend.
  89. 10:22So, that that gets us to the notion of trusted throughput.
  90. 10:26How do we think about that?
  91. 10:28How do we define that?
  92. 10:29First, I want to kind of share the quantified uh side of the things.
  93. 10:33What are the metrics that kind of we have been involving in defining and tracking.
  94. 10:37So we talked about line of code is clearly not a good way to measure if AI is you know generating a lot of value.
  95. 10:44So the next evolution can be let's count the number of open PRs pull requests.
  96. 10:50The intuition being engineers are using AI to generate a lot more code.
  97. 10:55So let's measure the open PR.
  98. 10:57So clearly we see a big kind of inflection in the open PR count.
  99. 11:03But eventually as we as I assume everyone would agree over the time even though people may do oneoff you know R&D work to try out things without lending them but eventually we're all measured by the code we ship.
  100. 11:16So therefore we evolved from tracking the open PR count to tracking the merge PR count.
  101. 11:22So that's an improvement.
  102. 11:25But the next question is not every merged PR is equal.
  103. 11:29There can be a PO with only 10 lines of code that takes forever that finds and fix a concurrency bug or there can be a thousand line kind of boilerplate
  104. 11:38code that just takes a lot of time to then kind of generate and review but otherwise it's not necessary adding as much business value.
  105. 11:46So as such we then started kind of tagging each merged PR with some sort of complexity score.
  106. 11:53There's no traditional definition of what that means.
  107. 11:55We looked at the literature a bit.
  108. 11:57So we just took a pragmatic approach of giving AI a well-crafted prompt and then we feed the PR into basically one or two M and say score the complexity based on t-shirt size.
  109. 12:09So I the idea being if you use AI to generate a more complex PR we consider that as being more valuable basically that's how we kind of add a weightage
  110. 12:18to each merged PR but that's not the end of the journey that's still something we're going to evolve keep evolving and I would love to discuss with everyone on kind of how we end up creating defining a set of metrics that kind of approximate
  111. 12:31the value AI is generating.
  112. 12:34Now let's look at the qualitative view.
  113. 12:36What we think about the way we would define trusted throughput is a high quality output that's interested by both internal engineering and leadership and external customers.
  114. 12:47We think they come from three buckets.
  115. 12:50The first bucket is all of the objective metrics that we run with checking the test coverage whether uh all of the predefined security checks are passing.
  116. 13:00Do we go through the regular canarying practice as we roll out features safely and so on.
  117. 13:06In addition, we complement the subjective objective metrics with our subjective human judgment.
  118. 13:13So that's where the code review, the design review come in to look at the code quality, clarity, maintenance, architecture fit and so on.
  119. 13:21And then finally we want to make sure through all of these internal objective and subjective check when the rubber meets the road how customer perceive the changes are there production fire that lead to ro rollbacks
  120. 13:35do customers complain have tickets that talk about usability uh friction uh bugs and so on.
  121. 13:41So these are the three buckets that together form what we think is trusted throughput from engineering.
  122. 13:52Okay.
  123. 13:52So now let's talk about from a software deploy deployment life cycle perspective where we observe the new bottlenecks are as I mentioned earlier AI code generation is making PR creation
  124. 14:06abundant.
  125. 14:08So now the the bottleneck from kind of the whole life cycle perspective gets shifted onto re review and they're subsequently merging the PR.
  126. 14:17Does that resonate?
  127. 14:20I see some heads nodding.
  128. 14:22So this is where we spend time on figuring out how we can further improve the review process as well as the continuous integration the CI process.
  129. 14:31So we will dive into these two topics in the next couple slides here.
  130. 14:35I just want to say a potential anti-attern anti-solution is that hey if the CI infrastructure gets overloaded then a workar around by engineers to stop splitting PR just start submitting large PR for review and submission
  131. 14:51because if it takes an hour to run all of your regression test and submit it I don't want to break my PR into 10 right which might take 10 hours
  132. 14:59however this in our view can be pretty risky because it makes the human review overhead higher it also reduce the quality of the review because the human attention can be spread thin so that is an anti-attern
  133. 15:13I wanted to caution so for code review the key principle we use is to make sure we onboard AI tooling as the first level of defense they don't replace human reviewers but we want to offload human reviewers
  134. 15:30as much as possible let the AI review take care of simpler things like coding style issues or if there's a missing test coverage.
  135. 15:39So, make sure the author gets through all of them before then the review gets routed to a human reviewer.
  136. 15:46And this way our human engineers can focus on applying their deep judgment on aspects that are somewhat subjective like if the code is good, if the architecture is sound,
  137. 15:57if the code uh uh passes kind of the security uh the security design and so on.
  138. 16:04so that in the end our engineering team can take the final accountability.
  139. 16:11Now let's look at CI.
  140. 16:13So I assume all of you deploy some form of CI uh CI/CD and what we're seeing is thanks to AI now making it much easier to generate code as splitting code into smaller but more PRs
  141. 16:27it puts a lot more pressure on the CI and this is something that uh if we don't address uh at a company level individual engineers can be struggling because that means they have to waste their human time babysitting
  142. 16:41the PR to get merged.
  143. 16:43If they run into flaky test then they have to manually they hit rerun it's very frustrating or they can recruit an AI agent to babysit and kind of do a loop but that in turn waste AI token as well.
  144. 16:55So these are not these are just workarounds not perfect solution and also tend to make engineers feel a little bit lower morale a little bit more frustrated.
  145. 17:04So what we what we are doing is kind of we put more uh developer experience uh platform kind of engineering to invest into reducing removing the flaky test improving the CI infrastructure
  146. 17:19and the key thing here is to also define and measure the right metrics for example uh the work clock time between when a peer is ready to submit till when it's submitted
  147. 17:32right if a typical CR uh run takes an hour.
  148. 17:35Does the typical PR submission take two or three hours?
  149. 17:38In which case, that's a red flag and also the number of times a PR needs to get retrieded for passing through the test.
  150. 17:45So, these are the key metrics that we are using to measure our developer experiences and the relevant team who is focused on improving uh these uh the developer experience.
  151. 17:58So with all of the analysis and ideas here we uh want to share kind of the a pragmatic framework of how we can then measure and optimize token usage.
  152. 18:10It has three aspects.
  153. 18:11The first one is set the right set of guards across setting the budget and quota tracking usage defining anomalies so that no users uh leaders can get notified if something feels wrong.
  154. 18:25This is complementaryary to still regular human review which can catch other interesting patterns or learnings and feedback into the institutional knowledge base.
  155. 18:35Let me just couple that with the third item here which is the learning loop we talk about as our leadership work with individuals to define these guard rails review the metrics and then refine that's how we kind of close the learning loop.
  156. 18:50In addition to that, we want to work with our teams, individual engineers to continue to search for and if needed innovate on the best practices of how to use AI, how to use AI to build products and also use it internally.
  157. 19:05For example, some engineers may be writing an agentic loop as part of the harness when they use cloud code.
  158. 19:13after they generated initial PR they go and loop around and say try and pass the set of tests and then if some tests don't pass just auto fix the test or the code and retry.
  159. 19:25One thing to watch out for is to put a limit on the number of loop steps to make sure if things go out of control we don't waste too many tokens on that.
  160. 19:35Another example is prompt caching.
  161. 19:37This is becoming increasingly more prevalent by the commercial uh model vendors where what they advise is if you send a prompt with the same prefix they could optimize how they process the prefix of the prompt.
  162. 19:54What that means then as a user to those is that we want to encourage our users to structure their prompt that way.
  163. 20:01For example, if your prompt consists of a system prompt followed by a user prompt, you want to put the system prompt that's fixed at the top and the varying content at the bottom.
  164. 20:12Context pruning is also important.
  165. 20:13We want to kind of drill it into each individual users kind of new kind of muscle memory.
  166. 20:19So they are aware that as they build out the context through a longer chat session, they would be mindful of summarizing the context and make sure that the token usage is efficient that way.
  167. 20:29There are increasingly more tools like claw code that will automatically manage and compact the context for you.
  168. 20:34And so this increases the token usage efficiency but also increase the quality of AI output.
  169. 20:40There are other ideas we're exploring as well.
  170. 20:48So I know we're at time so this is towards the end of the talk.
  171. 20:52There is sometimes we also face build versus by decision.
  172. 20:55The principle is simple for things that are non- differentiating like IDE CI infrastructure we want to buy.
  173. 21:02But then for things that are specific to our context like how we would generate high quality PR for small bug fixes versus building a new UI feature for refactoring and so on.
  174. 21:13We have our internal playbook which is a set of well-crafted AI prompts.
  175. 21:18So we save that and share across our team.
  176. 21:20So that gets reused and enhanced.
  177. 21:22So that's something we must build internally.
  178. 21:25When it comes to case to case though, sometimes it's still a bit ambiguous like we're trying to build what we call builder agent.
  179. 21:31That's like a cloud-based code generation that wrap the cloud codec and so on.
  180. 21:36While we know there are also other vendors out there that we're still exploring.
  181. 21:39So we love to exchange thoughts on that.
  182. 21:43So then to summarize here are a couple key lessons as we went through the last couple quarters of journey.
  183. 21:48I wanted to share so that hopefully you could kind of accelerate your process there.
  184. 21:52If I were to summarize these three things I would it's about learning planning ahead and learn from other people's stories mistakes.
  185. 22:00So what that means is think about build respences by early on as you are encouraging more code gen think about how that impact your code review and CI and how you can address these new bottlenecks.
  186. 22:12And finally, continue to define and instrument your system to get the right metrics to measure the health of your CI system and the whole developer experience in general.
  187. 22:24So that's it for the talk.
  188. 22:25We believe that this is the golden era of AI where maximizing token ROI is the key for every team success.
  189. 22:34And with that, I just want to end with saying we are hiring.
  190. 22:36I know this is engineering leadership crowd but if you know of someone who is interested in building cutting edge legal contracting AI we would love to talk.
  191. 22:45Thank you.