← Mithril Interview Insights

Mithril·Software Engineer·Onsite - Coding / Algorithms·Senior

Senior
Apr 2026

Summary

Round 4 at Mithril was a debugging exercise, not an algorithm grind. They handed me a small GPU resource manager codebase with logs and failing tests and basically said: figure out what's broken and fix it.

Questions Asked (3)

Q1

Given a small codebase for a GPU resource manager with failing unit tests and logs, identify and fix the bug in the GPU scoring logic.

Root Cause AnalysisAPI & Integrations
Author's notes

The root cause was that the scoring function wasn't actually checking the user's preference at all.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by reproducing the failing tests and examining the logs to pinpoint where the GPU scoring logic diverges from expected behavior. Then trace the scoring calculation step by step, comparing intermediate values against test expectations to isolate the bug. Finally, propose a fix, verify it against the tests, and consider edge cases or related code that might be affected.

Pro tip: Demonstrate a systematic debugging process: verbalize your hypotheses and how you'd validate them, rather than jumping to a fix. This shows maturity and reduces the risk of missing the root cause.

1. Reproduce and Observe

Run the failing unit tests and inspect the logs to understand the exact failure symptoms and any error messages or unexpected values.

2. Locate the Scoring Logic

Identify the function(s) responsible for GPU scoring and map the data flow from inputs to the final score.

3. Trace and Compare

Step through the scoring calculation with test inputs, comparing intermediate results against expected values to find the discrepancy.

4. Identify Root Cause

Determine the specific bug—such as an incorrect operator, missing normalization, or wrong weight—and explain why it causes the failure.

5. Fix and Verify

Implement the fix, re-run the tests to confirm they pass, and check for any side effects or additional edge cases.

Key Points to Mention

  • Reproducing the issue with the provided tests and logs
  • Tracing the scoring algorithm step-by-step with concrete inputs
  • Checking for common bugs like off-by-one errors, incorrect weights, or missing normalization
  • Validating the fix against the unit tests and considering edge cases
  • Communicating the root cause clearly and explaining the fix
  • Considering whether the bug could affect other parts of the codebase

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Debug a resource allocation and preemption bug in the same GPU manager codebase, where a unit test is failing due to incorrect preemption behavior.

Root Cause AnalysisSystem Design
Author's notes

Missing GPU lease.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by understanding the failing unit test and the expected preemption behavior, then trace the resource allocation and preemption logic to identify where the actual behavior diverges. Use a systematic debugging process: reproduce, isolate, hypothesize, and verify, while considering concurrency and state management issues.

Pro tip: Demonstrate maturity by discussing how you would add logging or use a debugger to inspect the state of the GPU manager during preemption, and emphasize the importance of writing a regression test to prevent future occurrences.

1. Understand the Test and Expected Behavior

Read the failing unit test to determine what preemption scenario it covers and what the expected outcome is. Clarify the requirements and assumptions about resource allocation and preemption.

2. Reproduce and Gather Data

Run the test to confirm the failure and collect logs, stack traces, or debug output. Instrument the code if necessary to observe the state of resources and preemption decisions.

3. Trace the Code Path

Follow the execution path from resource allocation to preemption, examining relevant functions, data structures, and synchronization mechanisms. Identify where the logic deviates from expectations.

4. Form and Test Hypotheses

Based on the trace, hypothesize the root cause (e.g., race condition, incorrect priority comparison, off-by-one error). Design experiments or add temporary assertions to validate or refute each hypothesis.

5. Fix and Verify

Implement a fix that addresses the root cause, ensuring it doesn't introduce regressions. Run the unit test and related tests to confirm the fix, and add a regression test if missing.

Key Points to Mention

  • Concurrency issues such as race conditions or deadlocks in preemption logic
  • Correctness of priority comparison and preemption conditions
  • State management of GPU resources (e.g., allocation tracking, preemption flags)
  • Importance of unit tests and test-driven debugging
  • System design considerations for scalability and fairness in resource allocation
  • Use of debugging tools (logging, breakpoints, tracing) to inspect runtime behavior

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Extend the preemption logic to sort candidates by GPU score before selecting which resource to preempt.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This was the least stressful part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the existing preemption logic and the definition of GPU score, then propose sorting candidates by GPU score in descending order before selecting the highest-scoring one to preempt. Discuss trade-offs like time complexity, stability, and whether to sort on every preemption or maintain a sorted structure.

Pro tip: Mention that if preemptions are frequent, a heap or balanced tree can provide O(log n) insertion and O(1) access to the max, avoiding repeated O(n log n) sorts. Also, consider tie-breaking rules and whether GPU score is static or dynamic.

1. Clarify requirements and assumptions

Ask about the current preemption logic, how GPU score is computed, and whether it changes over time. Confirm if the goal is to always preempt the highest GPU score or if other factors matter.

2. Design the sorting approach

Propose sorting candidates by GPU score in descending order. Discuss whether to sort the entire list or use a selection algorithm like quickselect for the top element.

3. Analyze time and space complexity

Compare O(n log n) sorting vs. O(n) selection vs. maintaining a heap. Consider the frequency of preemptions and the size of the candidate set to choose the most efficient method.

4. Handle edge cases and tie-breaking

Define behavior for equal GPU scores (e.g., use another metric like priority or timestamp). Ensure the logic handles empty candidate lists or missing scores gracefully.

5. Integrate and test

Explain how to integrate the new logic into the existing preemption system, and suggest unit tests for correctness, performance, and edge cases.

Key Points to Mention

  • Time complexity of sorting vs. using a heap or selection algorithm
  • Stability of the sort and tie-breaking rules
  • Whether GPU score is static or dynamic, and if re-sorting is needed
  • Space complexity and in-place sorting considerations
  • Impact on system performance and scalability
  • Testing strategy including edge cases and performance benchmarks

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.