Skip to main content

Hardware, hosting and ML frameworks

Why This Matters

A model that scored 95% in the data scientist’s notebook can score 91% on a phone. It was compressed to fit, it runs on different hardware, and it was converted to another format by another framework. Where a model is built and where it runs are test conditions, and they belong in your test plan.

What you will learn

  • The hardware options for ML (CPU, GPU, ASIC and system-on-a-chip, neuromorphic) and when each fits
  • The options for developing and hosting a model, and what decides between them
  • What ML development frameworks do, and how to choose one

Syllabus: AI-1.1.5, AI-1.1.6, AI-1.1.7.

Hardware

Training a model and using it (inference) are different workloads, and often run on different hardware: train in the cloud on hundreds of GPUs, run the result on a smartphone.

ML hardware benefits from three features:

  • Handling large data structures: models and their data are big.
  • Massively parallel processing: ML is mostly matrix multiplication, which splits into many small independent calculations.
  • Low-precision arithmetic: a model often works almost as well with 8-bit or even 4-bit numbers instead of 32-bit. This is quantization, and it makes models smaller and faster, at some cost in accuracy.
HardwareStrengthsTypical use
CPUFew cores, high clock speed, high precision, flexibleGeneral computing; small models; less efficient for ML
GPUThousands of cores working in parallelTraining and inference; usually much faster than a CPU for ML; the best option for small-scale ML work
ASIC and system-on-a-chip (SoC)Built for AI: many cores, specialised data handling, in-memory processingEdge devices (phones, cameras, cars); training usually still happens in the cloud
Neuromorphic processorInspired by the brain, not the classic von Neumann architectureResearch and very low-power applications

For testers: the hardware is a test variable. Quantization and the conversion for an edge chip can change predictions. If the model will run on a phone, the acceptance test runs on (an emulation of) that phone, not on the developer’s GPU (module 8, ML deployment testing).

Developing and hosting a model

Build or buy

  • Third-party models: a pretrained model you download, or AI as a Service (AIaaS), a model you call through an API. Fast to start with; you control less, and you test something you cannot look into.
  • Private development: you build or fine-tune the model yourself. Tailored to the task, but it takes specialised skills, data and computing power.

Development environments

  • Local: direct control and privacy. Small models run on a PC; mid-sized models need dedicated GPUs; large models need a server cluster on-premises.
  • Cloud: flexible and pay-as-you-go. A public cloud is pre-configured and scales easily; a private cloud gives more security at a higher upfront cost.
  • Hybrid: prototype locally, keep sensitive data on-premises, and use the cloud for the heavy computing.

Hosting

The same options apply to hosting the finished model: local (privacy, no licence costs, limited capacity), dedicated servers, public cloud, private cloud or hybrid. The decision depends on:

  • the size and complexity of the model
  • the required performance (response time, number of requests)
  • the budget
  • security and privacy: can the data leave the building?
  • deployment needs: does it have to run offline, on a device?
  • regulatory requirements: where may the data be stored and processed?

For testers: each option changes what you can test. With AIaaS you test through the API only: you have no access to the training data, the provider can update the model without telling you, and your regression tests need to detect that. With a self-hosted model you control the version, and you also own the performance and security testing.

ML development frameworks

An ML framework is the software library a model is built with (TensorFlow, PyTorch and scikit-learn are well-known examples; you use scikit-learn in this course). Frameworks provide:

  • Data handling: loading, preprocessing and transforming data
  • Model building: algorithms, network architectures, layers and their connections
  • Training and optimisation: adjusting the parameters, distributed training over several machines, fine-tuning a pretrained model
  • Evaluation: metrics such as accuracy, precision and recall for classification, and error measures for ML regression
  • Deployment: converting the model for the web, mobile, edge or embedded systems

Frameworks differ in level of abstraction (a low-level API gives control but takes expertise; a high-level API is simpler but less flexible) and in domain (general-purpose, or specialised for images, speech or language).

How to choose: the application area, how easy it is to prototype, how configurable it is, the expertise of the team, the available resources, community support and the maturity of the ecosystem.

For testers: the framework is code you did not write, and it has defects too. Its evaluation functions calculate the numbers you report; its conversion tools produce the model that is deployed. Module 8 covers the risks: a wrong framework choice, a defect in a library, a conversion that changes behaviour.

Exercise

Choose hardware and hosting for each scenario, and name one thing the choice means for testing.

  1. A hospital wants a model that flags abnormal X-rays. Patient data may not leave the hospital.
  2. A start-up wants a chatbot in its app within two weeks, with a small team and no ML expertise.
  3. A car maker wants pedestrian detection that works without a network connection.
Show suggested answer
  1. Local or private-cloud development and hosting, with GPUs on-premises (or a hybrid where only anonymised data is used in the cloud). For testing: the test environment needs the same privacy controls as production, and test data must be anonymised or kept inside the hospital. As a medical device it is also high-risk under the EU AI Act (lesson 4).
  2. AIaaS: an LLM through a provider’s API, hosted in the public cloud. For testing: you test a black box through its API, so you need a regression suite that runs often, because the provider can change the model; and you test the parts you control: system prompt, guardrails, retrieval.
  3. An ASIC or system-on-a-chip in the car (edge), with training in the cloud. For testing: the model is quantized and converted for the chip, so the accuracy must be tested again on the target hardware, together with response time and behaviour in poor conditions (night, rain).

Exam-style questions

Quiz

1. Why do GPUs usually outperform CPUs for machine learning?

  • A. GPUs have a higher clock speed
  • B. GPUs have thousands of cores that can perform the many parallel calculations of ML at the same time
  • C. GPUs use higher-precision arithmetic
  • D. GPUs do not need memory
Show answer
B. ML is dominated by parallel calculations such as matrix multiplication. CPUs have higher clock speeds and precision but few cores.
Quiz

2. A company must keep sensitive training data on-premises but needs a lot of computing power for occasional large training runs. Which development environment fits best?

  • A. Local only
  • B. Public cloud only
  • C. Hybrid
  • D. A neuromorphic processor
Show answer
C. A hybrid environment keeps sensitive data on-premises and uses the cloud for compute-intensive work.
Quiz

3. Which function is typically provided by an ML development framework?

  • A. Writing the acceptance criteria
  • B. Converting a trained model for deployment on mobile or embedded systems
  • C. Labelling the training data
  • D. Deciding the risk level under the EU AI Act
Show answer
B. Frameworks cover data handling, model building, training, evaluation and deployment, including conversion for other platforms.