Meta Senior Machine Learning Engineer Interview Preparation Guide
Meta's Senior Machine Learning Engineer interview process consists of an initial recruiter screening, followed by two technical phone screens (one focused on coding and algorithms, one on ML fundamentals), and a comprehensive onsite loop with four rounds covering ML system design, advanced deep learning, coding under pressure, and behavioral assessment. The entire process evaluates candidates on technical depth, architectural thinking, problem-solving ability, communication skills, leadership potential, and cultural fit. Meta's evaluation focuses on engineers who can design scalable ML systems, own complex end-to-end projects, mentor team members, and demonstrate real-world impact. The process typically spans 4-6 weeks and includes assessment of proficiency with Meta's preferred frameworks (PyTorch), understanding of production ML infrastructure, and alignment with Meta's fast-paced, mission-driven culture.
Interview Rounds
Recruiter Screening
What to Expect
This initial screening combines the first recruiter call and any subsequent recruiter follow-up conversations. The recruiter will verify your background, assess your interest in the role and company, and explain the interview process timeline and structure. They will inquire about your salary expectations, relocation willingness, notice period, and availability to interview. For senior-level candidates, recruiters probe deeper into your career trajectory, significant technical contributions, leadership experience, and specific reasons for considering Meta at this stage. The recruiter may conduct preliminary technical calibration by asking about your ML systems experience or recent projects. This round typically lasts 30-45 minutes and serves primarily as a fit and logistics discussion, though communication skills and cultural alignment are subtly assessed.
Tips & Advice
Prepare a compelling 2-3 minute career narrative highlighting significant technical contributions, projects with measurable impact, and growth trajectory. Structure your story around key accomplishments and technical decisions you've made. Research Meta thoroughly: understand its product portfolio, recent announcements, technical initiatives, and organizational structure. For senior candidates, be prepared to discuss mentorship experience, examples of technical leadership, and your approach to solving ambiguous problems. Discuss compensation based on market research for your level and location—be realistic but advocate for yourself. Proactively address any gaps in your background or career transitions. Frame your interest in Meta specifically: reference particular teams, technical problems, or aspects of the company that align with your goals. Prepare thoughtful questions about team dynamics, technical challenges, growth opportunities, and company direction. Be authentic, enthusiastic, and professional. Recruiters appreciate candidates who demonstrate genuine interest rather than those applying broadly.
Focus Topics
Meta company alignment and motivation
Clear understanding of Meta's mission, recent products and initiatives, technical challenges, and culture. Articulate specifically why Meta appeals to you beyond compensation. Reference specific teams, problems, or technical directions.
Practice Interview
Study Questions
Production ML systems and scalability experience
Background designing, building, and deploying ML systems at scale. Experience with distributed infrastructure, production ML infrastructure, performance optimization, monitoring, and understanding challenges of serving billions of users.
Practice Interview
Study Questions
Leadership and mentorship experience
Concrete examples of leading technical projects, making architectural decisions, mentoring junior engineers, driving team technical discussions, and influencing technical direction. Demonstrates ability to scale beyond individual contribution.
Practice Interview
Study Questions
Career narrative and technical impact
Ability to articulate your professional journey, key accomplishments, and technical contributions with specific, quantifiable impact. Includes discussing projects you've owned, problems solved, systems improved, and business or product outcomes achieved.
Practice Interview
Study Questions
Technical Phone Screen - Coding and Algorithms
What to Expect
This 45-60 minute technical assessment evaluates your coding proficiency, problem-solving approach, and algorithmic thinking. You'll solve 1-2 coding problems in a shared IDE (typically CoderPad or similar). Problems focus on data structures (arrays, linked lists, binary trees, hash tables, graphs, heaps, stacks, queues) and algorithms (searching, sorting, dynamic programming, graph traversals like BFS/DFS, recursion). You're expected to write correct, efficient, well-optimized code while clearly explaining your approach. The interviewer assesses multiple dimensions: correctness of implementation, code quality and readability, algorithmic optimization (Big O time and space complexity), edge case handling, and clear communication of your thinking. For senior candidates, interviewers place additional emphasis on code design decisions, trade-offs between approaches, suggesting multiple solution strategies, and how you'd extend solutions to production scenarios.
Tips & Advice
Start by clarifying the problem: What are the constraints? What inputs should I handle? Then discuss your approach before coding. Write pseudocode or explain your algorithm first. Always analyze and communicate complexity (time and space Big O) before and after implementation. Think aloud to show your problem-solving process—interviewers value understanding your reasoning. Code incrementally: start with a brute force solution, then optimize progressively. Discuss trade-offs as you optimize: Why make this change? What are we trading? For senior candidates, discuss architectural considerations: How would this scale to large datasets? What are the implications of your choice? What alternatives exist and why didn't you choose them? Test your code mentally against edge cases (empty input, single element, large inputs, duplicates, negative numbers). Handle errors gracefully. Write clean, readable code with meaningful variable names. Practice LeetCode/InterviewQuery Medium to Hard problems regularly. Master your preferred programming language inside-out. Have experience solving problems both iteratively and recursively. Stay calm under time pressure.
Focus Topics
Problem-solving communication and collaboration
Ability to articulate your thinking clearly, explain design decisions, ask clarifying questions, discuss trade-offs, solicit feedback, and adjust approach based on interviewer input.
Practice Interview
Study Questions
Code quality, optimization, and edge case handling
Writing clean, readable, maintainable code. Proper naming conventions, error handling, comprehensive edge case testing, and refactoring for performance. Understanding when premature optimization is warranted.
Practice Interview
Study Questions
Algorithm design and Big O complexity analysis
Ability to design algorithms from scratch, analyze time and space complexity, compare approaches, and understand trade-offs. Knowledge of searching algorithms (binary search, hash-based), sorting algorithms (merge sort, quick sort), dynamic programming, graph algorithms (BFS, DFS, shortest path), and recursion.
Practice Interview
Study Questions
Data structures proficiency and selection
Deep working knowledge of arrays, linked lists, binary trees, balanced trees, hash tables, heaps, stacks, queues, and graphs. Understanding trade-offs of each structure (time and space complexity for operations), when to use each, and how to implement them efficiently.
Practice Interview
Study Questions
Technical Phone Screen - Machine Learning Fundamentals
What to Expect
This 45-60 minute technical assessment focuses on ML theory, algorithms, and practical problem-solving. You'll be asked conceptual and application-focused questions about machine learning. Typical questions include: 'How does random forest differ from logistic regression and when would you use each?', 'What are ways to counter overfitting?', 'How would you handle missing data in a dataset?', 'Explain the bias-variance trade-off and its implications,' 'What's the difference between classification and regression?', 'How do you approach feature selection?', 'When would you use clustering versus classification?' The interviewer assesses your understanding of ML fundamentals, ability to reason about algorithm selection, practical problem-solving skills, and depth of knowledge. You're expected to explain concepts clearly, discuss real-world considerations, and sometimes code simple implementations.
Tips & Advice
Focus on understanding the 'why' behind each algorithm and concept, not just memorization. Be prepared to compare and contrast algorithms: decision trees vs. random forests vs. neural networks; linear regression vs. logistic regression; clustering approaches. Always discuss trade-offs explicitly: accuracy vs. interpretability, complexity vs. performance, computational cost vs. model quality. Know common ML problems and standard approaches: handling class imbalance, feature scaling, cross-validation strategies, regularization techniques (L1, L2, dropout), handling missing data. Be ready to explain when you'd choose different approaches. For senior candidates, emphasize production considerations: How would you deploy this model? What would you monitor in production? How would you detect and handle model degradation? What's the inference latency? Be prepared to code simple algorithms if asked (e.g., implementing decision tree splits, gradient descent, or K-means). Discuss how you'd validate model assumptions. Show ability to reason about data quality impacts on models.
Focus Topics
Bias-variance trade-off and model complexity
Understanding bias and variance, how they relate to model complexity and training data size, and the bias-variance trade-off. Recognizing underfitting vs. overfitting.
Practice Interview
Study Questions
Evaluation metrics and model comparison
Selecting appropriate metrics for different problems: accuracy, precision, recall, F1 score, ROC-AUC, RMSE, MAE. Understanding when each metric is appropriate, how to interpret them, and how to compare models rigorously.
Practice Interview
Study Questions
Feature engineering and data preprocessing
Handling missing data (imputation strategies), categorical encoding, feature scaling (normalization, standardization), feature selection and extraction, dimensionality reduction. Understanding data quality impact on model performance.
Practice Interview
Study Questions
Supervised learning algorithms and model selection
Deep knowledge of regression (linear, polynomial), classification (logistic regression, SVM, naive Bayes), and ensemble methods (random forests, gradient boosting). Understanding assumptions, strengths, weaknesses, and computational requirements of each. Knowing when to use which model.
Practice Interview
Study Questions
Overfitting, regularization, and model validation
Understanding overfitting causes and solutions (L1/L2 regularization, dropout, early stopping, data augmentation). Knowledge of cross-validation strategies, train/validation/test splits, and selecting appropriate evaluation metrics.
Practice Interview
Study Questions
Onsite Round 1 - ML System Design
What to Expect
This 60-75 minute round is typically one of the most challenging and is critical for senior-level evaluation. You'll be asked to design an end-to-end ML system for a real, complex problem, such as 'Design a personalized news ranking system for the Meta feed,' 'Design a product recommendation engine that suggests items users might want to purchase,' 'Build a system to detect fraudulent transactions on a banking platform,' 'Design a system for ranking posts in comments section,' or 'Build a recommendation algorithm for search type-ahead.' You're expected to navigate the problem space systematically and discuss: (1) Problem understanding and requirements gathering, (2) Data sources, collection, and preprocessing pipeline, (3) Feature engineering and feature infrastructure, (4) Model selection, training strategy, and infrastructure, (5) Evaluation framework and metrics, (6) Deployment strategy and serving infrastructure, (7) Monitoring, retraining, and model updates in production, (8) Scalability and optimization for billions of users. The interviewer pushes you to think about trade-offs, real-world constraints, and system-level considerations rather than individual components.
Tips & Advice
Start by asking clarifying questions to understand requirements: What's the business objective? What's the primary success metric? What are latency and throughput requirements? How many predictions per second? Who are the users? What scale are we designing for? Discuss the problem holistically—don't jump to modeling. Think through the data pipeline first: What data is available? How would you collect it? What's the data quality? Discuss feature engineering thoroughly as this is often where models succeed or fail at Meta's scale. Propose a simple baseline model first (e.g., logistic regression), then discuss how and why you'd add complexity. Talk about deployment: How would you A/B test? How would you monitor for model drift? What would success look like? For senior candidates, emphasize architectural thinking: How does this scale to billions of users? What's the data infrastructure? How do you handle online vs. offline serving? What are latency requirements and trade-offs? Discuss end-to-end latency budget: data pipeline, feature computation, model inference, ranking. Mention specific technologies (e.g., Spark for data processing, PyTorch for training, model serving solutions). Discuss distributed training if models are large. Explain trade-offs explicitly (model complexity vs. inference latency, accuracy vs. computational cost, real-time vs. batch). Show you understand production constraints and can make pragmatic decisions.
Focus Topics
Production deployment and monitoring
Model serving infrastructure and latency optimization. Monitoring for model drift and performance degradation. Retraining strategies and automated pipelines. Rollback plans and incident response. Understanding inference serving frameworks.
Practice Interview
Study Questions
Evaluation, metrics, and A/B testing
Designing rigorous evaluation frameworks, selecting appropriate offline and online metrics, planning A/B tests, understanding statistical significance, and measuring real business impact.
Practice Interview
Study Questions
Scalability and production trade-offs
Designing systems that scale to billions of users and predictions per second. Understanding trade-offs between model complexity and inference latency, accuracy and computational cost, real-time vs. batch processing, storage vs. computation.
Practice Interview
Study Questions
Data pipeline and feature engineering at scale
Designing end-to-end data collection, preprocessing, feature engineering, and feature infrastructure. Understanding data quality, freshness, consistency, and infrastructure considerations. Discussing online vs. offline feature computation.
Practice Interview
Study Questions
Problem scoping and requirements gathering
Ability to clarify ambiguous problems through thoughtful questioning. Understanding business objectives, success metrics, constraints (latency, throughput, scale), user context, and stakeholders. Defining scope to be solvable yet impactful.
Practice Interview
Study Questions
Model architecture and training strategy
Selecting appropriate models for the problem, addressing data challenges (class imbalance, missing data), designing training strategies (online learning, distributed training, hyperparameter tuning), and understanding when to add model complexity.
Practice Interview
Study Questions
Onsite Round 2 - Advanced Machine Learning and Deep Learning
What to Expect
This 60-75 minute round dives deeper into advanced ML topics and deep learning techniques. You may be asked about neural network architectures and their applications, deep learning frameworks, advanced optimization problems, and specialized techniques for specific domains. Questions might include: 'How do neural networks prevent overfitting?' (discussing batch normalization, dropout, regularization), 'Explain different neural network architectures: CNNs, RNNs, LSTMs, Transformers,' 'How would you build a recommendation system using embeddings?' 'Explain attention mechanisms and why they're important,' 'What's the difference between different loss functions and when would you use each?', 'How do you handle imbalanced data in deep learning?', 'Discuss transfer learning and when you'd use pre-trained models,' 'How would you approach few-shot learning?' The round assesses your understanding of when and how to apply deep learning, knowledge of Meta's preferred frameworks (PyTorch), and ability to reason about architectural choices for specific problems.
Tips & Advice
Demonstrate solid understanding of deep learning fundamentals: backpropagation, gradient descent, activation functions, loss functions, and how neural networks learn. Be proficient with PyTorch (Meta's framework of choice) or TensorFlow. Understand different neural network architectures and their use cases: CNNs for vision/images, RNNs and LSTMs for sequential data, Transformers for NLP and beyond, Graph Neural Networks for structured data. Know when deep learning is appropriate vs. simpler models—deep learning isn't always the best choice. For Meta specifically, understand embeddings and representation learning deeply (critical for recommendation systems and ranking). Be ready to code a simple neural network layer, explain backpropagation, or discuss how you'd implement a specific architecture. Discuss distributed training and optimization for large-scale models. Talk about transfer learning and pre-trained models. Be familiar with common techniques: batch normalization, dropout, learning rate scheduling, early stopping. For senior candidates, emphasize architectural innovation and deep thinking: Why would you choose this architecture? What are alternatives? How would you optimize for Meta's constraints (latency, throughput)? Discuss trade-offs: Model complexity vs. inference latency, accuracy vs. computational cost, training time vs. inference time. Show you understand production implications of architectural choices.
Focus Topics
Transfer learning and modern deep learning techniques
Using pre-trained models, fine-tuning, domain adaptation. Few-shot and zero-shot learning. Meta-learning approaches. Knowing when to use transfer learning vs. training from scratch.
Practice Interview
Study Questions
Distributed training and production deployment of deep learning models
Data parallelism and model parallelism for training large models. Mixed precision training. Quantization and model compression. Inference optimization. Deploying models efficiently for real-time serving.
Practice Interview
Study Questions
Loss functions and optimization algorithms
Understanding different loss functions (cross-entropy, MSE, ranking losses, contrastive losses) and when to use each. Knowledge of optimization algorithms (SGD, momentum, Adam, RMSprop) and learning rate scheduling strategies.
Practice Interview
Study Questions
Regularization and training techniques for deep learning
Batch normalization, layer normalization, dropout, L1/L2 regularization, early stopping, data augmentation. Understanding how these techniques improve training and prevent overfitting.
Practice Interview
Study Questions
Embeddings and representation learning
Understanding how embeddings work, Word2Vec, GloVe, FastText. Matrix factorization for recommendations. Using embeddings for semantic similarity, recommendation systems, and ranking. Designing embedding spaces.
Practice Interview
Study Questions
Neural network architectures and framework proficiency
Deep understanding of different neural network types (fully connected, CNNs, RNNs, LSTMs, GRUs, Transformers, attention mechanisms) and their applications. When to use each architecture. Proficiency with PyTorch and TensorFlow for implementing and training models.
Practice Interview
Study Questions
Onsite Round 3 - Coding Under Pressure
What to Expect
This 45-60 minute round assesses your ability to write correct, optimized, production-quality code in a high-pressure environment with live coding. You'll solve 1-2 coding problems via a shared IDE. For ML Engineers at Meta, these problems often blend standard algorithmic challenges with ML-specific considerations. Example problems: 'Design a data structure supporting insert, delete, search, and get-random operations in O(1) time,' 'Find the next greatest element to the right for each element in an array,' 'Implement an LRU cache,' 'Solve problems involving trees, graphs, or dynamic programming.' The focus is on your ability to write correct implementations, optimize for complexity, handle edge cases, and think about real-world usage. For senior candidates, code quality, maintainability, and architectural thinking matter as much as correctness.
Tips & Advice
Use the same systematic approach as phone screens: clarify the problem, discuss your approach, write pseudocode, implement, optimize. This is similar in difficulty to phone screens but conducted in high-pressure onsite environment. For senior candidates, focus on code quality and architectural thinking, not just 'solving' the problem. Write code that's clean, maintainable, and demonstrates mature engineering judgment. Discuss trade-offs: Would you use more memory for faster lookup? When would you choose this approach? Be prepared to modify your solution if the interviewer introduces constraints. Handle all edge cases explicitly. For senior roles, think about real-world usage: Would this work with large inputs? What would you monitor? How would you debug if something went wrong? This is an opportunity to demonstrate that you're not just someone who can solve LeetCode problems—you're someone who thinks about production implications. Explain your optimization decisions. Refactor progressively. Ask clarifying questions. Show collaborative problem-solving.
Focus Topics
Communication and collaborative problem-solving
Explaining your approach clearly before implementing. Soliciting feedback. Discussing assumptions. Adjusting based on interviewer input. Thinking out loud to show your reasoning.
Practice Interview
Study Questions
Production-quality code practices
Writing code that handles edge cases properly, uses appropriate error handling, is readable and maintainable by others, follows conventions, and can be understood without extensive documentation.
Practice Interview
Study Questions
Problem decomposition and systematic problem-solving
Breaking down complex problems into manageable pieces. Identifying patterns and reusable components. Building solutions incrementally and testing as you go.
Practice Interview
Study Questions
Algorithm optimization and intelligent trade-offs
Ability to optimize code progressively for different constraints (time vs. space). Comparing multiple solution approaches and choosing based on problem requirements. Understanding when certain optimizations are worthwhile.
Practice Interview
Study Questions
Onsite Round 4 - Behavioral and Cultural Fit
What to Expect
This 45-60 minute round assesses your alignment with Meta's culture, demonstrated leadership, teamwork abilities, communication skills, and how you navigate challenges and ambiguity. You'll be asked behavioral questions exploring your past experiences, decision-making, and values. Questions include: 'Tell me about yourself,' 'Why Meta?', 'Tell me about a time you faced a significant technical obstacle and how you resolved it,' 'Give an example of using data and ML to influence a product or business decision—what was the impact?', 'Tell me about a time you disagreed with a team member and how you handled it,' 'Describe a time you mentored or helped a junior engineer grow,' 'How do you balance multiple complex projects and competing deadlines?', 'Tell me about your greatest technical accomplishment,' 'How do you approach learning new technologies or domains?' For senior-level candidates, there's strong emphasis on leadership, mentorship, driving impact, and demonstrating alignment with Meta's mission and fast-paced culture. The interviewer assesses whether you can thrive in Meta's environment and contribute to its culture.
Tips & Advice
Use the STAR method (Situation, Task, Action, Result) to structure answers clearly. Prepare 7-8 strong, concrete examples showcasing: (1) significant technical impact or ownership, (2) leadership of complex projects, (3) effective mentorship, (4) handling ambiguity and navigating unclear requirements, (5) cross-functional collaboration, (6) data-driven decision making, (7) handling failure or setback and learning, (8) alignment with Meta's culture. Practice telling each story concisely (2-3 minutes). For senior candidates, emphasize leadership: How have you mentored others? Name specific people. How have you influenced technical decisions? Tell stories showing you drive outcomes, not just execute tasks. Research Meta's mission, recent products, technical challenges, and company values. Explain specifically why Meta appeals to you—reference specific teams, technical problems, or company direction. Be authentic. Meta's culture rewards builders, risk-takers, and mission-driven people. Show genuine enthusiasm. When asked about failures, explain what you learned and how you applied that learning. Handle tough questions honestly but constructively. Demonstrate ownership: 'I took the lead on...', 'I drove the decision...', 'I took ownership...' Practice explaining impact in business and user terms: What did your project achieve? How did it affect users, engagement, revenue? Prepare good questions for your interviewer about technical challenges, team structure, and growth opportunities.
Focus Topics
Meta culture and mission alignment
Authentic understanding and articulation of alignment with Meta's mission (connecting people, advancing AI/metaverse). Explaining what excites you about Meta's technical direction and products. Demonstrating understanding of Meta's values and culture.
Practice Interview
Study Questions
Cross-functional collaboration and conflict resolution
Examples working effectively with product, design, infrastructure, and other engineering teams. Handling disagreements professionally and constructively. Building consensus. Navigating competing priorities.
Practice Interview
Study Questions
Navigating ambiguity and taking ownership
Examples of handling unclear requirements or ambiguous problems. Taking ownership of vague problem spaces. Defining scope and requirements. Driving projects to completion with minimal guidance. Making autonomous decisions.
Practice Interview
Study Questions
Leadership and technical mentorship at scale
Concrete examples of leading complex technical projects from conception to impact. Mentoring junior and mid-level engineers. Making architectural decisions and driving consensus. Influencing team technical direction and strategy. Growing others' capabilities.
Practice Interview
Study Questions
Data-driven decision making and measurable impact
Stories demonstrating using data and ML to influence product or business decisions. Showing how you measure impact. Articulating real-world outcomes (e.g., improved engagement, reduced latency, better accuracy). Connecting technical work to business value.
Practice Interview
Study Questions
Frequently Asked Machine Learning Engineer Interview Questions
Sample Answer
Sample Answer
Sample Answer
Sample Answer
import numpy as np
from scipy.stats import ks_2samp
def psi(expected, actual, buckets=10):
eps=1e-6
exp_hist, _ = np.histogram(expected, bins=buckets, density=True)
act_hist, _ = np.histogram(actual, bins=buckets, density=True)
exp = exp_hist + eps; act = act_hist + eps
return np.sum((exp - act) * np.log(exp / act))
# KS test
stat, p = ks_2samp(train_feature, prod_feature)Sample Answer
Sample Answer
#include <atomic>
#include <cstdint>
struct Node {
int value;
std::atomic<uint64_t> next; // lower bits: pointer, high bit: marked
Node(int v): value(v), next(0) {}
};
inline uintptr_t pack(Node* p, uint64_t tag){ return (uintptr_t)p | (tag & 1); }
inline Node* ptr_of(uintptr_t x){ return (Node*)(x & ~uintptr_t(1)); }
inline bool marked_of(uintptr_t x){ return x & 1; }
class LFList {
std::atomic<uintptr_t> head; // packed pointer+mark/tag
public:
LFList(){ head.store(pack(nullptr,0)); }
bool find(int val, std::atomic<uintptr_t> &pred, std::atomic<uintptr_t> &curr){
// traverse, help removing marked nodes
// omitted for brevity
return false;
}
void insert(int val){
Node* n = new Node(val);
while(true){
uintptr_t h = head.load();
n->next.store(h);
if(head.compare_exchange_weak(h, pack(n, (uintptr_t(h)+1)&1))) return;
}
}
bool remove(int val){
// logical mark then physical CAS from pred->next to curr->next
// use CAS loops similar to Harris-Michael list
return false;
}
};Sample Answer
Sample Answer
Sample Answer
# python
import os
import signal
import torch
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
def init_distributed(rank, world_size, backend="nccl"):
# Set CUDA device for this process
torch.cuda.set_device(rank)
os.environ['MASTER_ADDR'] = os.environ.get('MASTER_ADDR', '127.0.0.1')
os.environ['MASTER_PORT'] = os.environ.get('MASTER_PORT', '29500')
# Initialize process group (synchronous)
dist.init_process_group(backend=backend, rank=rank, world_size=world_size)
# Optional: tune cudnn for deterministic/fast behavior
torch.backends.cudnn.benchmark = True
def cleanup_distributed():
if dist.is_initialized():
dist.barrier() # ensure all processes reach cleanup
dist.destroy_process_group()
def train_loop(rank, world_size, args):
try:
init_distributed(rank, world_size)
device = torch.device(f'cuda:{rank}')
# seed per-rank for reproducibility
seed = args.seed + rank
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
# Build model and move to device
model = build_model().to(device)
# Wrap model in DDP (find_unused_parameters only if necessary)
model = DDP(model, device_ids=[rank], output_device=rank, find_unused_parameters=False)
# Dataset and DistributedSampler to shard data and avoid overlap
dataset = build_dataset()
sampler = DistributedSampler(dataset, num_replicas=world_size, rank=rank, shuffle=True)
loader = DataLoader(dataset, batch_size=args.batch_size, sampler=sampler, num_workers=args.num_workers, pin_memory=True)
optimizer = build_optimizer(model)
loss_fn = build_loss()
for epoch in range(args.epochs):
sampler.set_epoch(epoch) # important for shuffling across epochs
model.train()
for batch in loader:
inputs, targets = batch_to_device(batch, device)
outputs = model(inputs)
loss = loss_fn(outputs, targets)
optimizer.zero_grad()
loss.backward()
# gradient clipping, if needed, before step
torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)
optimizer.step()
# Save checkpoint only from rank 0 to avoid races
if rank == 0 and (epoch % args.save_every == 0):
torch.save({
"epoch": epoch,
"model_state": model.module.state_dict(), # DDP wraps module
"optim_state": optimizer.state_dict()
}, f"{args.ckpt_dir}/ckpt_epoch_{epoch}.pt")
except Exception as e:
# Log error locally; ensure other ranks don't deadlock
print(f"[rank {rank}] Exception: {e}", flush=True)
# Use a non-blocking broadcast to inform other ranks (optional)
# Ensure we still attempt a barrier with timeout semantics in production
finally:
# Best-effort barrier; wrap in try to avoid deadlock if some ranks crashed hard
try:
if dist.is_initialized():
dist.barrier()
except Exception:
pass
cleanup_distributed()
def spawn_main(world_size, args):
# Prefer torch.multiprocessing.spawn for multi-process launching
import torch.multiprocessing as mp
mp.spawn(train_loop, args=(world_size, args), nprocs=world_size, join=True)
# Signal handler to allow graceful termination (SIGTERM)
def setup_signal_handlers():
def _signal_handler(sig, frame):
print(f"Received signal {sig}, exiting", flush=True)
# No blocking operations in handler; set flags or rely on finally in train_loop
signal.signal(signal.SIGTERM, _signal_handler)Sample Answer
Search Results
Meta Machine Learning Engineer Interview Guide - Prepfully
Interview Questions · Why do you want to join Meta? · Why do you think you will be a good fit for the role? · What responsibilities do you expect to have from your ...
Meta Machine Learning Engineer Interview - Datainterview.com
What are ways to counter overfitting? · Have you implemented any machine learning algorithms from scratch? · How do you test your ML models for ...
Meta ML Engineer Interview Decoded 2025: Systems, Strategy ...
Meta ML interview questions are designed to test how you think, not just what you know. You'll need to demonstrate strong technical depth, ...
Meta Machine Learning Engineer Interview (questions, process, prep)
Tell me about yourself. Why Meta? Give me an example of a project where you used data and machine learning. Tell me about a time you faced an obstacle ...
Meta Machine Learning Engineer (MLE) Interview Guide - Exponent
Why do you want to work at Meta? ... Tell me about a project you worked on. ... Tell me about your current role. ... Describe your machine learning experience.
This interview preparation guide was generated using AI-powered research from the sources listed above. While we strive for accuracy, we recommend verifying critical information from official company sources.
Want to create your own tailored preparation guide using our deep research?
Get Started for FreeInterview-Ready Courses
Visual-first, interactive, structured learning paths
Browse Machine Learning Engineer jobs
AI-enriched listings across hundreds of company career pages
Explore Jobs